When we place the code {if "{embed:page}” == “home”} in the header of our site, values are returned, but if we place the same code in the footer, we get no returned values. Does anyone know why?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
October 01, 2010 10:53am
Subscribe [5]#1 / Oct 01, 2010 10:53am
When we place the code {if "{embed:page}” == “home”} in the header of our site, values are returned, but if we place the same code in the footer, we get no returned values. Does anyone know why?
#2 / Oct 01, 2010 7:21pm
Hi MLWack, what about:
{if embed:page == "home"}Does that work?
#3 / Oct 01, 2010 7:26pm
We’ll try that.
#4 / Oct 03, 2010 2:19pm
Hi MLWack,
Okay, please let us know how you get on.
Cheers
Greg
#5 / Oct 04, 2010 11:16am
Nope, it didn’t work. We’ve tried all three below:
{if embed:page == "home"}
Page -> Home
{/if}
----------------------------------
{if "{embed:page}" == "home"}
Page -> Home
{/if}
----------------------------
{if "embed:page" == "home"}
Page -> Home
{/if}Anyone have any other ideas of what we might be doing wrong?
#6 / Oct 04, 2010 4:49pm
Can you show us a little more of your code and setup? What is it, exactly, that you’re trying to achieve? Also, what version and build of EE are you using?
#7 / Oct 04, 2010 5:04pm
We are currently on EE 1.6.8 Build: 20100121 running over Apache Version Apache/2.2.3 on Linux (Red Hat).
We are trying to move Javascript from the header to the footer. The actual code is:
#8 / Oct 04, 2010 5:12pm
And this is within an embedded and the “page” variable is being passed down from the calling template, as it were?
#9 / Oct 04, 2010 5:16pm
Yes, sorry. This is the _header.php file that is included in all templates. We are trying to move it to _footer.php which is also included in all templates, but is the last file to be included.
The goal is to postpone the load of the javascript pages to the end so that other items can begin to render on the page.
#10 / Oct 04, 2010 5:24pm
Where and how are you calling this embed? Can you show us the relevant parts of the parent template?
#11 / Oct 04, 2010 5:27pm
Here is the code from one of our main templates. It’s for our generic landing page:
{exp:weblog:entries weblog="page" disable="categories|category_fields|member_data|pagination"}
{!-- HEADER --}
{embed="embeds/_header" title="{title}" description="{page_meta_description}" keywords="{page_meta_keywords}"}
<div id="innerwrap">
{!-- LEFT COLUMN --}
<div id="sidenav">
{embed="embeds/_local_navigation"}
</div>
{!-- CENTER COLUMN --}
<div id="content" class="narrow">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
<h1>{title}</h1>
{exp:content_components:entries group="main" entry_id="{entry_id}"}
{page_body}
</div>
{!-- RIGHT COLUMN --}
<div id="right" class="fornarrow">
<div id="rightwrap">
{!-- QUICK LINKS --}
{embed="embeds/_quick_links"}
{!-- COMPONENT --}
{exp:content_components:entries group="right" entry_id="{entry_id}"}
</div><!--close rightwrap-->
</div><!--close right-->
<div id="base"></div>
</div><!--close innerwrap-->
{!-- FOOTER --}
{embed="embeds/_footer"}
{/exp:weblog:entries}#12 / Oct 04, 2010 5:28pm
This is the code from our homepage:
<?php
// absolute URLs - DG
define('BASE','http://'.$_SERVER['HTTP_HOST']);
?>
{exp:weblog:entries weblog="homepage_content" disable="categories|category_fields|member_data|pagination"}
{!-- HEADER --}
{embed="embeds/_header" page="home"}
<?php
global $PREFS;
$ses_user_id = $_SESSION['mris_session']['user_id'];
$ses_nick_name = $_SESSION['mris_session']['nick_name'];
if ($ses_user_id != -1) {?>
<div class="welcome">
<?php echo "Welcome, $ses_nick_name!" ?></div>
<?php } ?>
{!-- SLIDES --}
<div class="cf_wrapper">
<div class="cf_element" id="cf1">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_1}
</div>
<div class="cf_element" id="cf2">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_2}
</div>
<div class="cf_element" id="cf3">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_3}
</div>
<div class="cf_element" id="cf4">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_4}
</div>
<div class="cf_element" id="cf5">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_5}
</div>
<div class="cf_element" id="cf6">
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}
{homepage_img_content_6}
</div>
</div>
{!-- SLIDES JS--}
[removed]
var cf = new Crossfader( new Array('cf1','cf2','cf3', 'cf4', 'cf5', 'cf6'), 1000, 10000 );
[removed]
{!-- QUICKLINKS --}
{embed="embeds/_quick_links"}
{!-- WHY MRIS --}
<div id="why">
<h3>{homepage_body_header} </h3>
<p> {homepage_body_content}<br />
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}<br />
</div></p>
<p>{!-- CLOSE HOME PAGE CONTENT ENTRY --}<br />
{/exp:weblog:entries}<br />
<br />
{!-- MEDIA TABS --}<br />
<div id="media"><br />
</p><h3>
{!-- TABS --}
<div id="gallery">
<div class="on" title="News"><span>News</span></div>
<div class="off" title="Blog"><span>Blog</span></div>
<div class="off" title="Tweets"><span>Tweets</span></div>
</div>
</h3>
<p> {!-- NEWS --}<br />
<div id="News" class="show"><br />
<ul><br />
{exp:weblog:entries weblog="news" dynamic="off" disable="categories|category_fields|member_data|pagination" limit="2"}<br />
<li><br />
{exp:edit_this:entry entry_id="{entry_id}" weblog_id="{weblog_id}" author_id="{author_id}"}<br />
<a href="http://{page_url}" title="{title}">{title} - {entry_date format="%m/%d/%y"}</a><br />
</li><br />
{/exp:weblog:entries}<br />
</ul><br />
<a href="http://{homepage}about-mris/news/" title="Read All News">Read all news</a><br />
</div></p>
<p> {!-- BLOG --}<br />
<div id="Blog" class="hide"><br />
<ul><br />
{exp:magpie url="http://feeds.feedburner.com/MRISResource?format=xml" limit="3" refresh="120"}<br />
{items}<br />
<li><a href="http://{link}" title="{title}" target="_blank" rel="noopener">{title}</a></li><br />
{/items}<br />
{/exp:magpie}<br />
</ul><br />
<a href="http://www.mrisblog.com" title="Go to our blog" target="_blank" rel="noopener">Go to our blog</a><br />
</div><br />
<br />
{!-- TWEETS --}<br />
<div id="Tweets" class="hide"><br />
<ul><br />
{exp:twitter_timeline screen_name="mris_real_news" limit="2" create_links="user_mentions|hashtags|urls"}<br />
<li>{text} - {status_relative_date}</li><br />
{/exp:twitter_timeline}<br />
</ul><br />
<a href="http://www.twitter.com/mris_real_news" title="View our Twitter page" target="_blank" rel="noopener">View our Twitter page</a><br />
</div><br />
<br />
</div><!--close media--></p>
<p>{!-- FOOTER --}<br />
{embed="embeds/_footer"}#13 / Oct 04, 2010 5:30pm
Here is the full code for the _head file:
#14 / Oct 04, 2010 5:30pm
And finally the _footer file:
#15 / Oct 04, 2010 5:46pm
There’s the issue:
{embed="embeds/_header" page="home"}vs.
{embed="embeds/_footer"}
You need to add page= to your embed for the footer as well.