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.

Linking to article detail page

January 14, 2010 6:53pm

Subscribe [2]
  • #1 / Jan 14, 2010 6:53pm

    honey4d

    15 posts

    Hi.

    I’m struggling to get my news page working and wondered if anyone could offer some help.

    I can display the news articles but when you click ‘more’ (or on the headline) it doesn’t really work..

    http://www.emagregional.org.uk/national-news/Barnsley/

    The ‘more’ link uses “{title_permalink=national-news/view}” and the link on the headline uses “/national-news/view/{segment_2}/{url_title}”....I have done them differently just to test options.

    Segment_2 is required to show the region name in the header and relevant content on some of the other pages.

    Any pointers would be much appreciated.

    Jon

  • #2 / Jan 14, 2010 7:10pm

    Adam Dorsey

    1439 posts

    What does your weblog tags look like on thew single-entry page? Can you post the code?

    Have you thought of maybe using categories for the regions? This would simplify things a bit.

  • #3 / Jan 14, 2010 7:42pm

    honey4d

    15 posts

    Hello Adam

    This is the excerpt page (/national-news/)...

    {exp:weblog:entries weblog="national-campaign-news" orderby="date" limit="8" paginate="bottom" dynamic="off"}
    
    <h3><a href="/national-news/view/{segment_2}/{url_title}">{title}</a></h3>
    
    <p> </p>
    
    <p>{exp:md_eexcerpt if_exceeds="100" stop_after="100" <br />
    the_link="<a href='{title_permalink=national-news/view}'>MORE</a>"}<br />
    {news-body}<br />
    {/exp:md_eexcerpt}</p>
    
    <p>{paginate}<br />
    {if "{total_pages}" != 1}Page {current_page} of {total_pages} pages {pagination_links}{/if}<br />
    {/paginate} </p>
    
    <p> </p>
    
    <p>{/exp:weblog:entries}

    Here’s the code from the page that displays the whole article (/national-news/view/)...

    {exp:weblog:entries weblog="national-campaign-news" limit="1"}
    
    <h2>{title}</h2>
    <p>{if news-image != ''}<br />
    <div class="imagefloatright">/img/news/{news-image}<br />
    {if news-image-caption != ''}<br />
    {news-image-caption}</p>
    
    <p>{/if}<br />
    </div><br />
    {/if}</p>
    
    <p>{news-body}</p>
    
    <p>{/exp:weblog:entries}


    I didn’t use categories for the 80 regions as they needed to include several fields to hold region specific contact details, coordinates for the location on the homepage map, an image link, etc.

    Thanks
    Jon

  • #4 / Jan 14, 2010 7:56pm

    Adam Dorsey

    1439 posts

    Try adding url_title=”{segment_4}” to your weblog tag, like so:

    {exp:weblog:entries weblog="national-campaign-news" limit="1" url_title="{segment_4}"}
    
    <h2>{title}</h2>
    <p>{if news-image != ''}<br />
    <div class="imagefloatright">/img/news/{news-image}<br />
    {if news-image-caption != ''}<br />
    {news-image-caption}</p>
    
    <p>{/if}<br />
    </div><br />
    {/if}</p>
    
    <p>{news-body}</p>
    
    <p>{/exp:weblog:entries}

    This will tell EE to grab the url_title from that correct segment.

    Does this help?

  • #5 / Jan 14, 2010 8:07pm

    honey4d

    15 posts

  • #6 / Jan 14, 2010 8:12pm

    Adam Dorsey

    1439 posts

    What about:

    {exp:weblog:entries weblog="national-campaign-news" limit="1" url_title="{segment_4}" dynamic="off"}

    Does that work?

  • #7 / Jan 14, 2010 8:32pm

    honey4d

    15 posts

    Thank you Adam, that works.

    One problem though - the paginate links don’t work. Any suggestions?

  • #8 / Jan 14, 2010 9:36pm

    Adam Dorsey

    1439 posts

    Hmm- I could have sworn I replied to this already 😉 Must have been a browser issue.

    Your first weblog:entries tag has dynamic=“off” which will prevent pagination from working. Try removing that:

    {exp:weblog:entries weblog="national-campaign-news" orderby="date" limit="8" paginate="bottom"}
  • #9 / Jan 14, 2010 10:11pm

    honey4d

    15 posts

    When I remove dynamic=“off” no news is displayed!

    I guess this is because none of the national news is linked to a specific region.

  • #10 / Jan 14, 2010 10:14pm

    Adam Dorsey

    1439 posts

    Hmm… Well pagination will only work if that weblog is dynamic, (Being controlled by the url).

    Can you try disabling htaccess and then retesting?

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

ExpressionEngine News!

#eecms, #events, #releases