Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{include} and Array[]

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Aliba
Smarty Rookie


Joined: 31 May 2003
Posts: 14

PostPosted: Sat May 31, 2003 4:33 pm    Post subject: {include} and Array[] Reply with quote

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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat May 31, 2003 4:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Aliba
Smarty Rookie


Joined: 31 May 2003
Posts: 14

PostPosted: Sat May 31, 2003 4:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat May 31, 2003 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat May 31, 2003 6:37 pm    Post subject: Reply with quote

Special chars within quotes require backtick escapement:

Code:
{include file="header.tpl.html" title="News -  `$NEWS.subject`"}


Monte
Back to top
View user's profile Send private message Visit poster's website
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat May 31, 2003 8:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Aliba
Smarty Rookie


Joined: 31 May 2003
Posts: 14

PostPosted: Sat May 31, 2003 9:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat May 31, 2003 10:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sat May 31, 2003 11:00 pm    Post subject: Reply with quote

or update to 2.5.0 Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat May 31, 2003 11:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Aliba
Smarty Rookie


Joined: 31 May 2003
Posts: 14

PostPosted: Sun Jun 01, 2003 4:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP