How to use global variables to create CSS file links?
Posted: 09 May 2008 01:45 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  34
Joined  03-26-2008

I noted that the documentation refers to using a global variable for creating a CSS file link but having looked at the set up for the global variable its not apparent to me how this is accomplished.

Can anyone point me in the right direction for instructions on this and in general on creating links to CSS files.
I’ve searched in the knowledge base and wiki but can’t find anything that seems to address the first question.

This is for an evaluation version so my files are on the EE server.

Thanks.

Profile
 
 
Posted: 09 May 2008 08:33 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  374
Joined  02-26-2008

I think this page in the User Guide will be of assistance to you here.  Let us know if this doesn’t fill in the gaps for you.

Profile
 
 
Posted: 10 May 2008 12:39 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  34
Joined  03-26-2008

Thanks for yr response.

I did look at that page but I didn’t see how to use the global variables set up.

Do you paste the full link into the variable field and then give it a short name?

How is it then evoked as a link in the template?

Thx.

Profile
 
 
Posted: 10 May 2008 12:55 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  2064
Joined  05-07-2007

If you are looking to link to a css file in a template group called “foo” and you have named your css template ‘bar’, you would call it in the head of an html template as follows:

{stylesheet=foo/bar}

Per Ingmar’s contribution at the bottom of the docs, “{site_url}” is the only variable that is parsed regardless.

It’s set up when you install expression engine.

eg, if your site is “http://www.example.com”  and you want to link to:  http://www.example.com/images/foo.png you could do:

#my_div {background-image:url({site_url}images/foo.png); }

and on output, it prints:

#my_div {background-image:url(http://www.example.com/images/foo.png); }

Does this make sense?

-greg

 Signature 
Profile
MSG
 
 
Posted: 10 May 2008 09:09 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  34
Joined  03-26-2008

Thanks for your response.

Greg A. - 10 May 2008 12:55 AM

If you are looking to link to a css file in a template group called “foo” and you have named your css template ‘bar’, you would call it in the head of an html template as follows:

{stylesheet=foo/bar}

I think I have the conventional method of linking to a css file working correctly. What I’m trying to do is to understand how you would define this link as a global variable and then how you would replace the conventional link in the html header with the global variable.

So if my existing link is

<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=bn_trial/article_page_header}" />

I’m assuming that you can create a global variable that represents this link and use it in different templates.
My question is does the global variable represent just the information within {} or is it the whole link <....> or should it be something else?

Then my other question is how is this created?
There are two fields in the setup menu, a name variable and the variable content. Do you just pick a name for the variable, that meets the rules of course, and then paste the link or file reference into the field? For instance:

Variable name=foo
Variable content= <link rel=“stylesheet” type=“text/css” media=“all” href=”{stylesheet=bn_trial/article_page_header}” />

Or

Variable name=foo
Variable content= stylesheet=bn_trial/article_page_header

And my third related question was, how do you then call up the global variable in the header so that the CSS file is read?

Do you in some way just use “foo”

Or is it something like

<link rel=“stylesheet” type=“text/css” media=“all” href=”{foo}” />

 

Per Ingmar’s contribution at the bottom of the docs, “{site_url}” is the only variable that is parsed regardless.

.......
Does this make sense?

-greg

Thanks

Profile
 
 
Posted: 10 May 2008 09:35 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  34
Joined  03-26-2008

I think I finally understood the process so please ignore the questions above.

Thanks.

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: 65087 Total Logged-in Users: 35
Total Topics: 82229 Total Anonymous Users: 21
Total Replies: 441928 Total Guests: 220
Total Posts: 524157    
Members ( View Memberlist )