Global Variable in Templates
Posted: 31 July 2008 12:46 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  5
Joined  07-29-2008

Hi to everyone !
I’m a novice and I’m trying to understand how EE works.

I’ve created this Global Variable (in Templates) named {ud_copyright}:

© Copyright {current_time format=”%Y”} - All rights reserved

Then I use my Variable in the footer :
<p>{ud_copyright}</p>

Doesn’t work {current_time format=”%Y”}, the result is :
© Copyright {current_time format=”%Y”} - All rights reserved.

Why, where I’m wrong ?

Excuse me for this stupid question and many thanks to everyone.

Profile
 
 
Posted: 31 July 2008 01:22 AM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1644
Joined  05-13-2004

The docs have the answer
You can’t use an EE tag inside a user defined global variable.

User-defined global variables are not run through the template engine, so you cannot place EE Tags, PHP, or variables inside them.  Also note that Global Variables are one of the last things parsed in your Templates. This means that you cannot use a Global Variable as the value for an EE Tag parameter.

 Signature 

CreateSean - My journey to pro web designer
currently improving my CSS, XHTML, JQuery & photoshop kung fu skills
I am the poster formally known as The Linguist.

Profile
 
 
Posted: 31 July 2008 01:23 AM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6092
Joined  08-04-2002

Could be wrong but I don’t think you can embed one global within another.
You could instead use a template with the copyright text and the time global and embed that template. I’m pretty sure that would work.

Edit-Add: Sean had the definitive answer. The template idea would work though.

Profile
 
 
Posted: 31 July 2008 01:39 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  5
Joined  07-29-2008

Many thanks to Sean C. Smith and PXLated !

The next time I’ll be more careful.

Thanks.

Profile
 
 
Posted: 31 July 2008 02:52 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Avatar
Total Posts:  5
Joined  07-29-2008
PXLated - 31 July 2008 01:23 AM

Could be wrong but I don’t think you can embed one global within another.
You could instead use a template with the copyright text and the time global and embed that template. I’m pretty sure that would work.

Edit-Add: Sean had the definitive answer. The template idea would work though.

...Maybe I’m really stupid but ....

I’ve created a new Template named “Footer” with this code inside :

<p><span>copyright &copy; {current_time format="%Y"} codenic&middot;com | Tutti i diritti riservati | Powered by </span>
<
span><a href="http://www.expressionengine.com" title="Publish Your Universe !">Expression Engine</a> & </span>
<
span><a href="http://code.google.com/p/blueprintcss/" title="BluePrint CSS Framework">BluePrint</a> & </span>
<
span><a href="http://www.jquery.com" title="jQuery: The Write Less, Do More, JavaScript Library">jQuery</a></span></p>

then I tryed to embed this new template in my site/index template, like this:

<div id="footer">{embed="site/footer"}</div>

and the time global variable doesn’t work, infact the result is :
copyright © {current_time format=”%Y”} codenic·com | Tutti i diritti riservati | Powered by Expression Engine & BluePrint & jQuery

I don’t understand…..

Thanks.

Profile
 
 
Posted: 31 July 2008 02:57 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-23-2008

You got a link to your site? That should definitely work.

 Signature 

while(!(succeed=try()));

Profile
 
 
Posted: 31 July 2008 03:03 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Avatar
Total Posts:  5
Joined  07-29-2008

Yes but it’s “work in progress”, however the link is : www.codenic.com.
In the footer section it’s possible to see what I posted.

Many many Thanks.

Profile
 
 
Posted: 31 July 2008 03:10 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-23-2008

It’s all Greek to me. Well, Italian smile All kidding aside, your footer is empty, I am afraid.

 Signature 

while(!(succeed=try()));

Profile
 
 
Posted: 31 July 2008 03:20 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Avatar
Total Posts:  5
Joined  07-29-2008

Sorry Sorry Sorry red face but I changed the footer’s access permission so the my footer is empty.

Now, it’s ok.

Profile
 
 
Posted: 29 August 2008 06:58 AM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  602
Joined  11-07-2004

There’s definitely something goofy going on there because I have the following code at the very end of my footer and it works just fine

script executed in: {elapsed_time} seconds with a total of {total_queries} queries. Copyright &copy; {current_time format="%Y"}  {site_name}. All rights reserved

 Signature 

Member: ExpressionEngine Pro Network: ePlaces Network Services

ePlaces Network Services

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65086 Total Logged-in Users: 37
Total Topics: 82224 Total Anonymous Users: 17
Total Replies: 441922 Total Guests: 192
Total Posts: 524146    
Members ( View Memberlist )