When moving from one page to another [current-page:page-number] is not updated unless the cache is manually flushed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marikomay’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.x-dev

Same problem using 7.x-1.0-alpha5+1-dev. [current-page:page-number] token does not update unless the cache is manually flushed. I am using Views 3 to override taxonomy term pages.

marikomay’s picture

In case this is relevant, I am using the Omega theme.

jarrodirwin’s picture

Status: Active » Needs review
FileSize
484 bytes

I am having the same issue. I have a taxonomy term index page which is built via an attached view. I am setting the pagination number in the page title manually using hook_metatag_metatags_view_alter. This works the first time after clearing cache however then it's cached.

The problem is that the caching CID does not take into consideration the page number you are on.

Attached is a simple patch to add the page number which fixes this.

jarrodirwin’s picture

Last patch was giving notices when not on a paginated page. Added a check for the $_GET['page'] variable.

marcelovani’s picture

Adding a patch for the current DEV version

couturier’s picture

Title: Cached [current-page:page-number] » Using [current-page:page-number] to avoid duplicate page titles in Views
Category: bug » feature
Status: Needs review » Reviewed & tested by the community
FileSize
29.62 KB

Marcelovani's patch shows the correct page number for each page of a View. Please excuse my inexperience, but in order to get page numbers, all I knew how to do was to configure the Meta Tags Global Title to look like this:

[current-page:title] | [site:name] | [current-page:page-number]

Comment #4 is still relevant, that titles are "giving notices when not on a paginated page." But, this is okay with me. To explain, if I have any View, whether it is only one page or paginated, the title of the first page will always look like this:

<title>Name of the View Page | Name of my site | 1</title>

Pages that are not created through Views do not show any page number at all with marcelovani's patch. [Update: I just noticed that taxonomy term pages do show numbers.]

I have closed as a duplicate this issue that is related and turned this issue into a feature request since many people are interested in how to do this in Meta Tags. Here is the reason, from the previous issue:

This is important for SEO because Google and Bing both flag this as an SEO flaw, duplicate page titles a paginated View. The Page Title module already provides the capability of fixing this, but it would be great to have it in Meta Tags since Page Title functionality is being integrated with Meta Tags.

Now, all we need is a way for newbies like me to know how to add the page number to Views page titles. Can we insert some documentation text into the Meta Tags UI? For example:

TYPE	
Global
Title:	[current-page:title] | [site:name]
Generator:	Drupal 7 (http://drupal.org)
Open Graph title:	[current-page:title]
Open Graph type:	article
Open Graph URL:	[current-page:url]
Open Graph site name:	[site:name]

+ To show page numbers for every page created in Views, including for paginated Views, override the Title and add "| [current-page:page-number]" to the settings.

Or, it would be extra nice if we could configure this with it's own UI setting, just like Page Title does. Attached is a screenshot of this feature in Page Titles. This one feature is really the last major feature that people are saying Page Title does that Meta Tags does not (titles for comment nodes might be related, also). It would be great if everyone could make the final switch to Meta Tags so the maintenance energy can go into this one module for the future.

couturier’s picture

I just updated my previous comment to note that taxonomy term pages are also showing a 1 when [current-page:page-number] is added to the Global title. However, there is a related issue underway to fix the problem that taxonomy term pages cannot be customized apart from inheriting the Global settings, at Support taxonomy term pages until taxonomy supports hook_entity_view().

couturier’s picture

Title: Using [current-page:page-number] to avoid duplicate page titles in Views » Cache clearing for [current-page:page-number] to avoid duplicate page titles in Views and taxonomy term pages
Category: feature » bug

I'm moving this back to bug report because two other bugs have just been fixed that also relate to taxonomy term pages (see this issue), and I know people want this caching fix committed even if the additional UI documentation I requested is not yet implemented.

Really, all it would take to help a lot of users right away is to add a line of documentation in the UI (probably under Global), as mentioned in #6, to say something like For SEO purposes, to avoid duplicate titles for View and taxonomy term pages with pagination, override the Title and add [current-page:page-number] to the settings.

hass’s picture

I do not like to add the page number to every page. I'd like to have it only added if required.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks jarrodirwin, marcelovani and everyone for testing!

DamienMcKenna’s picture

DamienMcKenna’s picture

Removed the tag.

DamienMcKenna’s picture

FYI a new hook was added to let the cache bits be altered before processing, which might help some developers work with custom pagers, etc: #1568164: Configuration of available tags to use / preventing caching

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

Last night saw the release of 7.x-1.0-beta1, so I'm closing all these "fixed" issues in the interest of tidying up the issue queue. Thank you all for your help getting us to this point!

couturier’s picture

I just tried the new 7.x-1.0-beta1 release, and I still cannot get the [current-page:page-number] token to show up on paginated Views. The token will return a number "1" on regular nodes, though. It's strange, because it was working on paginated Views earlier.

I just tried downgrading back to the version I thought it was working on (Meta Tags version = "7.x-1.0-alpha8+10-dev" with marcelovani's patch from #5) and I couldn't get the token to show back up. I'm thinking it must be some interference with another module, maybe Tokens, that has affected this since my post in #6 where [current-page:page-number] was working on paginated Views.

We are waiting on a new token, [metatag:pager] to replace it, so that should probably solve this (and we should probably take out [current-page:page-number] from the list of available tokens if it continues to not work). Follow that feature request here: Add a customizable pager token to extend the normal Token pager.