Take number from url as page parameter

Permalink
I'm writing a catalog, it looks kindda like instagram. When someone click on a item, window pops up with bigger image, comments and description. Also url changes via JS from /catalog/ to /catalog/17. But if I press F5 on a /catalog/17 page, Concrete5 says "page not found" of course. Because /catalog/ is existing single page, but there's no /catalog/17 page. Is there a way to feed anything that goes after /catalog/ in url to /catalog/ page?

I know that I can do this instead: /catalog?id=17
But it's just doesn't look pretty.

 
hutman replied on at Permalink Reply
hutman
In your single page controller you can do

view($variableName = 0){
    if(intval($variableName) > 0){
        //do things, this is a detail
    } else {
        //do things, this is not a detail
    }
}
MaestroMagnifico replied on at Permalink Reply
This doesn't make sense. And it doesn't work. I think .htaccess is the way here. So I asked on stackoverflow for solution:http://stackoverflow.com/questions/42460756/alias-all-sub-pages-to-...
JohntheFish replied on at Permalink Reply
JohntheFish
C5 detects parameters to view() in a single page controller; So you can do
function view($catalog_item=null){
  if($catalog_item){
    // do something to get the item ready for the view.
  }
}


single/page/url/XX/

Will then pass XX to view().
MaestroMagnifico replied on at Permalink Reply
Still not get it. My single page is /catalog/. So my controller is /application/single_pages/catalog.php, right? I've added this function there, but when I open /catalog/17, it still shows "page not found" message.
hutman replied on at Permalink Reply
hutman
Your single page controller should be in /application/controllers/single_page/catalog.php if this file didn't exist before you will need to Refresh the single page in the dashboard to get it recognized. You will also need to make sure that the controller's namespace is correct.
JohntheFish replied on at Permalink Reply
JohntheFish
As a test, if you hack die('ME') into your single page controller, that will tell you if the core is loading your custom controller or the core's generic controller, and hence if you have been caught out by the idiosyncrasies of the class and path naming mess.
MaestroMagnifico replied on at Permalink Reply
Controller works. Function is there and I tried to update single page. /catalog/17 still says "page not found". Because there is no /catalog/17 in my pages tree.
JohntheFish replied on at Permalink Reply
JohntheFish
The view() function needs a parameter for every part of the path after the single page path.

so if the path is yoursite.com/catalog/17/

the view method needs to be function view($catalog_item){};

If you have further path parts, then you need parameters to hold them or c5 will think its a different page.

If you don't have pretty urls enabled, you will also need index.php in the path.
MaestroMagnifico replied on at Permalink Reply 1 Attachment
Nope, not working. I even tried to create new single page /test/, placed function view in controller, but /test/1 still says "page not found". Maybe there's something's wrong with my settings (check attachment)?