1

I'm having an issue with a template pulling data onto a page when it loads. For example, I have 2 sites (a desktop and mobile version). I'm attempting to pull content from the desktop site pages onto the mobile sites page. So from one template group to another.

However, the problem I'm having is that the URL is being pulled correctly, BUT the content is from the most recent post. The only way I'm able to get more than the most recent post to display is if I set the limit to be greater than 1.

This is the main listing template:

    {if '{segment_3}' != ''}

    {embed="mobile__site/post"}

{if:else}

{embed="_embeds/_mobile_head" entry_id="{entry_id}" page_title="Blog {if segment_3 != 'category'}{exp:channel:category_heading channel='blog'}- {category_name}{/exp:channel:category_heading}{if:else}{exp:channel:month_links channel='blog'}- {month} {year}{/exp:channel:month_links}{/if}"}

                {exp:channel:entries channel="blog" dynamic="yes" orderby="date" sort="desc" limit="4" paginate="bottom"}
                        <h3><a href="{url_title_path='blog/post'}">{title}</a></h3>
                        {summary}
                        {if full_entry !=""}
                            <p>
                                <a href="{url_title_path='blog/post'}">Read More...</a>
                            </p>
                        {/if}

                        <div class="posted">
                            Posted by {author} on {entry_date format='%m/%d'} at {entry_date format='%h:%i %A'} in {categories}<a href="{path='blog'}">{category_name} </a> &#8226; {/categories}

                            <a href="{url_title_path='blog/post'}">Permalink</a>
                        </div>

                        {paginate}
                            Page {current_page} of {total_pages} pages {pagination_links}
                        {/paginate}
                    </div>
                {/exp:channel:entries}

            </div>

        </div>
    </div>
</div>
{embed="_embeds/_mobile_footer"}
{/if}

And this is the post template:

{exp:channel:entries channel="blog" dynamic="yes" disable="categories|member_data|pagination" limit="1"}
{embed="_embeds/_mobile_head"}


                        <h3>{title}</h3>
                        {!--{summary}--}
                        {full_entry}


                            <a href="{url_title_path='blog/post'}">Permalink</a>


                        </div>                  
                    </div>


                </div>
            </div>

    </div>
</div>
{embed="_embeds/_mobile_footer"}
{/exp:channel:entries}

EDIT: I make an exact copy of the desktop version in the "mobile" version of the template. It still loads incorrectly. I'm wondering if it's a plugin issue. When I attempted to visit the developers site, it looks like the last time they answered a question was 2012. Can anyone recommend a mobile site plugin that is currently being supported?

7
  • A few things: since your embed tag is outside of a channel:entries tag, so {entry_id} will always be blank. Furthermore, in the post template change dynamic="yes" to dynamic="no" and include url_title="{segment_x}" – Jelle Dijkstra Nov 16 '16 at 20:53
  • Thanks for that. I made those changes. Any idea as to why it won't allow me to pull the correct post in? – Matt Dowis Nov 17 '16 at 14:41
  • what plugin are you using? – Jelle Dijkstra Nov 17 '16 at 17:02
  • Also what version of EE? – Jelle Dijkstra Nov 17 '16 at 17:08
  • The plugin is called 'mobile'. And the EE version is v2.9.3 – Matt Dowis Nov 17 '16 at 18:24
0

EE doesn't care about your template groups. All content in the channels is available in whatever templte you want. Let's say your url is this: yoursite.com/blog The index template of the blog template group would have this in it:

{exp:channel:entries channel="blog" dynamic="no" orderby="date" sort="desc" limit="4" paginate="bottom"}
<h3><a href="{url_title_path='blog/post'}">{title}</a></h3>
    {summary}
    {if full_entry !=""}
         <p>
             <a href="{url_title_path='blog/post'}">Read More...</a>
         </p>
    {/if}
{paginate}
Page {current_page} of {total_pages} pages {pagination_links}
{/paginate}
{/exp:channel:entries}
{/if}

So this would be your blog/post template:

{exp:channel:entries channel="blog" dynamic="no" url_title="{segment_3}" disable="categories|member_data|pagination" limit="1"}
                        <h3>{title}</h3>
                        {full_entry}
{/exp:channel:entries}

First see if you get this to work before putting in addons and conditionals

7
  • With only the above code, the index template is working as it should. When I click on a post, the correct URL displays but there is no content on the page. – Matt Dowis Nov 17 '16 at 18:36
  • After further investigation, it appears that the desktop version is being pulled into the template rather than the "mobile-friendly" template that I'm asking it to. And there is JS that is preventing it from rendering on a mobile device. – Matt Dowis Nov 17 '16 at 19:21
  • Where I'm at now is back at square one. I don't understand why only the most recent post is being pulled no matter what link I click on. When I view source the links are correct. – Matt Dowis Nov 20 '16 at 0:28
  • It seems EE isn't told properly what entry to show. If you dan't have dynamic="no" in all your channel:entries tags, EE will try to guess what entry to load based on the url. Another thing that might be the case is that it's actually showing a 404. Do you have a 404 page set in your preferences? – Jelle Dijkstra Nov 21 '16 at 8:21
  • I double checked the dynamic property and it is set to "no". It looks like there isn't a 404 set. – Matt Dowis Nov 21 '16 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.