Routing for optional controller using generic controller otherwise / Dynamic Routing.

2013-05-07 Thread Sebastian Piskorski
I'd like to make an application in CakePHP which manages exercises and 
users results. Users and results are not important in this question.

I want to have a possibility to add an exercise with adding only a specific 
table and line to .ini config file. Application should route to a 
GenericExercisesController if specific one doesn't exists. Controller 
should load a GenericExerciseModel if specific doesn't exists. I'd managed 
with model loading and partially with routing with controller like this:

In `route.php`

foreach(Configure::read('exercisesTables') as $exerciseName){
if( App::import('Controller', Inflector::pluralize($exerciseName))){

Router::connect('/exercises/'.Inflector::pluralize($exerciseName).'/:action', 
array('controller' => Inflector::pluralize($exerciseName)));
}else{

Router::connect('/exercises/'.Inflector::pluralize($exerciseName).'/:action', 
array('controller' => 'GenericExercises', 'fakeModel' => $exerciseName));
}
}

So if I want to load an exercise **Foo** I should use address:

`http://example.com/exercises/Foos/view`

And this works fine, doesn't matter if specific controller exists. 

Problem begins when I use reverse routing to generate links in views. If 
exercise **Foo** have specific controller this works correctly:

`print $this->Html->url(array('controller' => 
Inflector::pluralize($exerciseName), 'action' => 'view'));` 
produces:
`/exercises/Foos/view`

But when exercise **Bar** doesn't have specific controller then the same 
code produces:
`/Bars`

This causes a problem, there is no `Bars` Controller.

Temporarily I'm generating those links manually, but I don't think that 
this is the best solution:

`print 
$this->Html->url("/".Configure::read('exerciseRoutingPrefix')."/".Inflector::pluralize($exerciseName)."/view");`

Those are routes in `route.php` defined before `foreach` in order as 
they're in file:

Router::connect('/', array('controller' => 'questions', 'action' => 
'regulations'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 
'display'));
Router::connect('/help', array('controller' => 'pages', 'action' => 
'faq'));

Maybe someone of you know a better solution. Thank you for reading my 
question.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dynamic Routing

2008-10-28 Thread Dardo Sordi Bogado

This might help, look at the comments:

http://bakery.cakephp.org/articles/view/taking-advantage-of-the-pages-controller

Others approaches:

http://snook.ca/archives/cakephp/static_pages_cakephp12/
http://cakebaker.42dh.com/2008/06/18/an-alternative-approach-for-static-pages/
http://snook.ca/archives/cakephp/easier_static_pages_2/

> Could you possibly point me to the specific page in the manual
> where it refers to this area of functionality?

He is talking probably about the routes section.

> Also, is there a way to pass control from one controller to another?
> If thats in the manual also could you point me to the page in the
> manual where it talks about it?

For another action in the same controller you can use
$this->setAction(), but for a different controller you can use
$this->requestAction() or instanciate the other controller and do the
dispatching yourself (don't forget to call constructClasses()  in the
new controller).

HTH,
- Dardo Sordi.

> Thanks.
>
> On Oct 26, 2:18 am, deedod <[EMAIL PROTECTED]> wrote:
>> What's the best way to go about setting updynamicrouting
>> so that I can redirect all my 'missing controller' errors to another
>> defined controller to perform operations on?
>>
>> I basically want any error page to filter through the pages controller
>> (or any other controller I choose) so I can check the requested URL
>> and determine if the URL is valid or not.
>>
>> I have some other defined controllers that I use as normal but I also
>> want the ability to define custom URLs for a page and then to be
>> able to pull the data for that page after checking the URL requested.
>>
>> Should I use some sort ofrouting?  Or is there another approach I
>> should use.  I don't want to redirect ALL pages to the specified
>> controller since I have a couple other controllers that I use.
>>
>> Also, is there a way that you can pass control from one controller
>> to another?  For instance, I'm in the pages controller but is there a
>> way to jump to another controller on the fly?
>>
>> Any help would be great.
>>
>> Thanks.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-10-27 Thread deedod

Could you possibly point me to the specific page in the manual
where it refers to this area of functionality?

Also, is there a way to pass control from one controller to another?
If thats in the manual also could you point me to the page in the
manual where it talks about it?

Thanks.

On Oct 26, 2:18 am, deedod <[EMAIL PROTECTED]> wrote:
> What's the best way to go about setting updynamicrouting
> so that I can redirect all my 'missing controller' errors to another
> defined controller to perform operations on?
>
> I basically want any error page to filter through the pages controller
> (or any other controller I choose) so I can check the requested URL
> and determine if the URL is valid or not.
>
> I have some other defined controllers that I use as normal but I also
> want the ability to define custom URLs for a page and then to be
> able to pull the data for that page after checking the URL requested.
>
> Should I use some sort ofrouting?  Or is there another approach I
> should use.  I don't want to redirect ALL pages to the specified
> controller since I have a couple other controllers that I use.
>
> Also, is there a way that you can pass control from one controller
> to another?  For instance, I'm in the pages controller but is there a
> way to jump to another controller on the fly?
>
> Any help would be great.
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-10-26 Thread majna

You should just r3ad manual. It is all there!
http://book.cakephp.org/


On Oct 26, 7:18 am, deedod <[EMAIL PROTECTED]> wrote:
> What's the best way to go about setting up dynamic routing
> so that I can redirect all my 'missing controller' errors to another
> defined controller to perform operations on?
>
> I basically want any error page to filter through the pages controller
> (or any other controller I choose) so I can check the requested URL
> and determine if the URL is valid or not.
>
> I have some other defined controllers that I use as normal but I also
> want the ability to define custom URLs for a page and then to be
> able to pull the data for that page after checking the URL requested.
>
> Should I use some sort of routing?  Or is there another approach I
> should use.  I don't want to redirect ALL pages to the specified
> controller since I have a couple other controllers that I use.
>
> Also, is there a way that you can pass control from one controller
> to another?  For instance, I'm in the pages controller but is there a
> way to jump to another controller on the fly?
>
> Any help would be great.
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dynamic Routing

2008-10-25 Thread deedod

What's the best way to go about setting up dynamic routing
so that I can redirect all my 'missing controller' errors to another
defined controller to perform operations on?

I basically want any error page to filter through the pages controller
(or any other controller I choose) so I can check the requested URL
and determine if the URL is valid or not.

I have some other defined controllers that I use as normal but I also
want the ability to define custom URLs for a page and then to be
able to pull the data for that page after checking the URL requested.

Should I use some sort of routing?  Or is there another approach I
should use.  I don't want to redirect ALL pages to the specified
controller since I have a couple other controllers that I use.

Also, is there a way that you can pass control from one controller
to another?  For instance, I'm in the pages controller but is there a
way to jump to another controller on the fly?

Any help would be great.

Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-13 Thread mbavio

Not necesarily with reverse routes... I guess...

http://debuggable.com/posts/new-router-goodies:480f4dd6-4d40-4405-908d-4cd7cbdd56cb

On Jun 13, 7:23 am, RichardAtHome <[EMAIL PROTECTED]> wrote:
> Another problem with slug based URLs is ..
>
> What if they change the slug? You'll get a bunch of broken bookmarks
> (not necessarily  in your app, but in all the places outside your app
> that point to it)...
>
> On Jun 13, 11:12 am, Marcin Jaworski <[EMAIL PROTECTED]> wrote:
>
> > If you allow only "-", "_" and alphanumeric characters in user slugs
> > then this should also do it:
> > ^([-_a-z0-9]*[-_a-z][-_a-z0-9]*)$
>
> > Then string with at least one non-numeric characted anywhere will be
> > matched as slug.
>
> > On 13 Cze, 01:48, "b logica" <[EMAIL PROTECTED]> wrote:
>
> > > On Thu, Jun 12, 2008 at 7:04 PM, Dardo Sordi Bogado
>
> > > <[EMAIL PROTECTED]> wrote:
>
> > > >> allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
> > > >> just make sure it
> > > >> can't *begin* with a number:
>
> > > >> ^([^0-9][-_a-z0-9]+)
>
> > > > Actually, anything which isn't just numbers will be ok.
>
> > > Every one of which belongs to the set of strings which do not begin
> > > with a number.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-13 Thread RichardAtHome

Another problem with slug based URLs is ..

What if they change the slug? You'll get a bunch of broken bookmarks
(not necessarily  in your app, but in all the places outside your app
that point to it)...

On Jun 13, 11:12 am, Marcin Jaworski <[EMAIL PROTECTED]> wrote:
> If you allow only "-", "_" and alphanumeric characters in user slugs
> then this should also do it:
> ^([-_a-z0-9]*[-_a-z][-_a-z0-9]*)$
>
> Then string with at least one non-numeric characted anywhere will be
> matched as slug.
>
> On 13 Cze, 01:48, "b logica" <[EMAIL PROTECTED]> wrote:
>
> > On Thu, Jun 12, 2008 at 7:04 PM, Dardo Sordi Bogado
>
> > <[EMAIL PROTECTED]> wrote:
>
> > >> allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
> > >> just make sure it
> > >> can't *begin* with a number:
>
> > >> ^([^0-9][-_a-z0-9]+)
>
> > > Actually, anything which isn't just numbers will be ok.
>
> > Every one of which belongs to the set of strings which do not begin
> > with a number.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-13 Thread Marcin Jaworski

If you allow only "-", "_" and alphanumeric characters in user slugs
then this should also do it:
^([-_a-z0-9]*[-_a-z][-_a-z0-9]*)$

Then string with at least one non-numeric characted anywhere will be
matched as slug.

On 13 Cze, 01:48, "b logica" <[EMAIL PROTECTED]> wrote:
> On Thu, Jun 12, 2008 at 7:04 PM, Dardo Sordi Bogado
>
> <[EMAIL PROTECTED]> wrote:
>
> >> allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
> >> just make sure it
> >> can't *begin* with a number:
>
> >> ^([^0-9][-_a-z0-9]+)
>
> > Actually, anything which isn't just numbers will be ok.
>
> Every one of which belongs to the set of strings which do not begin
> with a number.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread b logica

On Thu, Jun 12, 2008 at 7:04 PM, Dardo Sordi Bogado
<[EMAIL PROTECTED]> wrote:
>
>> allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
>> just make sure it
>> can't *begin* with a number:
>>
>> ^([^0-9][-_a-z0-9]+)
>
> Actually, anything which isn't just numbers will be ok.
>

Every one of which belongs to the set of strings which do not begin
with a number.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread Dardo Sordi Bogado

> allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
> just make sure it
> can't *begin* with a number:
>
> ^([^0-9][-_a-z0-9]+)

Actually, anything which isn't just numbers will be ok.

> Also, a check would already be needed to ensure that the submitted
> string wasn't already taken.
>
> On Thu, Jun 12, 2008 at 4:07 PM, Jonathan Snook
> <[EMAIL PROTECTED]> wrote:
>>
>> The reason I didn't recommend your approach is because the user slugs
>> are user definable. What if I wanted to call myself "6"? (I am not a
>> number...) You have to set a restriction on user slugs to include a
>> non digit character so as not to create issues. Your user slugs are
>> restrictive in that NO numbers could be used which would prevent me
>> from using my semi-common alias, gr66nman. But either solution is
>> viable, it's just important to be aware of the restrictions in doing
>> so.
>>
>> On Thu, Jun 12, 2008 at 4:00 PM, b logica <[EMAIL PROTECTED]> wrote:
>>>
>>> It works for me. What's needed, though, is a regexp and then rules to
>>> ensure that the user-defined slug will match when it's created.
>>>
>>> /* matches underscore, hyphen, and lowercase alpha
>>>  */
>>> Router::connect('/users/:user_slug',
>>>array('controller' => 'users', 'action' => 'view'),
>>>array('user_slug' => '[-_a-z]+')
>>> );
>>>
>>> Router::connect('/users/:user_id',
>>>array('controller' => 'users', 'action' => 'view'),
>>>array('user_id' => '[0-9]+')
>>> );
>>
>> >
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread b logica

Yeah, that's the down-side. But, if the OP s willing to accept that
then, as i said, it would
be necessary to set up rules to restrict what slugs could be created.
But, doing so is not
much different than having password creation rules. For this purpose,
I'd certainly recommend
checking that the user doesn't choose, "/haxxor/me". So it's not like
just any chacter should be
allowed, anyway. Disallowing numbers shouldn't be such a big deal. Or
just make sure it
can't *begin* with a number:

^([^0-9][-_a-z0-9]+)

Also, a check would already be needed to ensure that the submitted
string wasn't already taken.

On Thu, Jun 12, 2008 at 4:07 PM, Jonathan Snook
<[EMAIL PROTECTED]> wrote:
>
> The reason I didn't recommend your approach is because the user slugs
> are user definable. What if I wanted to call myself "6"? (I am not a
> number...) You have to set a restriction on user slugs to include a
> non digit character so as not to create issues. Your user slugs are
> restrictive in that NO numbers could be used which would prevent me
> from using my semi-common alias, gr66nman. But either solution is
> viable, it's just important to be aware of the restrictions in doing
> so.
>
> On Thu, Jun 12, 2008 at 4:00 PM, b logica <[EMAIL PROTECTED]> wrote:
>>
>> It works for me. What's needed, though, is a regexp and then rules to
>> ensure that the user-defined slug will match when it's created.
>>
>> /* matches underscore, hyphen, and lowercase alpha
>>  */
>> Router::connect('/users/:user_slug',
>>array('controller' => 'users', 'action' => 'view'),
>>array('user_slug' => '[-_a-z]+')
>> );
>>
>> Router::connect('/users/:user_id',
>>array('controller' => 'users', 'action' => 'view'),
>>array('user_id' => '[0-9]+')
>> );
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread Jonathan Snook

The reason I didn't recommend your approach is because the user slugs
are user definable. What if I wanted to call myself "6"? (I am not a
number...) You have to set a restriction on user slugs to include a
non digit character so as not to create issues. Your user slugs are
restrictive in that NO numbers could be used which would prevent me
from using my semi-common alias, gr66nman. But either solution is
viable, it's just important to be aware of the restrictions in doing
so.

On Thu, Jun 12, 2008 at 4:00 PM, b logica <[EMAIL PROTECTED]> wrote:
>
> It works for me. What's needed, though, is a regexp and then rules to
> ensure that the user-defined slug will match when it's created.
>
> /* matches underscore, hyphen, and lowercase alpha
>  */
> Router::connect('/users/:user_slug',
>array('controller' => 'users', 'action' => 'view'),
>array('user_slug' => '[-_a-z]+')
> );
>
> Router::connect('/users/:user_id',
>array('controller' => 'users', 'action' => 'view'),
>array('user_id' => '[0-9]+')
> );

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread b logica

It works for me. What's needed, though, is a regexp and then rules to
ensure that the user-defined slug will match when it's created.

/* matches underscore, hyphen, and lowercase alpha
 */
Router::connect('/users/:user_slug',
array('controller' => 'users', 'action' => 'view'),
array('user_slug' => '[-_a-z]+')
);

Router::connect('/users/:user_id',
array('controller' => 'users', 'action' => 'view'),
array('user_id' => '[0-9]+')
);

Then, in the controller:

function view($id = null)
{
if (empty($id))
{
 if (isset($this->params['user_slug']))
 {
   /* either find the user or the user id from the slug,
whichever is preferred
*/
   $this->set('user',
$this->User->findBySlug($this->param['user_slug']));
  }
  else if (isset($this->params['user_id']))
  {
   // ...
  }
  else
  {
// error
   }
  }
  else
  {
// find by ID
   }
}

On Thu, Jun 12, 2008 at 3:41 PM, Jonathan Snook
<[EMAIL PROTECTED]> wrote:
>
> On Thu, Jun 12, 2008 at 12:52 PM, mwcbrent <[EMAIL PROTECTED]> wrote:
>> I'm looking to setup a system that will do rewrites, this is
>> similar to myspace or other sites that allow you to setup a page and
>> change the url to something personalized.
>> www.mysite.com/user/232434
>> to
>> www.mysite.com/user/myhomepage
>
> Reusing /user/* for both IDs and custom labels is going to be a pain.
> I'd recommend coming up with something different for the /user/ part
> to more readily differentiate between the two structures. For example:
>
> Router::connect('/person/:label', array('controller'=>'users',
> 'action'=>'bylabel'), array('label'=>'.*')); (or something like that)
>
> function bylabel(){
>  $user = $this->User->findByLabel($this->params['label']);
>  [...other code here...]
> }
>
> That's a pretty rough idea.
>
>> Is there a way to get the routing system to check the database?  Or
>> should i just not even use the routing system and query the db with
>> 'myhomepage' instead of the user id passed in the url?
>>
>> Thanks for the feedback.
>>
>> >
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic Routing

2008-06-12 Thread Jonathan Snook

On Thu, Jun 12, 2008 at 12:52 PM, mwcbrent <[EMAIL PROTECTED]> wrote:
> I'm looking to setup a system that will do rewrites, this is
> similar to myspace or other sites that allow you to setup a page and
> change the url to something personalized.
> www.mysite.com/user/232434
> to
> www.mysite.com/user/myhomepage

Reusing /user/* for both IDs and custom labels is going to be a pain.
I'd recommend coming up with something different for the /user/ part
to more readily differentiate between the two structures. For example:

Router::connect('/person/:label', array('controller'=>'users',
'action'=>'bylabel'), array('label'=>'.*')); (or something like that)

function bylabel(){
  $user = $this->User->findByLabel($this->params['label']);
  [...other code here...]
}

That's a pretty rough idea.

> Is there a way to get the routing system to check the database?  Or
> should i just not even use the routing system and query the db with
> 'myhomepage' instead of the user id passed in the url?
>
> Thanks for the feedback.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dynamic Routing

2008-06-12 Thread mwcbrent

Tried to search around for a few things before I posted but couldn't
find it.  I'm looking to setup a system that will do rewrites, this is
similar to myspace or other sites that allow you to setup a page and
change the url to something personalized.  So I'm looking for the
functionality of the routing to change:

www.mysite.com/user/232434
to
www.mysite.com/user/myhomepage

Is there a way to get the routing system to check the database?  Or
should i just not even use the routing system and query the db with
'myhomepage' instead of the user id passed in the url?

Thanks for the feedback.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: creating dynamic routing

2008-02-15 Thread Voyager2K

thanks for interesting ideas, but me now mostly liked my version :)
just add to URL "MyPages/show/" and rerun __getController();
$_GET['url'] = 'sitepages/index/'.$_GET['url'];

imho defects :

>> Router::connect('/*', array('controller' => 'MyPages', 'action' => 'show'));
>> But remember to define _before_ it a route for each controller in your app. 
>> Ex:
>> Router::connect('/users/:action/*', array('controller' => 'users'));

here me does not liked manually setting exsits controllers...

>> Or implement something like this: 
>> http://snook.ca/archives/cakephp/static_pages_cakephp12/

by logic not so good to hide controller "redirect" to error hadler...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: creating dynamic routing

2008-02-15 Thread Adam Royle

Or implement something like this: 
http://snook.ca/archives/cakephp/static_pages_cakephp12/

On Feb 15, 9:08 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> An easy way to do it is setup a catch all route:
>
> Router::connect('/*', array('controller' => 'MyPages', 'action' => 'show'));
>
> But remember to define _before_ it a route for each controller in your app. 
> Ex:
>
> Router::connect('/users/:action/*', array('controller' => 'users'));
> ...
>
> HTH,
> - Dardo Sordi.
>
> On Fri, Feb 15, 2008 at 6:52 AM, Voyager2K <[EMAIL PROTECTED]> wrote:
>
> >  Lets i post my look at this implementation:
> >  adding to dispatch one more condition if (!is_object($controller))
>
> >  dispatcher.php
>
> > function dispatch($url = null, $additionalParams = array()) {
> > if ($this->base === false) {
> > $this->base = $this->baseUrl();
> > }
> > if ($url !== null) {
> > $_GET['url'] = $url;
> > }
>
> > $url = $this->getUrl();
> > $this->here = $this->base . '/' . $url;
>
> > if ($this->cached($url)) {
> > exit();
> > }
>
> > $this->params = array_merge($this->parseParams($url),
> >  $additionalParams);
>
> > $controller = $this->__getController();
>
> > // HANDLE DB TREE
> > if (!is_object($controller)) {
> > $_GET['url'] = 'sitepages/index/'.$_GET['url'];
> > $url = $this->getUrl();
> > $this->here = $this->base . '/' . $url;
>
> > if ($this->cached($url)) {
> > exit();
> > }
> > $this->params = 
> > array_merge($this->parseParams($url),
> >  $additionalParams);
> > $controller = $this->__getController();
>
> > }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: creating dynamic routing

2008-02-15 Thread Dardo Sordi Bogado

An easy way to do it is setup a catch all route:

Router::connect('/*', array('controller' => 'MyPages', 'action' => 'show'));

But remember to define _before_ it a route for each controller in your app. Ex:

Router::connect('/users/:action/*', array('controller' => 'users'));
...

HTH,
- Dardo Sordi.

On Fri, Feb 15, 2008 at 6:52 AM, Voyager2K <[EMAIL PROTECTED]> wrote:
>
>  Lets i post my look at this implementation:
>  adding to dispatch one more condition if (!is_object($controller))
>
>  dispatcher.php
>
> function dispatch($url = null, $additionalParams = array()) {
> if ($this->base === false) {
> $this->base = $this->baseUrl();
> }
> if ($url !== null) {
> $_GET['url'] = $url;
> }
>
> $url = $this->getUrl();
> $this->here = $this->base . '/' . $url;
>
> if ($this->cached($url)) {
> exit();
> }
>
> $this->params = array_merge($this->parseParams($url),
>  $additionalParams);
>
> $controller = $this->__getController();
>
> // HANDLE DB TREE
> if (!is_object($controller)) {
> $_GET['url'] = 'sitepages/index/'.$_GET['url'];
> $url = $this->getUrl();
> $this->here = $this->base . '/' . $url;
>
> if ($this->cached($url)) {
> exit();
> }
> $this->params = array_merge($this->parseParams($url),
>  $additionalParams);
> $controller = $this->__getController();
>
>
> }
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: creating dynamic routing

2008-02-15 Thread Voyager2K

Lets i post my look at this implementation:
adding to dispatch one more condition if (!is_object($controller))

dispatcher.php

function dispatch($url = null, $additionalParams = array()) {
if ($this->base === false) {
$this->base = $this->baseUrl();
}
if ($url !== null) {
$_GET['url'] = $url;
}

$url = $this->getUrl();
$this->here = $this->base . '/' . $url;

if ($this->cached($url)) {
exit();
}

$this->params = array_merge($this->parseParams($url),
$additionalParams);

$controller = $this->__getController();

// HANDLE DB TREE
if (!is_object($controller)) {
$_GET['url'] = 'sitepages/index/'.$_GET['url'];
$url = $this->getUrl();
$this->here = $this->base . '/' . $url;

if ($this->cached($url)) {
exit();
}
$this->params = array_merge($this->parseParams($url),
$additionalParams);
$controller = $this->__getController();
}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: creating dynamic routing

2008-02-15 Thread Voyager2K

*
"fir url argument" = "first url argument"
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



creating dynamic routing

2008-02-15 Thread Voyager2K

help me create dynamic routing.

A have a DB tree structure of pages like

- page1
- page1.1
- page1.2
- page2
- page2.1

and have a MyPagesController which handle request like

/MyPages/show/page1/
or
/MyPages/show/page1/page1.2/

How can i trim URL  this format:
 /page1/
or
/page1/page1.2/

One idea i have: after bootsrap.php before dispatcher
- load MyPagesModel
- look all db trees
- formate route::connect

but i think it will be too long.

May be do something for dispatcher which call
/MyPages/show/
if not found controller name like fir url argument ?

Help me plesase.

PS. Sorry my Englsih
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---