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.

home/index page embed problem

May 26, 2011 6:34pm

Subscribe [5]
  • #1 / May 26, 2011 6:34pm

    ll23

    7 posts

    My boss is adamant about having ad landing page urls not involve “subdirectories” (er, extra segments in the EE way. To accomplish this I simply have the index of the homepage template group embed a homepage template if there’s no second segment and embed an ad landing page if there is a second segment.

    The problem is, the landing page only ever shows the last entry. Require_entry throws it into the no_results loop. However, if I use this exact same method on a non-default template group it works as expected.

    Can someone explain what is going on here? Here’s my site’s index page code (main is my default template group):

    {if segment_1 == ''}{embed='main/homepage'}{if:else}{embed='main/landingpage'}{/if}

    landingpage:

    {exp:channel:entries channel="landing" limit="1" status="open"}
         {embed="includes/header" bodyclass="layoutB landingpage"}
        {if no_results}{redirect=''}{/if}
        <div id="main" role="main">
            <h1>{title}</h1>
            {other_stuff}
        </div>
        {embed="includes/footer"}    
    {/exp:channel:entries}

    To recap, my problem is that given the following “landing” entries (url_titles):
    http://www.site.com - shows homepage
    http://www.site.com/campaign04 - shows the “landing” channel entry with the url_title of campaing04
    http://www.site.com/campaign03 - still shows the “landing” channel entry with the url_title of campaing04
    http://www.site.com/foo - shows the “landing” channel entry with the url_title of campaing04


    (campaing04 is the latest landing entry that has an open status.)

    Note if I use the exact same templates in a non default template group it works as expected:
    http://www.site.com/test/ - shows homepage
    http://www.site.com/test/campaign04 - shows “landing” channel entry campaing04
    http://www.site.com/test/campaign03 - shows “landing” channel entry campaing03
    http://www.site.com/test/foo - shows “landing” channel entry foo

  • #2 / May 27, 2011 12:42am

    Cheif

    626 posts

    Try adding url_title=”{segment_1}”. I expect that the include cannot identify the URL properly as segment_1 is generally for the template group *shrugs*

    {exp:channel:entries channel="landing" limit="1" status="open" url_title="{segment_1}"}
  • #3 / May 27, 2011 6:19am

    John Henry Donovan

    12339 posts

    ll23,

    Along with what Cheif says. Because you have basically rolled your own URL where the url_title is now at segment_1 you have cut of the dynamic URL feature of EE. Which is fine by the way but you need to make allowances now for this and feed through values for certain parameters

    {if segment_1 == ''}
    {embed='main/homepage'}
    {if:else}
    {embed='main/landingpage' seg="{segment_1}"}
    {/if}
    {exp:channel:entries channel="landing" limit="1" status="open" url_title="{embed:seg}"}

    Does that help?

  • #4 / May 27, 2011 1:25pm

    ll23

    7 posts

    Yes, I just needed to add url_title=”{segment_1}”. It wasn’t even necessary to pass an embed parameter. Thanks!

  • #5 / May 27, 2011 1:51pm

    Sue Crocker

    26054 posts

    Glad you were able to figure out what the problem was. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases