Wednesday, August 29, 2012

Re: CakePHP 2 and hyphens on the router

@Sophistry: tried that, no changes.

@AD7six: as stated also before, I have this route too, but nothing changes: 
Router::connect('/my-controller/', array('controller' => 'my_controller', 'action'=>'index')); 

I tried to remove default routes or to change the order but no success, I think this is not a clean thing to do with cake!

MN



On Wed, Aug 29, 2012 at 3:56 PM, AD7six <andydawson76@gmail.com> wrote:
3rd time lucky perhaps.

Router::connect('/my-controller/:action/*' <-

This can only possibly generate a url of the form "/x/y/" or "/x/y/etc."

Routes are not magic - they do what they say, and what your route says is "include the action in the url", so it does.

AD


On Tuesday, 28 August 2012 09:20:39 UTC+2, Mohammad Naghavi wrote:
@Salines: I read the page twice and didn't get any point about why having this routing rule:
Router::connect('/my-controller/:action/*', array('controller' => 'my_controller'));
will result in producing urls with /index at the end, instead of simply producing ones with nothing at the end.

@lowpass: thanks anyway.

Rgards,
Mohammad



On Mon, Aug 27, 2012 at 8:21 PM, lowpass <zijn.d...@gmail.com> wrote:
Sorry, I can't help. I never use the ":action" placeholder in routes
so I'm not clear on what the issue could be. I prefer to specify all
the possible routes. There shouldn't be any trouble with updating
Cake's libs unless there is a big change in how routing is done.

On Mon, Aug 27, 2012 at 9:47 AM, Mohammad Naghavi <moha...@gmail.com> wrote:
> Hi again,
> so I defined the routing approach but now I have a new problem. I have
> defined this routing rule in app/Config/routes.php:
> Router::connect('/my-controller/:action/*', array('controller' =>
> 'my_controller'));
>
> and in my view, I have a link like this:
> <?php echo $this->Html->link('some title',
> array('controller'=>'my_controller', 'action'=>'index')) ?>
>
> the output is:
> <a href="/mapp/my-controller/index">some title</a>
>
> it has a new /index there! and I tried to remove it by adding this route:
> Router::connect('/my-controller/', array('controller' => 'my_controller',
> 'action'=>'index'));
>
> but it changes nothing!
> and the worst is that pointing the browser to /mapp/my-controller/ does not
> go to index but shows the error page that says the My-controllerController
> has to be created!
> any Idea how to solve this new problem?
>
> Regards,
> Mohammad
>
>
> On Sun, Aug 26, 2012 at 12:00 PM, Mohammad Naghavi <moha...@gmail.com>

> wrote:
>>
>> ok thanks to know. no it is not so bad, I just want to keep myself out of
>> the way where updates to cake's core can immobilize my program in future.
>>
>> any way thanks again too much.
>>
>>
>> On Sun, Aug 26, 2012 at 3:39 AM, lowpass <zijn.d...@gmail.com> wrote:
>>>
>>> I understand now. No, you cannot customise this; the underscore is
>>> hard-coded. See Inflector::humanize() and Inflector::underscore() (in
>>> the Utility directory of the libs).
>>>
>>> But is it so bad to have to create routes?
>>>
>>> On Sat, Aug 25, 2012 at 11:14 AM, Mohammad Naghavi <moha...@gmail.com>

>>> wrote:
>>> > thanks for the response it works, however I have to define a routing
>>> > rule
>>> > per controller. but this is not a need in case I use underscores, I
>>> > meant if
>>> > there is a way to automate hyphens also like underscores?
>>> >
>>> > regards,
>>> > Mohammad
>>> > ________________________________________
>>> > PHP & ASP .Net 3.5 web developer
>>> > Java & C# desktop developer
>>> > www.mohamnag.com
>>> >
>>> >
>>> >
>>> > On Sat, Aug 25, 2012 at 12:19 PM, Salines <nikola....@gmail.com>

>>> > wrote:
>>> >>
>>> >>
>>> >>> I mean for example the following has to generate a valid URL to
>>> >>> MyController:
>>> >>> $this->Html->link('some title',
>>> >>> array('controller'=>'my-controller'));
>>> >>>
>>> >>> but what I get is an error that says the My-controller has to be
>>> >>> created.
>>> >>> i.e. it does not recognize the existing MyController. can it be done
>>> >>> in
>>> >>> behaviour?
>>> >>
>>> >>
>>> >> in the your view.ctp
>>> >>
>>> >>  $this->Html->link('some title', array('controller'=>'MyController',
>>> >> 'action'=>'view', $id);
>>> >>
>>> >> in the app/Config/routes.php
>>> >>
>>> >> Router::connect('/my-controller/show-my-favorites/*',
>>> >> array('controller'
>>> >> => 'MyController', 'action' => 'view'));
>>> >>
>>> >>
>>> >> Output links like
>>> >>
>>> >> <a href="/my-controller/show-my-favorites/19">some title</a>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> >> Groups
>>> >> "CakePHP" group.
>>> >> To post to this group, send email to cake...@googlegroups.com.

>>> >> To unsubscribe from this group, send email to
>>> >> cake-php+u...@googlegroups.com.

>>> >> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "CakePHP" group.
>>> > To post to this group, send email to cake...@googlegroups.com.

>>> > To unsubscribe from this group, send email to
>>> > cake-php+u...@googlegroups.com.

>>> > Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>> >
>>> >
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "CakePHP" group.
>>> To post to this group, send email to cake...@googlegroups.com.

>>> To unsubscribe from this group, send email to
>>> cake-php+u...@googlegroups.com.

>>> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>>
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com.

> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com.

> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.

--
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 cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

--
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 cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: