But other links like /pages/display/about gave me 404 error as it routes to 
posts controller not pages controller.

Thanks


On Friday, January 3, 2014 10:07:23 PM UTC+2, Stephen S wrote:
>
> The link you gave me is done a little differently to how you are doing it 
> now, all the post is introducing is a new method to parse the route itself.
>
> Normally you may have something like /posts/view/slug which may be public 
> function view($slug = null), then you may execute a query to find the first 
> post record which contained that exact slug and load the results into an 
> array. Mark is doing a similar search in his actual custom route file, 
> caching it, then passing that information to the controller so it doesn't 
> have to do that. He doesn't appear to mention the issue you are having, 
> unless I missed it, I'm afraid.
>
> Try this for me and see if it helps
>
> Router::connect(
>     "/members/:plugin/:controller",
>     array('action' => 'index', 'prefix' => members, members => true)
> );
> Router::connect(
>     "/members/:plugin/:controller/:action/*",
>     array('prefix' => members, members => true)
> );
> Router::connect(
>     "/members/:controller",
>     array('action' => 'index', 'prefix' => members, members => true)
> );
> Router::connect(
>     "/members/:controller/:action/*",
>     array('prefix' => members, members => true)
> );
> Router::connect('/*', array('controller' => 'posts', 'action' => 'view'));
>
> Then try to access /post-slug and /members/users/login and see what 
> happens.
>
>
> On 3 January 2014 19:31, gonzela2006 <[email protected] <javascript:>>wrote:
>
>> Hi Stephen,
>>
>> s members a prefix, or do you have a users method with login parameter, 
>>> or do you have that as a custom route?
>>
>> Yes, members is a prefix but the problem also exists with urls without 
>> prefix like /pages/display/about
>>
>> I found a post on Mark Story's blog that is talking about my problem but 
>> it was for CakePHP 1.3 how can I use it with CakePHP 2?
>>
>> http://mark-story.com/posts/view/using-custom-route-classes-in-cakephp
>>
>> Thanks
>>
>>
>> On Friday, January 3, 2014 9:16:58 PM UTC+2, Stephen S wrote:
>>
>>>  A few things come to my mind off the top off my head.
>>>
>>> You could route your controller-action url's first, to catch the actual 
>>> links such as /members/users/login (is members a prefix, or do you have a 
>>> users method with login parameter, or do you have that as a custom route?)
>>>
>>> Then providing you did those routes correctly, the bottom route would 
>>> catch anything that didn't match the earlier ones, hopefully your post slug.
>>>
>>> Another idea would be to use a regular expression to match the pattern 
>>> of a "post-slug", if there are any distinguishing features this would be 
>>> much more effective. If not I would recommend doing something like this:
>>>
>>> /posts/post-slug
>>> /blog/post-slug
>>> /keyword/post-slug (i.e. if I was writing on a health care blog, I would 
>>> use /health/post-slug. This could produce something like 
>>> /health/top-10-diet-tips which holds the keyword health as well as the 
>>> slug.)
>>>
>>> It would be easier to avoid issues if you did it this way.
>>>
>>> HTH
>>>
>>> -- 
>>> Kind Regards
>>>  Stephen Speakman
>>>  
>>  -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Kind Regards
>  Stephen Speakman
>  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to