Jump to content

URL Segments passing callback paramaters -- Help?


John W.
 Share

Recommended Posts

I seem to be having trouble with url segments on a projects. I'm working on an arrest report system and will provide the structure.

What I have is a page called arrests in the back end that loads up an arrests.php file.

Under arrests, in the back-end (with URL segments enabled), I have two pages that only store data, they don't load actual .php files.

structure in the back-end (see attached photo)

/arrests (loads arrests.php)

          -February 2016   - a page that uses a template called arrestlog that only stores data, it has no .php file

          -March 2016 - a page that uses a template called arrestlog that only stores data, it has no .php file

          

when my site loads /arrests/ my arrests.php performs a find('template=arrestlog') where I display only the most recent addition, in this case data for March 2016.

So, if you go to /arrests/ in a browser, arrests.php does a $pages->find() and displays only March 2016 data.

What I'm trying to do is create a "next" link that loads : /arrests/february-2016/

So, when arrests is passed a url segment1 I can pull that url segment, then run a find on it to display february data.

I could use /arrests/?id= method to callback arrests.php passing a parameter, but, I'd rather use a friendly url segment if possible.

The end result is I'm getting a 404.

Assistance is much appreciated.

post-3466-0-87644200-1459472233_thumb.jp

Link to comment
Share on other sites

The only other thing I could think is to remove February, March etc from under /Arrests/ then create a root page called Arrest-Data(without a .php) just for the data like so...

Home

About Us

Arrests  (loads arrests.php that pulls data from Arrest-Data below)

Contact

----

Arrest-Data (2)

      February 2016
      March 2016

      etc...

Trash

Link to comment
Share on other sites

Problem solved.

For anyone that runs into this problem here is what I found.

Since /arrests/ has other data holder templates you can't pass the name of any of the children or you will get a 404 since those templates don't have a page.

Work around is call, as in my example, instead of /arrests/february-2016/, since february-2016 is only a template without a page this generates an error.

Instead, enable url segments on /arrests/, then call /arrests/s/february-2016/

Since there is no possibility of their being a data template named "s", it will load without a name collision.

You can replace "s" with anything, as long as you know that none of your data templates will have that same name.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...