Incorrect Templates Loading

Justin Ferrell's Avatar

Justin Ferrell

09 Jan, 2013 01:06 PM

When we try to use the plugin on template groups with more than one template (in this case, index and .detail), it always defaults to index and displays the wrong content. The issue that we've found is in the redirection within the plugin. We use the presence of segment 2 to determine whether or not a page is a detail page or a listing page. Since the plugin always redirects to template_name/index, we always see a listing page regardless of the URL.

Our logic looks like this.

  {!-- Detail page --}
  {if segment_2 != 'index'}
  {embed="{template_group}/.detail"
  template_group="{template_group}"
  channel="{channel}"
  category_group="{category_group}"
  }
  {/if}
  
  
   {!-- Full listing page --}
  {if segment_2 == 'index'}
  {embed="{template_group}/.list"
  template_group="{template_group}"
  channel="{channel}"
  category_group="{category_group}"
  }
  {/if}

The plugin functions perfectly well in every other template group, but it seems to get hung up here.

The example structure of this category is like this: somewebsite.com/eat/rendezvous-lodge
When I output the URL segments of that page, I get segment 1 as mobile__eat, segment 2 as index and segment 3 as blank, so the content never displays properly.

Thanks in advance! I love your plugin and look forward to recommending it to everyone.

  1. Support Staff 1 Posted by Wouter Vervloet on 10 Jan, 2013 10:39 PM

    Wouter Vervloet's Avatar

    Hi Justin,

    I believe it has something to do with the {template_group} variable you're using. Are you using some add-on that adds that variable or have I missed something that has been added in the latest version of EE? I believe that the {template_group} variable isn't the same as {segment_1}.

    May I ask which version of EE you're using?

    – Wouter

  2. 2 Posted by Justin on 10 Jan, 2013 11:17 PM

    Justin's Avatar

    We set those variables at the top of the template like this

    {!-- Preloads
    =====================================================================
    Use these variables to configure the content from ExpressionEngine
    for this site. --}
    {preload_replace:meta_keywords=""}
    {preload_replace:meta_description=""}
    {preload_replace:channel="eat"}
    {preload_replace:template_group="eat"}
    {preload_replace:disable="category_fields|member_data|pagination"}
    {preload_replace:taxonomy_tree="3"}
    {preload_replace:taxonomy_node="4"}
    

    We're currently running 2.4.0

    Thanks again!

  3. Support Staff 3 Posted by Wouter Vervloet on 10 Jan, 2013 11:33 PM

    Wouter Vervloet's Avatar

    Ah, I think I see what is going on here...

    Mobile can only alter the topmost template that is being loaded (in this case 'eat/index'). Templates that are embedded can't be altered by any addon (not yet at least).

    You will have to set the {template_group} variable to mobile__eat to embed the right template.

    – Wouter

  4. 4 Posted by Justin Ferrell on 10 Jan, 2013 11:46 PM

    Justin Ferrell's Avatar

    We will have to test to make sure that we can do it and keep the
    correct content in place.

    Justin Ferrell
    Mobile Developer @ Digital Relativity
    [email blocked]
    @mobile_justin
    304-719-7410

    Sent from my iPhone

  5. 5 Posted by Justin Ferrell on 11 Jan, 2013 02:26 PM

    Justin Ferrell's Avatar

    Is there no conceivable way to make it work? I ask because we didn't build the entire site we're looking at. The agency that made the desktop site wasn't able to do mobile (no idea why) so we're just adding the mobile version to an existing site. Trying to avoid having to alter the desktop site and content structure if at all possible.

  6. Support Staff 6 Posted by Wouter Vervloet on 11 Jan, 2013 03:11 PM

    Wouter Vervloet's Avatar

    What is the exact template group this template is a part of?

    – Wouter

  7. 7 Posted by Justin Ferrell on 11 Jan, 2013 03:12 PM

    Justin Ferrell's Avatar

    This template is in mobile__eat, and we want it to mirror the content
    and URL of the eat group.

    Justin Ferrell
    Mobile Developer @ Digital Relativity
    [email blocked]
    @mobile_justin
    304-719-7410

    Sent from my iPhone

  8. Support Staff 8 Posted by Wouter Vervloet on 11 Jan, 2013 03:26 PM

    Wouter Vervloet's Avatar

    Not sure if you have this already, but do you have the {template_group} variable set to 'mobile__eat'?

    – Wouter

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

11 May, 2020 02:18 PM
16 Apr, 2020 06:39 AM
04 Apr, 2020 06:12 PM
30 Mar, 2020 07:50 PM
24 Mar, 2020 05:10 PM