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.

Auto detect "p" segments?

January 04, 2012 8:01pm

Subscribe [2]
  • #1 / Jan 04, 2012 8:01pm

    benwellby

    17 posts

    Hello. Is there a way to auto detect the “p” segments of a given entry when using pagination?

    I have the below code in the footer of all pages, this displays three “quick links” to the blog. The blog section of the site doesn’t have detail pages, just a continuous feed with pagination. I’m looking to use anchor points on each article so that the page is loaded with the chosen article in view.

    Currently the link works until the pagination is used within the URI (p1, p2…), then the link breaks!

    {exp:channel:entries channel="blog" limit="3"}
    
     <h5><a href="http://{site_url}blog#{url_title}">{title}</a></h5>
    <p> <br />
     {exp:eehive_hacksaw words="15" allow="<p>" append="…"}<br />
     {article_body}<br />
     {/exp:eehive_hacksaw}<br />
    {/exp:channel:entries}


    Any advise would be really appreciated.

    Thanks

     

  • #2 / Jan 05, 2012 2:25am

    ahmad saad

    364 posts

    how you generate pagination links ,please post the code.

  • #3 / Jan 05, 2012 3:33am

    benwellby

    17 posts

    Of course, here you go…

    {paginate}
    {pagination_links}
    <ul class="paginate">
     <li class="page-count">{current_page} of {total_pages} pages</li>
        <li>{first_page}
                 <li><a href="http://{pagination_url}" class="page-first">« First</a></li>
         {/first_page}
         
         {previous_page}
                 <li><a href="http://{pagination_url}" class="page-previous">‹ Previous</a></li>
         {/previous_page}
         
         {page}
                 <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
         {/page}
         
         {next_page}
                 <li><a href="http://{pagination_url}" class="page-next">Next ›</a></li>
         {/next_page}
         
         {last_page}
                 <li><a href="http://{pagination_url}" class="page-last">Last »</a></li>
         {/last_page}</li>
    </ul>
    {/pagination_links}
    {/paginate}
  • #4 / Jan 05, 2012 7:56am

    ahmad saad

    364 posts

    if u tell me what actually happend footer code when used (p1, p2…) within the URI .

  • #5 / Jan 05, 2012 9:39am

    benwellby

    17 posts

    The three “quick links” URLs in the footer look like this:

    <h5><a href="http://{site_url}blog#{url_title}">{title}</a></h5>
    
    <p>Result: <a href="http://www.example.com/blog#article-title">http://www.example.com/blog#article-title</a>

    What I am after is something like this:

    <h5><a href="http://{site_url}blog/{url_p}#{url_title}">{title}</a></h5>
    
    <p>Result: <a href="http://www.example.com/blog/p1#article-title">http://www.example.com/blog/p1#article-title</a>

    Where “{url_p}” would automatically insert the entries “p” segment.

    Is this possible natively in EE or should I be looking at a plugin, Low Replace for example?

     

  • #6 / Jan 05, 2012 4:19pm

    Dan Decker

    7338 posts

    Hi benwellby,

    There isn’t a way to auto-detect this like you might expect, but those values would be available via segment variables. The only caveat there is that the segment variable would be different on pages that don’t use pagination. If your footer is only on pages that will be using pagination, you would use the {segment_2} variable.

    <h5><a href="http://{site_url}blog/{segment_2}#{url_title}">{title}</a></h5>

    If that gives you undesired results, you might look at using segment variables with some conditionals and Low Replace.

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

ExpressionEngine News!

#eecms, #events, #releases