0

this is my page view path /news/[years]/[month]

I want to get year and month from path, how can do it ?

Thank you.

2

You can use the arg() function.

Returns a component of the current Drupal path.

When viewing a page at the path "admin/structure/types", for example, arg(0) returns "admin", arg(1) returns "structure", and arg(2) returns "types".

In your case:
arg(1) = [year]
arg(2) = [month]

2
  • arg() is perfectly fine and works almost everytime... But remember - when you are dealing with Ajax, the path could be system/ajax so arg(0) would be system. +1 – AKS May 1 '13 at 18:48
  • this one also return an array of contextual filters arguments views_get_page_view()->args – Lhassan Baazzi May 1 '13 at 20:46

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.