简体   繁体   English

像Ruby on Rails一样在CodeIgniter中进行锚定

[英]Anchors in CodeIgniter like in Ruby on Rails

in Ruby on Rails i can generate links like <%= link_to 'Name', :controller => 'controller_name', :action => 'action_name' %> . 在Ruby on Rails中,我可以生成诸如<%= link_to 'Name', :controller => 'controller_name', :action => 'action_name' %> This alos works when i have changed the route for this url. 当我更改了该URL的路由时,此操作无效。

Is it possible to get something like this in CodeIgniter with the anchor when i have defined custom routes? 当我定义了自定义路由时,是否可以在CodeIgniter中获得类似anchor

I hope it is understandable ;) 我希望这是可以理解的;)

Thanks for help 感谢帮助

Depending on your codeigniter project configuration, you can create simple html links with href attribute set to /index.php/controller/action or /controller/action . 根据您的codeigniter项目配置,您可以创建简单的html链接,并将href属性设置为/index.php/controller/action/controller/action I am not sure if there are any link helpers present. 我不确定是否存在任何链接助手。

If you have custom routes set in application/config/routes.php then they won't be executed by the anchor function, you will have to extend the URL helper and redefine this function by passing your custom routes. 如果您在application / config / routes.php中设置了自定义路由,那么锚函数将不会执行它们,那么您将必须扩展URL帮助器并通过传递自定义路由来重新定义此函数。 Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM