Hi,
I’m just building my first site with EE after completing the Michael Boyink training for version 2.4 and have run into a problem that I would really appreciate some help with.
In summary it’s a fairly basic site and at the top of each page there’s an intro section and associated intro image. This will be the same for all pages except the home page where there are to be 3 images in line. Currently these are all contained in <li> elements within an un ordered list. This is just fine except that I need these images to be able to be changed within the CP.
I’m using a variable url_title=”{embed:the_url_title}” to determine if it’s the home page or not and then apply the required images solution depending using an {if} statement. The images for the n.on home pages are obtained from the articles in the misc_content channel
I’ve enclosed the code below for my embeded template page_intro… I’m sure I’m totally missing something here as a new boy and there’s a simple solution so your help really is appreciated.
Many thanks
Rob
<br />
<section id=“intro” class=“group” role=“complementary”><br />
<div class=“intro_text group”><br />
{exp:channel:entries channel="misc_content" limit="1" dynamic="no" disable="categories|member_data|pagination" url_title="{embed:the_url_title}”}<br />
<h1>{title}</h1><br />
{page_body}<br />
</div></p>
<p> <div class=“illustration group”></p>
<p> {if url_title =="web-sites-with-focus"}<br />
<ul class=“home”></p>
<p> <li><a href="#">{site_url}images/interface/sample1.png</a></li><br />
<li><a href="#">{site_url}images/interface/sample13.png</a></li><br />
<li class=“last”><a href="#">{site_url}images/interface/sample3.png</a></li><br />
</ul><br />
{if:else}</p>
<p> {intro_images}<br />
<br />
{/if}</p>
<p> {/exp:channel:entries}</p>
<p> </div><br />
<br />
</section><br />
Hi Rob - welcome to the EE community! Here’s hoping that I am only the first to give you a helping hand along your way as you learn the ins and outs of EE.
Ok, for starters, I have a couple of questions:
1) are you using separate template groups for your internal pages or do you have your whole site in one template group? Either way, when you’re on the “home” page (when you’re on the index template of the template group that you have set in your settings to be your “home” group) there is no first segment on the page. So when you’re on that home, you see only your domain.com and not your domain.com/template_group, for example. This can greatly simplify your approach in dynamically determining whether you are on the home page. On the home page, there is no first segment. Therefor you could use a simple conditional of:
{if segment_1 == ""}
you are on the home page
{/if}
Taking this approach, the condition is true even if you change your url title for your home page - and so then your template remains unchanged. With your conditional being hard coded to your url title, if your URL title were to change, your condition is no longer met.
2) the embed:value_here only works when you are pulling that value from another template, passing that value in the process. So it doesn’t apply here - which is probably why you’re not seeing the results you expect. To give you an example, let’s say i wanted to use an embed template to pass the title of an entry into an embedded meta tags template that i use in the <head></head> if the site. In my SOURCE template I would do something like this:
{exp:channel:entries channel="my_channel" limit="1" orderby="date" sort="desc" disable="categories|member_data|pagination" dynamic="no"}
{embed="my_embedded_template_group/dynamic_meta_template" the_entry_meta_title="{title}"}
{/exp:channel:entries}
Then in the template I embedded, which I named for demonstration purposes as “dynamic_meta_template”:
<title>{embed:the_entry_meta_title} | {site_name}</title>
So in the fashion that you’ve used it, the embed just doesn’t have any info to insert because it hasn’t been declared in another template prior to being brought into your usage.
3) I might also suggest, while the use of {site_url} is functional, it’s strictly speaking not necessary. As a global variable, you’re not likely taking a performance hit in EE rendering that in place within the template unless you have a massive number of images in the template, but you can achieve the same thing by using a relative path - so instead of “{site_url}/images/interface/photo1.jpg” you can use the simpler “/images/interface/photo1.jpg”
Anyway, i hope these ideas are useful to you. Having gotten yourself started with Boyink’s materials on trainee.com you’re well on your way. I was just relating to someone on Twitter yesterday that his “building a small business site” was my first hand-on experience with EE in late 2008. Been loving it ever since and trying top help out in the forums when i can because so many in the community kindly answered my questions when i got started with it.
Enjoy, and best of luck!