The categoryid is not passed thru location array by default.
So you can:
1. modify PHP code to pass it
2. pull all the categories with their ids from db, pass them to template and find id that corresponds required category name (PHP again)
3. Parse category URL to get it's number
The third way is the easiest one
like this:
Code:
{assign var=substr value=$location[1].1|regex_replace:"/^[^=]*/":""}
{$substr|regex_replace:"/\D*/":""}
For the root cat it will print nothing since root cat URL is home.php