1
phatjew
one small step for a man . . .
  • 2003/11/7 19:10

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


I'm trying to get started with using SMARTY templates, and I am having trouble understanding how they work. I'm using the news module as a model, so all the questions below refer to news_index.html and news\index.php.

1. What is $xoopsOption, and what does this line do:

$xoopsOption['template_main'] = 'news_index.html';

I think what it does is tell the php file what SMARTY template to use (although on the smarty site the template files are .tpl, not .html). Is that right?

2. Why is it that $xoopsOption is used for things like:
$xoopsOption['storytopic']
$xoopsOption['storynum']

. . . but $xoopsTpl->assign(...) is used for everything else?

In other words, if 'storytopic' and 'storynum' aren't needed for the template, why not just save them as scalar variables $storytopic and $storynum? Why do you want them as part of the $xoopsOption object? Perhaps knowing the answer to #1 above will help me understand this.


3. At the bottom of the index.php file, there are a bunch of what look like config assignments:

$xoopsTpl->assign('lang_go', _GO);
$xoopsTpl->assign('lang_on', _ON);
$xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY);
$xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY);
$xoopsTpl->assign('lang_postedby', _POSTEDBY);
$xoopsTpl->assign('lang_reads', _READS);

Are these required all the time? I can't find where they are used, or how they are used. They don't show up in the template file at all.

Thanks in advance for any help.

2
Draven
Re: one small step for a man . . .
  • 2003/11/7 19:52

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Quote:

1. What is $xoopsOption, and what does this line do:

$xoopsOption['template_main'] = 'news_index.html';

I think what it does is tell the php file what SMARTY template to use (although on the smarty site the template files are .tpl, not .html). Is that right?

You are correct. You can use .html to call the main template files, then within the SMARTY template you can include both .html and .tpl files using the include function.
Quote:

2. Why is it that $xoopsOption is used for things like:
$xoopsOption['storytopic']
$xoopsOption['storynum']

. . . but $xoopsTpl->assign(...) is used for everything else?

In other words, if 'storytopic' and 'storynum' aren't needed for the template, why not just save them as scalar variables $storytopic and $storynum? Why do you want them as part of the $xoopsOption object? Perhaps knowing the answer to #1 above will help me understand this.


I'd have to double check the code again to know the exact answer here. I can say that $xoopsTpl->assign is used to pass on variables to the SMARTY template.
Quote:


3. At the bottom of the index.php file, there are a bunch of what look like config assignments:

$xoopsTpl->assign('lang_go', _GO);
$xoopsTpl->assign('lang_on', _ON);
$xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY);
$xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY);
$xoopsTpl->assign('lang_postedby', _POSTEDBY);
$xoopsTpl->assign('lang_reads', _READS);

Are these required all the time? I can't find where they are used, or how they are used. They don't show up in the template file at all.

Thanks in advance for any help.


Those are language constants (_GO = word "GO" used in a submit button), you find them in the language file

3
Herko
Re: one small step for a man . . .
  • 2003/11/7 20:11

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


xoopsOption is used to get the values from the option setting in the module config, if I am correct. This means that the values used are defined in the config tables and can be changed and set bythe module admin. Not sure tho, but this is what I remember (but hey, I'm no dev!)

Herko

Login

Who's Online

186 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 186


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