Yii Framework Forum: Incorrect Output For Createurl - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Incorrect Output For Createurl Page 43 of the book

#1 User is offline   jjmontgo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 29-January 14

Posted 30 January 2014 - 08:14 PM

Hi there!

I am experimenting with Yii's ability to print URL patterns from urlManager, and am frustrated to find output that differs from what I would expect.

Here are the URL patterns I am using from page 41:

'urlManager' => array(
  'urlFormat' => 'path',
  'rules' => array(
    '<alias:about>' => 'website/page',
    'page/about/<alias:authors>' => 'website/page',
    'page/<alias>' => 'website/page',

Here is my call to createUrl:

echo $this->createUrl('website/page', array('alias' => 'authors'));

And here is the output:


Given that alias is set to "authors", and not "about", I would expect it to print "/page/about/authors". Is this incorrect?

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,225
  • Joined: 17-January 09
  • Location:Russia

Posted 08 February 2014 - 04:34 PM

By default when creating URLs Yii takes parameter name into account but ignores regex. Because of that the first rule matches and is used.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users