I am trying to display a list of objects related to my custom node, by showing one node on the node's page and also giving a "next" button which will call the same page but with the id/index of the next objects to display.

Is there a custom/better way to do it than with a GET parameter added to the url of the page call and then the reading of this parameter in the template file via $_GET[]?


You should never read the value of the $_GET param in a template file directly, that logic should be separated out into a process/preprocess function.

Other than that, no...there isn't really anywhere 'better' for page parameters to go. The alternatives are to use something session based, or to set something up to POST variables to the second page. Or use temporary database storage which seems like overkill for this.

Your use case sounds like the archetypal situation where URL parameters would be acceptable. For example, it's the same way Drupal core handles paging (the page parameter is added to URLs).

If you're worried about separating these pages up for SEO benefit, that's a different matter, and you should look at creating unique paths for each piece of content (provided of course that the page changes enough to not be seen as a duplicate with the URL parameter available).

  • Thanks, good point with the pagination, it is indeed basically the same use-case. For now i am not concerned with the SEO considerations, but i will keep that in mind (i hope) :) – Larzan Sep 17 '12 at 12:40
  • 2
    For SEO sake you can instruct Google not to consider these specific parameters in Google webmaster tools. – tostinni Sep 17 '12 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.