Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add a new token for inserting a pager, e.g. " | Page %page" which would become e.g. " | Page 5". Provide a settings page for customizing it.
Original request:
As posted in http://drupal.org/node/1337750#comment-6529578 (screenshot) we need a pager suffix that is only appended, if a pager is shown. The workaround in #1337750: Cache clearing for [current-page:page-number] to avoid duplicate page titles in Views and taxonomy term pages is not really good as it always show a pipe and show a pager number where no pager is shown as documented over there.
This feature seems to be the last to get rid of Page Title module that also collide with metatags, so we may be able to take over the code from there.
Comment | File | Size | Author |
---|---|---|---|
#40 | metatag-n1809652-40.patch | 5.76 KB | DamienMcKenna |
Comments
Comment #1
couturier CreditAttribution: couturier commentedComment from DamienMcKenna at an issue closed as a duplicate of this, Field to control suffix for use on page title fields:
Comment #2
marcelovaniI think its not a good idea to add it as a suffix for the title, because not everyone will want to have it at the end, for instance we use this configuration and it works well with the pagination
We use tokens, so that you can put them anywhere in the title.
Also, we use smart paging module to add pagination for nodes: http://ftp.drupal.org/files/projects/smart_paging-7.x-1.x-dev.tar.gz
The link above is for the latest version which features my patch that adds a token for pagination on nodes http://drupal.org/node/1776804
This module is good, because it removes the ?page= from the URL and adds /page/1/0 which is move SEO friendly
Another important bit is that tokens didn't work on every page, and I had to add this patch on http://drupal.org/node/224262#comment-6443384
Can you please try to use the smart paging module from the link above, without applying any patch and apply the patch above for tokens module, with the following metatags configuration:
Global
- Page Title: [current-page:title] | [current-page:page-number] | [site:name]
Global: Front page
- Page Title: [site:name] | [current-page:page-number] | [site:slogan]
Content
- Page Title: [node:title] | [smart-paging:page-number] | [site:name]
Taxonomy Term
- Page Title: [term:name] | [current-page:page-number] | [site:name]
Please let me know how it works for you
We have about 15 sites running on this configuration, for example:
Frontpage: http://www.theweek.co.uk/home/page/1/0
Taxonomy list: http://www.theweek.co.uk/news-opinion/page/2/0
Content: http://www.autoexpress.co.uk/driver-power/page/0/1
Comment #3
hass CreditAttribution: hass commentedThis does not work. Pager suffix is only added if a pager is shown and not always. You are also free to keep the field empty.
Comment #4
marcelovaniThe tokens use $_GET['page']. If you do not with to display page 1, it can be stripped off on template.php, or you can patch the modules to change the token.
Did you click on the website examples I provided?
Comment #5
couturier CreditAttribution: couturier commentedJust like marcelovani said, when using the Smart Paging module, before install my URL said:
http://fashionbelle.biz/modest-clothing-reviews/swimsuits?page=3
After following instructions in #2, the same URL reads:
http://fashionbelle.biz/modest-clothing-reviews/swimsuits/page/4/0
However, even with the Tokens module patch, I am not getting page numbers on paginated Views in the TITLE when following all instructions in #2.
Funny, because page numbers for paginated Views in the
<title>
was working for me a couple of weeks ago. I upgraded to the newest Meta Tags dev version today that has all the latest patches, and now page numbers in the title have disappeared even with tokens asking for them in the settings.Comment #6
hass CreditAttribution: hass commentedI do understand you token strings. But we do not want to strip anything anywhere on theme level. The module need to handle this and should only append the pager token value if a pager exists.
Maybe you should give page title a try to see how this works to understand what we expect.
Comment #7
couturier CreditAttribution: couturier commentedReply to #4 - Huge sites, marcelovani! They look amazing. Yes, I can see you are showing page numbers in your titles. I must be doing something wrong. I'll keep looking at this.
Comment #8
marcelovani@hass I'm adding more links to pages without pagination, check the title
Node http://www.theweek.co.uk/politics/gategate/49520/plebgate-mitchell-looks...
Taxonomy http://www.theweek.co.uk/pictures
Node http://www.autoexpress.co.uk/ford/mustang/60747/ford-mustang-shelby-gt500
@couturier Thanks, I'm just trying to make a point that it's not necessary to clutter metatag module when you can achieve the same with tokens. Let me know if I can help you with the setup.
Comment #9
marcelovani@couturier re #5, please apply this on tokens module http://drupal.org/node/224262#comment-6443384
Comment #10
DamienMcKennaMaybe instead Metatag could provide a new token which could be customized via a settings page? For example, if you add the page title "[current-page:title][metatag:pager] | [site:name]", and you have the pager customized to say " | Page %page", on page 2 it would say e.g. "My important article | Page 2 | My cool site".
Comment #11
marcelovani@Damien I think this is a great idea, it gives the user the flexibility to decide where to use it.
Comment #12
couturier CreditAttribution: couturier commentedI like #10.
marcelovani, on #9, I have tried the patch on the current Tokens dev, and it still doesn't work with the Meta Tags dev module released October 11 to make the [current-page:page-number] show up in
<title>
despite being in the settings. I've removed the Smart Paging module at present to simplify things.Don't worry about me. I will leave it alone for now. It was working earlier with a previous Meta Tags dev and some patches (which I thought were now all committed to the new dev). If we get #10 going, page numbers in titles should work again.
Comment #13
DamienMcKennaOk, lets refocus the feature request then.
Comment #14
couturier CreditAttribution: couturier commentedI've just been working for about an hour and a half reviewing the Meta Tags queue and trying different things, and I still don't know why [current-page:page-number] has stopped working for me in the
<title>
of pages created by Views. I can get the page number to show for plain nodes, but it reverts to an old setting for Views pages, like the cache hasn't been flushed even though I have flushed it many times trying to get the new settings to take effect.It's okay, I don't need a fix now, I just wanted to report it, since this was working with some manually applied patches to a previous Meta Tags dev. I'm using Drupal stable release 7.15, with the October 11 Meta Tags dev, with Tokens dev and marcelovani's patch applied (from #9). I'm looking forward to [metatag:pager] as a solution.
Comment #15
couturier CreditAttribution: couturier commentedSomeone really experienced with SEO talked to me since my last comment and said they use Page Title with Meta Tags for all their sites that have SEO attention. So, I am working now with both together and am finally seeing my pager number showing up on paginated Views. I'm just leaving the title options in Meta Tags blank and formatting all the titles in Page Title.
Since this works already in Page Title, and the two modules seem to peacefully co-exist, do you still want to work to build paging from the ground up into Meta Tags? I'm also seeing a lot of other fine-grained Page Title options there that don't exist in Meta Tags yet. Can the Page Title people get together with the Meta Tags people and just mesh the two modules? Forgive me if I sound over-simplistic, as I'm not a programmer. I'm just wanting to save everyone some work.
Comment #16
hass CreditAttribution: hass commentedI do not like to use page title myself.
Comment #17
couturier CreditAttribution: couturier commentedJust tried to add the Smart Paging module in addition to using Page Title and Meta Tags, and it improves URLs, but removes the Page Title enumeration in titles, even with the Smart Paging "display content title suffix" unchecked. Like marcelovani is doing, you cannot use Page Title with Smart Paging and make it work. It has to be done through tokens added to Meta Tags, as described in #2.
Comment #18
FiNeX CreditAttribution: FiNeX commentedCurrently I'm using metatag + page_title on every website where SEO is important. This is necessary if you care about SEO.
Comment #19
standingtall CreditAttribution: standingtall commentedAny update on this?
Comment #20
couturier CreditAttribution: couturier commentedYou still need to use Metatag and Page Title modules together if you want all features important to SEO. Metatag is slowly incorporating the Page Title functions, but you still have much better control in Page Title. Metatag has coding that recognizes when Page Title is being used on the same website and ensures that the functions do not overlap. It could be different in Drupal 8 or 9, so we will have to re-evaluate at that time and see whether more work has been done on Metatag so that you can do everything from that one module.
Comment #21
standingtall CreditAttribution: standingtall commentedThanks.
Is it possible to import/export title tags between the two modules? I have too many custom titles saved in meta tag.
Comment #22
DamienMcKenna@standingtall: Rather than waste time on that you could maybe try creating a token to fill in the missing gap between the modules?
Comment #23
standingtall CreditAttribution: standingtall commentedThanks DamienMcKenna
Does Meta Tag module generate a token that can be used in Page Title module?
A lot of my titles are modified at individual level.
Comment #24
couturier CreditAttribution: couturier commented@standingtall I'll repeat this, that Metatag cannot give you individual control over your page titles like you are asking. It is always good practice on a large website to automate as much as possible. You can use a toke that takes the title of the node to make each page title different. If you have fewer than a thousand titles, it would be worthwhile to open two browser windows and just transfer the titles into Page Title manually. However, I recommend using a token to make things more standard and faster if you ever want to change which module you are using to control the page titles.
Comment #25
standingtall CreditAttribution: standingtall commented@couturier - Metatag does give that much control. All my tags are automated plus I have the flexibility to override them on node level.
I have over 90,000 nodes so manually copy/pasting is not an option.
How do Metatag and Page Title work together? I mean which gets called first by Drupal if both are installed.
Comment #26
couturier CreditAttribution: couturier commented@standingtall So, is your question about how to add a pager suffix number? You could also try the Smart Paging module, see this comment. Page Title is called first (if it is activated and configured) when it is installed along with Metatag. The pager suffix number is the last major feature that needs to be moved to Metatag before developers can comfortably stop using both modules together for SEO. If you would like to program something for this feature in Metatag, it would be greatly appreciated.
Also, last I checked in early 2013, the pager token in Metatag did not actually work. Has that been fixed?
Comment #27
standingtall CreditAttribution: standingtall commentedThanks couturier. I installed Smart Paging and it provides great SEO benefit in its own right.
However, I have not been able to make the page titles work (added patches etc. too).
Currently I am getting issues on first page of Taxonomy terms. Ideally, I would only want to the title suffix to appear on second page onwards but it is adding it even on page 1. Example
My terms | 1 | Site Name
while I would Want
My terms | Site Name
My terms | 1 | Site Name
My terms | 2 | Site Name
onwards.
Furthermore, I was achieving this without Smart Paging as well so not sure Smart Paging has any impact here at all. Token [smart-paging:page-number] doesn't work on Taxonomy pages either.
Comment #28
marcelovaniTo remove the | 1 | you can add this to your template.php
function template_preprocess_html(&$vars) {
// remove page from title when page = 1.
$vars['head_title'] = str_replace('| 1 |', '|', $vars['head_title']);
}
You can use your theme name instead of the word 'template' i.e. zen_preprocess_html()
Comment #29
standingtall CreditAttribution: standingtall commentedThanks #28 worked like a charm. Issue solved for me.
Comment #30
harderj1 CreditAttribution: harderj1 commentedI am using Smart Paging and the most recent dev of Metatag. I've tried using both tokens, [smart-paging:page-number] [current-page:page-number], and both always return a 1 even when it is not the first page. This is the case on Taxonomy Term pages and Views generated pages.
@standingtall Can you post what patches/versions you are using to get the Page numbers to work on Taxonomy pages?
Or could someone else point me in the right direction? Thanks!
Comment #31
couturier CreditAttribution: couturier commentedIf you are using Smart Paging, I don't think you need a token in Metatag for the URL of Views-generated multi-page displays. Have you tried removing all those tokens in Metatag and seeing what Smart Paging generates on its own?
Comment #31.0
couturier CreditAttribution: couturier commentedRefocusing the request.
Comment #32
Plazik CreditAttribution: Plazik commentedWe can use Metatag Context, Context and Context Query Parameters to set up metatags on pages with
?page=
parameter in url.For example:
admin/structure/context
page.Add
and openadmin/structure/context/add
pagepager
, Conditions -Query parameters
, Parameter name -page
, Operator -must be set and have some value
, Parameter value - empty.Meta Data
, Page Title -[current-page:title] - Page [current-page:page-number]
This page title now will be work only on pages with pager (?page=123) exept the first page (without ?page in url).
Comment #33
DamienMcKennaAnyone care to put together a patch for this that could be included in the forthcoming 1.0 release?
Comment #34
DamienMcKennaTaking this off the 1.0 release queue, will follow-up with it after 1.0 is out.
Comment #35
psykotik CreditAttribution: psykotik commentedWhile I could not code anything, should you need any tester for this functionality, just let me know.
Comment #36
Ben Finklea CreditAttribution: Ben Finklea commentedWhat is the status of this issue? I've read it twice now and still can't quite figure out exactly where we are on this. Is it ready to go? Needs testing?
I've got a few clients that need this functionality. What could I do to push this over the edge and get it into the next release? Plead? Beg? Cash bounty? :)
Comment #37
DamienMcKenna@Ben: A patch, or time. Now that Metatag has a settings page we finally have somewhere that the pager could be managed from.
Comment #38
DamienMcKennaThis will need #2534214: Add optional page title prefix/suffix option.
The question is - should the pager go in between the normal page title and the (new) suffix, e.g. "Page title | page 42 | My awesome site"?
Comment #39
DamienMcKennaComment #40
DamienMcKennaHow does this work for you?
Comment #41
DamienMcKennaShould it also migrate the "page_title_pager_pattern" variable from the Page Title module and adjust it as necessary? FYI the patch in #40 isn't a suffix, by default it's designed to go in the middle or beginning of strings, e.g. "[node:title] | [current-page:pager][site:name]" is the new default page title for nodes.
Comment #43
DamienMcKennaI've committed this, lets deal with improvements as separate issues. Thanks everyone!
Comment #45
hass CreditAttribution: hass commentedThanks for adding this, but how can this translated? Can we add variables module support, please?
Comment #46
DamienMcKenna@hass: Lets do that in #2567621: Add Variables module support.