Yii Framework Forum: urlManager makes all images disappear when creating a rule - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

urlManager makes all images disappear when creating a rule Rate Topic: -----

#1 User is offline   YIINewBy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 11-September 09
  • Location:Pretoria, South Africa

Posted 15 May 2010 - 03:04 PM

I tried to implement urlManager Component, now my problem is that whenever I call this all my images on the page don't show, If I disable it it shows again

Without rewrite my URL looks as follows

index.php?r=images/load&cid=1


with urlManager it looks like this below, whenever this is called all the images on my page disappear :-(

gallery/category/1



My urlManager rules

'urlManager'=>array(
                    'urlFormat'=>'path',
                    'showScriptName'=>false,
                    'rules'=>
                        'gallery/category/<cid:\d+>'=>'images/
                    ),
                ),


I'm completely lost, since images disappear, but cid can be read. Any help I would appreciatte. Thanks
0

#2 User is offline   mintao 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 02-December 09
  • Location:Munich, Germany

Posted 15 May 2010 - 05:50 PM

Is the syntax error in your rule a copy/paste issue?
'gallery/category/<cid:\d+>'=>'images/

0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 May 2010 - 03:52 AM

If your image looks like

<img src="img/button.gif" />


and your page URI was /gallery/category/1, your image will get requested from /gallery/category/1/img/button.gif which is obviously not what you want. To avoid that, you need to supply an absolute URI to your image ('/' + baseUrl + image path). You can use the bu() method from here:

http://www.yiiframew...oc/cookbook/31/

My image tags usually look like this:
<img src="<?php bu('img/button.gif') ?>" />

1

#4 User is offline   YIINewBy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 11-September 09
  • Location:Pretoria, South Africa

Posted 17 May 2010 - 01:56 AM

View PostMike, on 16 May 2010 - 03:52 AM, said:

If your image looks like

<img src="img/button.gif" />


and your page URI was /gallery/category/1, your image will get requested from /gallery/category/1/img/button.gif which is obviously not what you want. To avoid that, you need to supply an absolute URI to your image ('/' + baseUrl + image path). You can use the bu() method from here:

http://www.yiiframew...oc/cookbook/31/

My image tags usually look like this:
<img src="<?php bu('img/button.gif') ?>" />




Thanks, that worked
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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