1
phillipd
Is there a limitation of doing multiple "user" templates vs "admin" templates
  • 2005/4/7 16:54

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


In my "admin" application code I can assign "template_main" to a template and as long as I do the

$xoopsTpl->display('db:'.$xoopsOption['template_main']);

prior to assigning another tempate I can layout several forms in one page with separate template files. I.E.

$xoopsOption['template_main'] = 'template1.html';
do form stuff
$xoopsTpl->display('db:'.$xoopsOption['template_main']);

$xoopsOption['template_main'] = 'template2.html';
do form stuff
$xoopsTpl->display('db:'.$xoopsOption['template_main']);

$xoopsOption['template_main'] = 'template3.html';
do form stuff
$xoopsTpl->display('db:'.$xoopsOption['template_main']);

This doesn't work in "user" code though. How can I accomplish the same thing ,using multiple templates, in user code?

Is template_main a "special" template? Can I use other names for that XOOPS option in user code?

Has anyone done multiple templates on a single page in "user" code. Am I asking a stupid question? (I hope not).

I guess I could use one template with multiple forms in it but I like to keep them separate.

Thanks

Doug P

2
wtravel
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates

Doug,

In the first template, after coding the first form, you could include template2 and template3 by using the smarty include code. Don't know the syntax from the top of my head, but I will check when I am back home.

Martijn

3
phillipd
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates
  • 2005/4/7 17:15

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Thankyou very much. I'm still relatively new at this so verbosity in example code is good.

Best regards

Doug P

4
-DJNZ-
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates
  • 2005/4/7 18:22

  • -DJNZ-

  • Just popping in

  • Posts: 30

  • Since: 2005/1/11


I think you are misunderstanding $xoopsOption['template_main'], and making things too complicated.

The purpose of $xoopsOption['template_main'] is to set the template which is called at the appropriate time by footer.php to display the module, using template variables which have been set by your code. You do not have to do
$xoopsOption['template_main'] = 'template1.html';
do 
form stuff
$xoopsTpl
->display('db:'.$xoopsOption['template_main']);

.. just do this instead:
$xoopsOption['template_main'] = 'template1.html';
do 
form stuff
$xoopsTpl
->display('db:'.$xoopsOption['template_main']);


But to get the output of a template into a variable rather than display it, you want to use $xoopsTpl->fetch. This will give you 3 ways to incorporate the contents of different templates into your output (in fact there are more ways using output buffering but let's keep it simple for the moment).

Perhaps the simplest is to have a template (module.html) which just displays the content of one variable:

<{$moduleOutput}>


In your module, you would then do the following:
$out  $xoopsTpl->fetch('db:template1.html');
$out .= $xoopsTpl->fetch('db:template2.html');
$out .= $xoopsTpl->fetch('db:template3.html');
$xoopsTpl->assign('moduleOutput'$out);
$xoopsOption['template_main']='module.html';


... or you can use different Smarty variables, doing some work in a template like this:
<h3><{$section1}></h3>
<
table class="outer"><tr><th><{$section2}></th></tr>
<
tr><td class="odd"><{$section3}></td></tr></table>

Then your module would do something like this:
$xoopsTpl->assign('section1'fetch('db:template1.html'));
$xoopsTpl->assign('section2'fetch('db:template2.html'));
$xoopsTpl->assign('section3'fetch('db:template3.html'));
$xoopsOption['template_main']='module.html';


Or finally, you can use the power of Smarty to the full like this:
<h3><{include file='db:template1.html'}></h3>
<
table class="outer"><tr><th><{include file='db:template2.html'}></th></tr>
<
tr><td class="odd"><{include file='db:template3.html'}></td></tr></table>

... then all you need to do (apart from assign the Smarty variables used by template1.html etc.) in your module code is:
$xoopsOption['template_main']='module.html';


Good luck playing around with these!

5
wtravel
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates

Thanks for the complete picture DJNZ

The syntax I was talking about is also mentioned by DJNZ:
<{include file='db:template1.html'}>

Cheers,

Martijn

6
phillipd
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates
  • 2005/4/11 22:32

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Thanks for the info. XOOPS seems to have 5 ways to do everything. I'll try these techniques out as I get time.

Regards

Doug P

7
phillipd
Re: Is there a limitation of doing multiple "user" templates vs "admin" templates
  • 2005/4/11 22:35

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Do you know of a module in the XOOPS repository that implements what you have described?

Thanks

Doug P

Login

Who's Online

253 user(s) are online (166 user(s) are browsing Support Forums)


Members: 0


Guests: 253


more...

Donat-O-Meter

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

Latest GitHub Commits