I am trying to write a module with an admin page. The admin page has three tabs. Instead of cramming all three tabs into one template I was trying to have the main template include each tab as a sub-template, using {include file='sub_template.tpl'}. This did not work. The file could not be found. I tried a whole bunch of relative paths but could not find one that works. Giving the absolute path to the file works but of course is not a portable solution.
What is the relative path to a module template file, or is there a better way to do what I am trying to do?
Relative path to module sub-template?
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Relative path to module sub-template?
Code: Select all
$this->ProcessTemplate('filename.tpl');
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Relative path to module sub-template?
I use $this->ProcessTemplate('filename.tpl') in action.defaultadmin.php to process the main template, but I want something to put inside the main template to include the sub-templates. The include-tag seems like a good candidate, only I don't understand how to get the path right.
Re: Relative path to module sub-template?
OK, I have been thinking. Perhaps the cleanest solution would be to implement each tab as a separate action? Now my main template would look something like this:
The action.defaultadmin.php would simply setup the $tab* variables and output the main template, while all the tab specific processing would be moved to action.admin_task1.php, action.admin_task2.php and action.admin_task3.php.
What do you think? Is this a good approach?
Code: Select all
{$tabs_start}
{$tab_start_task1}
{MyModule action='admin_task1'}
{$tab_end}
{$tab_start_task2}
{MyModule action='admin_task2'}
{$tab_end}
{$tab_start_task3}
{MyModule action='admin_task3'}
{$tab_end}
{$tabs_end}
What do you think? Is this a good approach?
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Relative path to module sub-template?
if you look at the action.defaultadmin.php of a couple of modules... News, Products, CGFeedback, etc. you will see that we do quite a bit more in php because there are things like permissions, preferences etc, that probably need to be checked to limit the ability of certain users, or to customize what is displayed for those users.
After that, we usually do something like:
in the function.admin_tab_sometabalias we do more security checks, and the functionality for that one tab, and at the end usually a
After that, we usually do something like:
Code: Select all
echo $this->StartTab('sometabalias');
include(dirname(__FILE__).'/function.admin_tab_sometabalias.php');
echo $this->EndTab();
Code: Select all
$this->ProcessTemplate('filename.tpl');
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.