1
dhansen
YANQ*: xoops+smarty
  • 2003/12/8 4:23

  • dhansen

  • Just popping in

  • Posts: 59

  • Since: 2003/12/6


*YANQ: "Yet Another Newbie Question"

I am new to both XOOPS and smarty so please be patient with me...

I am fiddling with my first theme and am adding...

{php}
$clrMainBG="#DDE1DE";
$clrBodyTable="#112233";
$clrWhatsis="#FF0000";
$clrWhatsis2="#00FF00";
{/php}

... then later trying to reference...

<table cellspacing="1" cellpadding="0"
bgcolor="{$clrBodyTable}">

... in my theme.html.

xoops/smarty appear to be ignoring my embedded smarty expressions -- but other smarty stuff in the script seems to be getting read OK (e.g. href="<{$xoops_url}). All of my smarty expressions including the curly braces are making their way down to the browser.

What am I doing wrong????!




2
hsalazar
Re: YANQ*: xoops+smarty
  • 2003/12/8 4:37

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


dhansen:

I'm not sure about what you've done, but I do remember XOOPS' implementation of Smarty has redefined the reference to the tags. That is, the base Smarty tags are {Variable}, while the XOOPS Smarty tags are <{Variable}>. Perhaps you should try with this first.

Cheers.

3
dhansen
Re: YANQ*: xoops+smarty
  • 2003/12/8 4:56

  • dhansen

  • Just popping in

  • Posts: 59

  • Since: 2003/12/6


Looks like that's part of it!

Now I'm doing...

<{php}>
$clrBodyTable="#112233";
<{/php}>

...and later referencing...

<table cellspacing="1" cellpadding="0" bgcolor="<{$clrBodyTable}>">

... but it's getting rendered as...

<table cellspacing="1" cellpadding="0" bgcolor="">

Is there a better way to do what I'm attempting (so I can change reference color constants by variable name rather than hardcoding them throughout theme.html while I tinker with it)?

dh





4
hsalazar
Re: YANQ*: xoops+smarty
  • 2003/12/8 6:22

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


dhansen:

The value of your variables is not reaching the template because you need to assign them to a Smarty variable.

Try this:

<{php}>
$clrBodyTable="#112233";
$xoopsTpl->assign('clrBodyTable', $clrBodyTable);
<{/php}>

It might work.

Cheers.

5
Draven
Re: YANQ*: xoops+smarty
  • 2003/12/8 6:28

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


THe problem is you're trying to assign SMARTY variables from within embedded PHP. It doesn't work like that. Either use:

<{assign var="clrBodyTable" value="="#112233"}>

and call it like this

<{$clrBodyTable}>

more info on the assign fnction herehttp://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN

or if you want to use PHP you do:

<{php}>
$clrBodyTable="#112233";
<{/php}>


and call it by using

<{php}> echo $clrBodyTable <{/php}>

NOTE: PHP assigned variables will not carry over into included .tpl files. I found that one out the hard way.

I've yet to find a way to assign a SMARTY variable from within embedded PHP. You would need to use the $tpl->assign("blah", "foo") which isn't avaible from within the template itself, only within the PHP scripts calling the template.

6
Draven
Re: YANQ*: xoops+smarty
  • 2003/12/8 6:30

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Quote:

Try this:

<{php}>
$clrBodyTable="#112233";
$xoopsTpl->assign('clrBodyTable', $clrBodyTable);
<{/php}>


I see we were posting at the same time.

Nope, that won't work since the $xoopsTpl var isn't available from within the templates scope. Not just that, but the template is the last thing being parsed, so the variable has to be assigned before the template is parsed or assigned using SMARTY's internal assign function.

Login

Who's Online

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


Members: 0


Guests: 122


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