Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

Trying to have a style sheet only used when the user is not on the home screen. This code in my head section should work, correct?

{if embed:loc != "home"}
<style> body {background:url(images/interface/header_bg_slice3.png) repeat-x,    
url(images/interface/texture_bg.png) top left, repeat;}</style>
{/if}   

here is the corresponding code I'm using in the page template:

{embed="embeds/html_header" page_title="About Us" loc="about-us"}

what am I missing?

share|improve this question
1  
Yes, that is correct, you are not missing anything. Is it not working for you when you inspect the source code of your page? –  Derek Hogue Dec 27 '12 at 23:09
    
This should be working. Have you tried {if "{embed:loc}" != "home"}? Does {embed:loc} output what you expect if you print the variable outside the conditional just to check? –  Kevin Cupp Dec 28 '12 at 15:56
add comment

3 Answers

up vote 4 down vote accepted

Another option would be to avoid using embedded styles and add a class to your body tag based on what page is loaded. Then you can adjust your body background in your stylesheet instead of the templates.

Like vfalconi said, you can often base this off the index not having a segment:

<body{if segment_1} class="subpage"{/if}>

Then in your stylesheet:

.subpage { your styles here... }
share|improve this answer
    
that works perfectly. thanks! –  hyphen81 Dec 28 '12 at 23:47
add comment

Have you tried:

{if segment_1}...{/if}

In most cases, if the user is on the site index, there wouldn't be a segment_1. Just seems a much more straight-forward approach to what you're trying to achieve (from what I can tell).

share|improve this answer
add comment

Similar to what Jim said but this would give a bit more flexibility:

{embed="embeds/_html_head" body_id="your-css-id" body_class="your-css-class"}

and then within that embed

<body id="{embed:body_id}" class="{embed:body_class}">

You can also achieve the same thing with Low Vars (less overhead too)

{exp:low_variables:single
var='lv_html_head'
preparse:body_id='home'
preparse:page_title='Home'
}

where lv_html_head is a textarea Low Variable containing what would be in your embed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.