By Daniel_Hatcher on
Just a quick question i need a way to read the URL in a module i need to get the id.
The URL is like so.
tutorial/show/1
i need to collect on the no. 1 from it. If anyone can help i'll be eternally grateful.
Just a quick question i need a way to read the URL in a module i need to get the id.
The URL is like so.
tutorial/show/1
i need to collect on the no. 1 from it. If anyone can help i'll be eternally grateful.
Comments
A couple of approaches
If you are defining the callback as part of the menu hook you have a path defined as either 'tutorial' or 'tutorial/show' and some callback function (for examples purposes I will call it tutorial_page). If you path is 'tutorial' you can then define the function as
or if your path is 'tutorial/show' you would define the function as
If the code in question can not be defined this way you can always use the arg() function, using 'tutorial/show/1' as an example, arg(0) would return 'tutorial', arg(1) would return 'show' and arg(2) would return '1'.
That works, thanks alot.
That works, thanks alot.