1
Dhurgan
Multiple templates in one script possible?
  • 2004/6/4 8:09

  • Dhurgan

  • Just popping in

  • Posts: 68

  • Since: 2004/2/11


Hi,

Probably a basic question but...

Since I, according to the documentation and code examples, have to specify the template before I include the header..i.e.

Quote:
$xoopsOption['template_main'] = 'files_submit.html';
include XOOPS_ROOT_PATH . "/header.php";

Is it possible to overide this later?
Why?
I would like to use different templates depending on what part of the code I'm running. I can solve this by having the template sort that out, but it would be quite convinient to be able to set the specific template when I decided what I need to do.
i.e.
Quote:
switch ($mode){
case 'update':
$xoopsOption['template_main'] = 'files_update.html';
break;
case 'manage':
$xoopsOption['template_main'] = 'files_manage.html';
break;
}


or even just...
Quote:
$xoopsOption['template_main'] = "files_".$mode.".html";



Would that be a "supported" method?

2
Mithrandir
Re: Multiple templates in one script possible?

Then wait with including header.php before you have determined the template.

Header.php basically initialize $xoopsTpl as a Smarty Template object, checks for cached pages and builds the blocks. If you provide a wrong template before including header.php, you risk the caching taking effect witht that template.

So as the first thing to do in a module page (after including mainfile.php naturally) is to figure out, which template is used - this may take function calls and other processing, but don't include header.php until this is done, and don't use the $xoopsTpl object until the header.php is included.

News v1.2 uses this in the main page to distinguish between By Topic and Classic view.

Login

Who's Online

241 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 241


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits