我正在用codeigniter重写我的网站,并有一些我想做的事情,但不确定这是可能的。
我的网站上有一个由flickr api支持的库。下面是我用来显示风景图片的代码示例:
<?php foreach ($landscapes->photoset->photo as $l->photoset->photo) : ?>
<a href="<?=$l->photoset->photo->farm?>/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id?>/<?=$l->photoset->photo->secret?>/<?=$l->photoset->photo->title?>">
<img class="f_thumb" src="<?=$l->photoset->photo->farm?>.static.flickr.com/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id ?>_<?=$l->photoset->photo->secret ?>_s.jpg" title="<?=$l->photoset->photo->title?>" alt="<?=$l->photoset->photo->title?>" />
</a>
<?php endforeach; ?>
如您所见,当用户单击图片时,我使用uri段传递farm、server、id、secret和title元素,并使用
$data['farm'] = $this->uri->segment(3);
$data['server'] = $this->uri->segment(4);
$data['id'] = $this->uri->segment(5);
$data['secret'] = $this->uri->segment(6);
$data['title'] = $this->uri->segment(7);
一切正常,但网址有点长。例子:
http://localhost:8888/wip/index.php/gallery/focus/3/2682/4368875046/e8f97f61d9/Old_Mill_House_in_Donegal
是否有方法重写URL,使其更像:
http://localhost:8888/wip/index.php/gallery/focus/Old_Mill_House_in_Donegal
我在考虑使用:
$url_title = $this->uri->segment(7);
$url_title = url_title($url_title, 'underscore', TRUE);
但我似乎无法让它工作。有什么想法吗?