View previous topic :: View next topic |
Author |
Message |
Aliba Smarty Rookie
Joined: 31 May 2003 Posts: 14
|
Posted: Sat May 31, 2003 4:33 pm Post subject: {include} and Array[] |
|
|
I have a problem. This worked once (in testing I belive) but once I upgraded Smarty and uploaded to the host it quit working.
I have a file called header.tpl.html that contains this line (among others):
Code: |
<TITLE>WebsiteName.com{if $title} - {$title|escape:"htmlall"}{/if}</TITLE>
|
That adds any prefix to the page title when built.
In the News detail page, I use this include:
Code: |
{include file="header.tpl.html"
title="News - $NEWS[subject]"}
|
Which should add the subject of the news item to the page title.
And I get the output:
Code: |
<title>WebsiteName.com - News - Array[subject]</title>
|
Can anyone help with this? I can't figure out how to address the subject element from the $News array within the {include}
Thanks.... |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat May 31, 2003 4:42 pm Post subject: |
|
|
It should be $NEWS.subject not $NEWS[subject] _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
Aliba Smarty Rookie
Joined: 31 May 2003 Posts: 14
|
Posted: Sat May 31, 2003 4:52 pm Post subject: |
|
|
That doesn't work either.....not in the context of quotes in an include anyway.
I've tried everything I could think of in both a smarty and php context and no go. It doesn't seem to want to access elements of the array from within quotes in an include. |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat May 31, 2003 5:02 pm Post subject: |
|
|
did you try {$NEWS.subject} _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat May 31, 2003 6:37 pm Post subject: |
|
|
Special chars within quotes require backtick escapement:
Code: | {include file="header.tpl.html" title="News - `$NEWS.subject`"}
|
Monte |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat May 31, 2003 8:12 pm Post subject: |
|
|
Right that slipped my mind there _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
Aliba Smarty Rookie
Joined: 31 May 2003 Posts: 14
|
Posted: Sat May 31, 2003 9:28 pm Post subject: |
|
|
Believe it or not, that didn't work either. Although backticks would seem to make sense. It gives the same output with the backticks around it, indicating that it still recognizes $News as an Array, but won't access the elements. All cache and compiled templates were cleared.
I'm wondering, is it possible that backticks may be added feature since my Smarty version? (which is 2.4.1 by the way)..... |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat May 31, 2003 10:46 pm Post subject: |
|
|
You probably need to use $`NEWS.subject` then _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Sat May 31, 2003 11:00 pm Post subject: |
|
|
or update to 2.5.0 |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat May 31, 2003 11:13 pm Post subject: |
|
|
Aliba wrote: | I'm wondering, is it possible that backticks may be added feature since my Smarty version? (which is 2.4.1 by the way)..... |
yep, you need 2.5.0+
Monte |
|
Back to top |
|
Aliba Smarty Rookie
Joined: 31 May 2003 Posts: 14
|
Posted: Sun Jun 01, 2003 4:29 am Post subject: |
|
|
aha, cool. Thanks for the answers guys, that's one that was killing me for a while.
I'll put the upgrade to 2.5 on the priority list. |
|
Back to top |
|
|