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.

Changing page title based on current entry with pagination

May 17, 2012 2:32pm

Subscribe [2]
  • #1 / May 17, 2012 2:32pm

    Magner Sanborn

    3 posts

    We have a site that pulls news entries into a page, displaying one at a time with pagination at the top. The page doesn’t refresh when the next and prev buttons are clicked, so does anyone have an idea how I can still manage to change the page title depending on the currently displayed article? Here is the pagination code I am using:

    {paginate}
     {if {total_pages} > 1}
             {if previous_page}
                 <a href="http://{auto_path}">< previous   | </a>
             {/if}
             {if next_page}
                 <a href="http://{auto_path}">  next ></a>
             {/if}
         {/if}
    {/paginate}

    Here is the title code I was trying to use, just to see if it was even possible:

    {exp:channel:entries channel="{channel}" limit="1"}
    <title>{if segment_3}{title} | {section} | {site_name}{if:else} {section} | {site_name}{/if}</title>
    {/exp:channel:entries}

    Thank you in advance for any suggestions!

  • #2 / May 22, 2012 12:12pm

    ChiefAlchemist

    913 posts

    No page refresh?

    Off the top of my head, then I think you’re gonna have to do the title change with javascript / jquery, etc.

    Also, how are you able to do the EE paging without refreshing the page? My experience has been that the EE paging always refreshes, yes?

  • #3 / May 22, 2012 12:18pm

    Magner Sanborn

    3 posts

    I had tried changing the page title based on the title of the article that was current on the page, but it didn’t work when changing the featured article with pagination (it would keep the article title from the first article only…which makes me think maybe the page wasn’t refreshing), so I ended up changing the pagination a bit. I did try the jQuery method as well, but it’s a bit harder to do it that way with dynamic content.

    Thank you!

  • #4 / May 22, 2012 1:39pm

    ChiefAlchemist

    913 posts

    but it didn’t work when changing the featured article with pagination (it would keep the article title from the first article only…which makes me think maybe the page wasn’t refreshing),

    Well, the loop for your title doesn’t know that you’re paging and therefore will default (?) to whatever makes sense.

    The jquery could have/should have been as simple as looking for an id and taking the value within those div tags, or something similar.

    So you’re sorted then, yes?

  • #5 / May 22, 2012 2:03pm

    Magner Sanborn

    3 posts

    I am indeed, thank you!

  • #6 / May 22, 2012 2:34pm

    ChiefAlchemist

    913 posts

    btw, I have a powerful but lite-weight jquery plugin for paging lists. I don’t think it would apply here but I figured I’d mention it.

    I’m working on a free-standing website for it but that’s still TBD. If you’re interested, just PM me.

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

ExpressionEngine News!

#eecms, #events, #releases