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

nevets’s picture

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

function tutorial_page($op, $id) {
// Where using the path 'tutorial/show/1',  $op is 'show' and $id would be 1
}

or if your path is 'tutorial/show' you would define the function as

function tutorial_page($id) {
// Where using the path 'tutorial/show/1',  $id would be 1
}

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'.

Daniel_Hatcher’s picture

That works, thanks alot.