• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [solved] question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 9:10 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Sat Aug 25, 2007 9:55 am
Posts: 1176
Location: Berlin
i use this additional content block:
Code:
{content block='Meta Description' oneline='true' assign="metadesc"}{eval var=$metadesc}


this works.
but i want to use the metadesc twice in my template. therefore i use it in the tag and in the tag.
But in body tag i get the error:
string(43) "Smarty error: eval: missing 'var' parameter"

why does that not work?
thanks!

_________________
follow me on twitter
---
find great code snippets at i-do-this blog
---
powerful templates for cms made simple


Last edited by nicmare on Wed Mar 31, 2010 12:51 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 9:57 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu May 14, 2009 8:11 pm
Posts: 1269
Location: Lithuania
Quote:
{content block='Meta Description' oneline='true' assign="temp"}
{eval var=$temp  assign='metadesc'}

{* use it whereever you want *}
{$metadesc}

_________________
My best friends are: FAQ: How can I debug my code/site ?...showtemplate=false...module_customhow to create a patch, {process_pagedata}
And Yours ? :)


Top
 Profile  
 
 Post subject: Re: question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 10:03 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Sat Aug 25, 2007 9:55 am
Posts: 1176
Location: Berlin
Ah allright now i get no error but also no value in my body tag. but it works in the meta tag.
obviously i can use the var just one time in whole template?!

_________________
follow me on twitter
---
find great code snippets at i-do-this blog
---
powerful templates for cms made simple


Top
 Profile  
 
 Post subject: Re: question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 11:40 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu May 14, 2009 8:11 pm
Posts: 1269
Location: Lithuania
Quote:
but also no value in my body tag

Mind, variable should be generated before {content}. I think
Code:
{content block='Meta Description' oneline='true' assign="temp"}
is bellow {content} isn't it ? It would be easier if you attached page template and link to page.

_________________
My best friends are: FAQ: How can I debug my code/site ?...showtemplate=false...module_customhow to create a patch, {process_pagedata}
And Yours ? :)


Top
 Profile  
 
 Post subject: Re: question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 11:59 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 5954
Location: Fernie British Columbia, Canada
CMSMS (since 1.5 IIRC) performs template processing in a non-standard manner.

Given a simplified page template like:
Code:
<html>
<head>
{metadata}
</head>
<body>
{content}
</body>
</html>

1.  Anything above is processed
2.  The body is processed
3.  The head section is processed
4.  all of the information from the above 3 steps is glued back together and output.

This is done to allow setting variables in the body (i.e:from a module) that can then be used in the head (to do things like set page title etc).
i.e (another simplified example):
Code:
<html>
<head>
<title>{$mypagetitle}</title>
{metadata}
</head>
<body>
{content block='mypagetitle' oneline=true assign='mypagetitle'}
{content}
</body>
</html>

Notice how 'mypagetitle' is created in the body, and then used in the head section.

Alternatively
Code:
{content block='mypagetitle' oneline=true assign='mypagetitle'}
<html>
<head>
[color=green]<title>{$mypagetitle}</title>[/color]
{metadata}
</head>
<body>
[color=green]<h3>{$mypagetitle}</h3>[/color]
{content}
</body>
</html>

Notice how mypagetitle is created above the head section, and then used in both the head and the body.

However:  This will not work:
Code:
<html>
<head>
{content block='mypagetitle' oneline=true assign='mypagetitle'}
<title>{$mypagetitle}</title>
{metadata}
</head>
<body>
<h3>{$mypagetitle}</h3>
{content}
</body>
</html>

This is because the body is processed first, and the head section is processed afterwards, therefore {$mypagetitle} is not set until the head is processed.

Of course in these simplified examples I am not doing any error checking to make sure that somebody actually specified a string in the mypagetitle field in edit content.

This is useful for things like:
a) setting the canonical URL from the news detail page
b) setting the page title from a news detail page
or any other header variable that you want to set.

Hope this solves the issue once and for all.

_________________
Follow me on twitter
For quality help follow these instructions:
a) Think about the problem for an hour
b) research the problem for an hour
c) spend 1/2 an hour explaining it and providing as much information as you can muster
(too much information is okay, not enough information may get your question ignored).
--
if you can't bother explaining your problem well, why should we bother helping with it.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: question about {eval var=$...}
PostPosted: Wed Mar 31, 2010 12:50 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Sat Aug 25, 2007 9:55 am
Posts: 1176
Location: Berlin
ouh, this is VERY interesting and it finally solved my problems, thanks calguy :)

_________________
follow me on twitter
---
find great code snippets at i-do-this blog
---
powerful templates for cms made simple


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner