Project:Token
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hello,

I would like to ask a new feature for the next release. Every page of pagination of Drupal has the same title. Would be posible to rename those pages too in the next release of this module?

Example: node?page=1 Page 1 | Sitename

This would help in search engines as they are detecting all the pagination pages are duplicate content with the index.

Comments

#1

It is something I'd like to ad - however... What if you have a page with TWO pagers on it?

Eg, a panel page and the panel has 2 paged views.

#2

I dont really understand what you mean, but i guess that the main page must use the "custom" title.

#3

The 'issue' is easy to solve if any given page only has 1 pager on it... But what if you have a page with two separate pages on it. In my example, say you defined a panel which has 2 views in it. Each view has its own pager. What if we set View 1 to be Page 2 and View 2 to be page 5.... What should the title be? How would we get a simple and effective interface to configure the title for something like this.

#4

Title:Pagination titles.» Pagination titles for simple cases

I agree that the "two pagers per page" problem is a hard problem to solve, but it's not very common. Why not just focus initially on the simple cases like the node/ pager, forum pagers, blog pager, tracker pager. ?

#5

Status:active» needs review

How about this attempt? patch sets a token value for the pager-page if set.

AttachmentSizeStatusTest resultOperations
page_title.module.224262.patch899 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch page_title.module.224262.patch.View details

#6

Ahh adding it as a Token isn't a bad idea! However, for security, Instead of...

<?php
  $values
['pager-page'] = $_REQUEST['page'] ? t('Page') .' '. $_REQUEST['page'] : '' ;
?>

I'd recommend something like:

<?php
  $values
['pager-page'] = $_REQUEST['page'] ? t('Page @page', array('@page' => $_REQUEST['page']) : '' ;
?>

This does two things:

  1. It allows easy translation of the title
  2. It also protects the code from malicious gits. The code you provided simply printed whatever was in the $_REQUEST into (in this case) the in the of the page. This could quite easily allow XSS. I believe this meethod should stop it as any 'variables' starting with an '@' get run through check_plain.
  3. Does else anyone have any thoughts on this?

#7

works for me...i suppose you could even force a check for is_numeric to be
even more complete.

#8

Do you know what would be REALLY nice...

Another module which took potential arguments from the URL (eg, 'page') and provided them as tokens :-)

#9

I encoutered this problem on my site I have hundreds of duplicate pages on google because of it... So a big +1 for this from me.

A nice feature would be to be ale to build custom titles by inserting tokens related to the pager you are using : for examle for taxonomy pagers, I would include the taxonomy terms, forum could include the forum name, etc...

Looking forward to a new patch to help and test this.

Patchak

#10

There is already a token for the term name ([cat] I believe)... The problem is getting Page Title to be able to identify a taxonomy_term or forum page... PT2-dev has code in it for working with non-node page titles.

My theory for the page title is to write a tiny contrib module which provides a [page_numer] token... This would allow you to define a default page title as [title][page_number]. The [page_number] token could provide a response which has a space at the beginning (or a colon... or anything really?) to separate it from the rest of the content...

#11

Status:needs review» needs work

@nicholasThompson - this seems general enough that it belongs in token core as a global token. If you agree please move this issue there.

The other problem with this patch is that it puts "Page " into the output. In general tokens should be the most simple thing possible - e.g. the number. If someone wants to have the output like "Page #number" then they could use the pattern "Page [page-number]"

#12

If you agree please move this issue there

I'd be happy for this to be in Token Core. Two things:
1) I dont have permission to shift issues to different queue's...
2) Do you need a hand with this?

#13

Project:Page Title» Token
Version:5.x-2.x-dev» 6.x-1.x-dev

In the “Edit issue settings”, just select a different project from the pull-down menu when Posting a new comment.

This will need to back-ported to 5.x as well.

#14

@nicholasThompson
1) yeah, what JohnAlbin said
2) always!

#15

Ooops - I just realised about the Project drop down in the comment posting :-) (I cant see an Edit Issue Settings section)...

I'll try to get a patch for Token done :-)

#16

Hi guys,
this path seems not not work on 5.x version of Drupal.

Any issue for the problem for this version?

Thanks,
Bencio

#17

Is there any update on this? Is the page number token in yet?

Is it possible to use it with views?

Thanks,
Patchak

#18

Yes, what are news about this?

#19

(Just for info, It lacks a parenthesis in your example.)

New patch with your suggestion.

AttachmentSizeStatusTest resultOperations
page_title.module.patch674 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch page_title.module_15.patch.View details

#20

I user luron patch for page_title, and it works like a charm with page_title v2 per d6.

#21

I personally - as stated above - think that this patch should head into Token rather than Page Title. The concept of tokens is bigger than just Page Title (far bigger) so making Page Title a prerequisite for having the Page token is a little unfair on users... imho.

#22

Title:Pagination titles for simple cases» Add Page Number token

I have attached a 2 line modification patch which adds a page-number token to the global array.

This is particularly useful when Page Title needs to handle unique page titles for listing pages such as Views.

Any chance this could get committed? I'm running it on www.thingy-ma-jig.co.uk with the latest DRUPAL-6--2 release of Page Title. If you go to the frontpage you get the normal frontpage title but if you got to page 2, you get an appended string pattern which uses the [page-number] token provided by this patch.

AttachmentSizeStatusTest resultOperations
token.patch1.15 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch token_15.patch.View details

#23

Status:needs work» needs review

Updating status... Previous post failed to do so for some reason.

#24

For some strange reason - my patch seems to break token.module. It's not a syntax problem - but when I re-apply that patch to the same version of token on another site on the same server that generated the patch... I get:

# warning: include_once(./sites/mysite.co.uk/modules/token/token.module) [function.include-once]: failed to open stream: Permission denied in /var/www/html/mysite.co.uk/drupal/includes/bootstrap.inc on line 611.
#  warning: include_once() [function.include]: Failed opening './sites/mysite.co.uk/modules/token/token.module' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/mysite.co.uk/drupal/includes/bootstrap.inc on line 611.

Very odd!

EDIT: I Cannot explain that error - there must be a bug with my patch binary.. it works fine if I manually apply it!

To manually apply it..
... add the following to the end of the array in the function token_token_list (after the site-date-d entry):

<?php
$values
['page-number']     = check_plain(1 + (int)$_REQUEST['page']);
?>

... and add the following to the end of the array in the function token_token_values (again, after the site-date-d entry):

<?php
$tokens
['global']['page-number']     = t('The current page number for paged lists');
?>

#25

Status:needs review» reviewed & tested by the community

I've just tested this patch on my development virtual machine and it worked perfectly. My patch binary on my webserver must be broken...

#26

Priority:normal» critical

The same patch worked on DRUPAL-5 too... It outputted this message:

Hunk #1 succeeded at 91 (offset -8 lines).

But when I checked the file, the two lines were in the correct place.

Greggles - could this please get committed as it's a requirement for a new feature in Page Title. I did consider putting it in Page Title itself, however I feel that such a general token could be useful for other modules to have access to without Page Title being a prerequisite...

#27

Priority:critical» normal

Nowhere else in core do we use $_REQUEST['page'] - why not $_GET['page'] ?

check_plaining something that's been cast to (int) is unnecessary. We can just cast as an int and call it good.

I'm going to make a new release soon...if you can test dev to make sure it's good that will make me more likely to commit this. Bumping priority, not as much :p

AttachmentSizeStatusTest resultOperations
224262_token_page_27.patch1.15 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 224262_token_page_27.patch.View details

#28

Status:reviewed & tested by the community» needs review

#29

Those changes look sensible - I'll run a test now on DRUPAL-6--1 and DRUPAL-5....

#30

Status:needs review» needs work

I've been looking through the pager_query function and it looks like $_GET['page'] could be a comma separated numbers as a string if there is more than 1 page...

Thoughts... Imagine we have a page with multiple pagers on it (in this example, assume 3 or more). Imagine we have selected Page 2, 3 and 7 for these pagers. In this case, do you think [page-number] should contain:
a) the string "2,3,7"
b) the string "2, 3 and 7" (or "2, 3 & 7").
c) just the first page listed (in this case "2").

Any thoughts?

#31

I say 2. That's how we handle multiple terms/vocabs on a node.

If someone wants a token for each they should create a custom module.

#32

Status:needs work» needs review

Attached is a patch which does option C (from post #30).

If there is a comma present in $_GET['page'], a substr() will be applied to grab the first digit, otherwise the $_GET['page'] will be used. I also added a short comment to explain what is happening in the line.

Cheers,
Nick

AttachmentSizeStatusTest resultOperations
224262-2-d6.token_.module.patch1.33 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 224262-2-d6.token_.module.patch.View details
224262-2-d5.token_.module.patch1.33 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 224262-2-d5.token_.module.patch.View details

#33

Status:needs review» fixed

This seems slightly difficult to read, but since I'm the dumbest guy who works on this module it shouldn't be a problem ;)

Committed to 5.x http://drupal.org/cvs?commit=217380 and 6.x http://drupal.org/cvs?commit=217378

Thanks for providing both versions.

#34

Category:feature request» bug report
Status:fixed» needs review

On the first page is $_GET['page'] NULL therefore its better to check this. see patch.

AttachmentSizeStatusTest resultOperations
token-224262.patch1011 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch token-224262.patch.View details

#35

Status:needs review» fixed

Thanks, Razorraser, http://drupal.org/cvs?commit=219284 6.x and http://drupal.org/cvs?commit=219284 5.x fixed!

#36

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#37

Version:6.x-1.x-dev» 7.x-1.x-dev
Category:bug report» feature request
Status:closed (fixed)» patch (to be ported)

Re-opening to ensure this gets added to the D7 version.

#38

Status:patch (to be ported)» needs review

Patch up for review that adds a 'current page' token type and the [current-page:page-number] token for basic functionality, although it does need testing for it.

AttachmentSizeStatusTest resultOperations
224262-token-current-page-number-D7.patch1.46 KBIdlePASSED: [[SimpleTest]]: [MySQL] 18 pass(es).View details

#39

Revised patch that also adds current page alias and URL.

AttachmentSizeStatusTest resultOperations
224262-token-current-page-number-D7.patch3.05 KBIdleFAILED: [[SimpleTest]]: [MySQL] 17 pass(es), 1 fail(s), and 0 exception(es).View details

#40

Status:needs review» needs work

The last submitted patch, 224262-token-current-page-number-D7.patch, failed testing.

#41

Status:needs work» fixed

I fixed the one test failed by the testbot and I also tested locally, so committing to CVS!
http://drupal.org/cvs?commit=395840

#42

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#43

FYI
For Drupal 6 support
http://drupal.org/project/ptoken

#44

@podarok: You do know that Token for D6 provides a [current-page-number] token right?

#45

Is it global token?
I can`t find it in page_title global context
Possibly I have to use developpment version ?

nobody click here