this is my page view path /news/[years]/[month]
I want to get year and month from path, how can do it ?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
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]