URL Routing

Permalink
Basically, I want a url to route to a controller actions. For example,http://www.example.com/blah/ is an actually page, by I would likewww.www.example.com/blah/blah1/... to automatically be routing to the controller. Most likely blah1 will be a 4 digit number which will be the id for some data in a database.

 
Job replied on at Permalink Reply
Job
How about get strings and then htaccess to rewrite it to appear as you'd like it to.
A fairly roundabout way, but I'm not if what you want to do is possible.

Job.
ScottC replied on at Permalink Reply
ScottC
how about:

http://www.concrete5.org/marketplace/addons/url-director/...

I wrote this for this in mind.
reese88 replied on at Permalink Reply
I was able to figure it out, thank you both.
titanve replied on at Permalink Reply
titanve
Hello Reese,

How did you figure it out? I'm trying to do the same thing with Backbone.

Thank you in advance.
jordanlev replied on at Permalink Reply
jordanlev
You can do this with a controller. You can have a controller for a "single_page" or for a regular page that is added by the user.

For a single_page, the controller would be in /controllers/your-page-handle.php
For a user-created page, you need a controller for a specific page type. Let's say you have a pagetype with the handle "blog_post", then you would create this folder:
/controllers/page_types/
...and inside that folder put a file called "blog_post.php". Inside that file would be something like this:
<?php defined('C5_EXECUTE') or die("Access Denied.");
class BlogPostPageTypeController extends Controller {
   public function view($first_querystring_arg = null, $second_querystring_arg = null) {
      //do something here with the querystring args, then send data to the page type template via $this->set('variable_name', $value);
   }
}


If this is a "single_page", check out this boilerplate code I have for dashboard CRUD interfaces:https://github.com/jordanlev/c5_boilerplate_crud...

Hope that helps!

-Jordan
titanve replied on at Permalink Reply
titanve
Dear Jordan,

Thank you for your help, but, what do you mean with single_page and
user-created
page? what's the difference between them?

Thank you



----------------------------------------------
Atentamente/Best regards

Rafael Mora
Cel/Mob: +58-414-493.31.39
BB Pin: 79F583A5
Twitter @titanve. I'm also on Telegram and Whatsapp
jordanlev replied on at Permalink Reply
jordanlev
titanve replied on at Permalink Reply
titanve
Thank for your help. I will try what you suggest.

Best regards



----------------------------------------------
Atentamente/Best regards

Rafael Mora
Cel/Mob: +58-414-493.31.39
BB Pin: 79F583A5
Twitter @titanve. I'm also on Telegram and Whatsapp