ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Weblog Entry Not Displaying with Certain Templates

September 25, 2007 3:56pm

Subscribe [2]
  • #1 / Sep 25, 2007 3:56pm

    sm9

    352 posts

    Hi there,

    I’ve setup a masthead_images weblog in order to display random images in the masthead of my site.

    This works fine on the home page, fine on the news page. Both of these pages use different templates and here’s the code from the news page template for info:

    {embed="includes/doctype"}
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    {embed="includes/metatags"}
    <title>{site_name} - {exp:weblog:entries weblog="news" limit="1" rdf="off"}{title}{/exp:weblog:entries}</title>
    </head>
    
    <body id="news">
    
    <div id="container">
    
    {embed="includes/header"}
    
    {embed="includes/main_nav"}
    
    {embed="includes/masthead"}
    
    {embed="includes/breadcrumb"}
    
    {embed="includes/sidebar_nav"}
    
    <div id="content_narrow">
    
    <h2>News</h2>
    
    <p>{exp:weblog:entries weblog="news"}</p><h3>{title}</h3>
    <p>{entry_date format="%d %F %Y"} by {author}<br />
    {summary}<br />
    {body}<br />
    {/exp:weblog:entries}</p>
    
    <p></div><!--end content--></p>
    
    <p>{embed="includes/footer"}</p>
    
    <p></body><br />
    </html>

    So far so good.  However, for some reason that is beyond me, the same masthead image doesn’t appear in the About and Services pages (both use the same template - text_page1), and doesn’t appear in the Contact page either (which uses it’s own template).

    Here’s the text_page1 template code:

    {embed="includes/doctype"}
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    {embed="includes/metatags"}
    <title>{site_name} - {exp:weblog:entries weblog="static_pages" limit="1" rdf="off"}{title}{/exp:weblog:entries}</title>
    </head>
    
    <body id="{exp:weblog:entries weblog="static_pages" limit="1" rdf="off"}{url_title}{/exp:weblog:entries}">
    
    <div id="container">
    
    {embed="includes/header"}
    
    {embed="includes/main_nav"}
    
    {embed="includes/masthead"}
    
    {embed="includes/breadcrumb"}
    
    {embed="includes/sidebar_nav"}
    
    <div id="content_narrow">
    
    {exp:weblog:entries weblog="static_pages" limit="1" rdf="off"}
        <h2>{title}</h2>
    <p>    {if image <> NULL}{site_url}/images/graphics/{image}{/if}<br />
        {body}<br />
    {/exp:weblog:entries}</p>
    
    <p></div><!--end content_narrow--></p>
    
    <p>{embed="includes/footer"}</p>
    
    <p></div><!--end container--></p>
    
    <p></body><br />
    </html>

    Any ideas what’s happening here?  When viewing the source code, it’s clear that the image code isn’t generating at all. But I have no idea why if it works on other templates. It seems bizarre and I can’t explain it at all.

    Thanks for any help with this,

    Ste

  • #2 / Sep 25, 2007 4:03pm

    PXLated

    1800 posts

    Really can’t tell from your code as you are using embeds…probably need to see the code that is actually calling the masthead_images weblog.
    My guess without seing it is you need to add dynamic=“off” to the weblog tag.

  • #3 / Sep 25, 2007 4:09pm

    Lisa Wess

    20502 posts

    I’m with PXLated - looks like a classic case of needing to turn dynamic off. =)

  • #4 / Sep 25, 2007 4:23pm

    sm9

    352 posts

    Thanks PXLated and Lisa, that was the issue!

    For completeness, here’s the code with dynamic=“off” added:

    <div id="masthead">
    
    {exp:weblog:entries weblog="masthead_images" limit="1" rdf="off" orderby="random" dynamic="off"}
    <a href="http://{site_url}gallery/">{site_url}/images/masthead/{masthead_image}.jpg</a>
    {/exp:weblog:entries}
    
    {exp:weblog:entries weblog="static_pages" limit="1" rdf="off" entry_id="12"}
    <h1>{summary}</h1>
    {/exp:weblog:entries}
    
    </div><!--end masthead-->

    I’ve just read the userguide description of this parameter but don’t really understand why this is needed for the about and services pages to work, but not needed for the news page to work (all have the same URL structure of {site_url)/segment_1/

    Anyway, it’s working now, thanks again!

    Ste

  • #5 / Sep 25, 2007 4:36pm

    Lisa Wess

    20502 posts

    I’m not quite sure about your URL structure - are those Pages you’re using, or just weblog entries?  You say they’re just templates, but they’re in segment_1; segment_1 should be the template_group.  Without knowing more about what you’ve done, it’s hard to explain what might be happening.

  • #6 / Sep 25, 2007 4:45pm

    PXLated

    1800 posts

    don’t really understand why this is needed

    The URLs may have the same structure… site/templateGroup/template/segment3/etc. but they don’t contain the same information. So, in some cases the info may be ok and not interfere with the embedded template and its weblog tag but in other cases it may. Dynamic=“off” tells EE to ignore it all. Generally you only want EE to pay attention for your main content and ignore it all for headers, footers, and sidebar content.

  • #7 / Sep 25, 2007 4:47pm

    sm9

    352 posts

    Sorry, I probably muddied the water by mentioning segment_1.  I’m just using the Pages module for those text_template1 based pages. When I mentioned segment_1 (note there are not segment tags used to make the URLs), I was just trying to use an analogy by saying that the URL was in the same format, i.e. mywebsite.com/blue/ and mywebsite.com/red/, as opposed to mywebsite.com/colour/blue/, if that makes sense.

    Anyway, it’s working now so that’s the main thing.

    Ste

  • #8 / Sep 25, 2007 4:50pm

    Lisa Wess

    20502 posts

    Well those are still segments, even if you’re not using {segment_1}.  Glad you got it working =)

    And thank you, PXLated, for the great explanation. =)

  • #9 / Sep 25, 2007 4:55pm

    sm9

    352 posts

    Thanks Lisa, and thanks too PXLated for the explanation - I missed that when I posted above as I must have hit reply just before you posted.

    Thanks,

    Ste

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases