Create Links

2018-07-12 10:38:35
tengfei
739
Last edited by tengfei on 2019-09-16 14:11:15

Because zentaoPHP has two request types, so try not to spell the code of the link manually to create links when generating links.  Call the createLink method provided by the system to generate links.


1. $this->createLink()

Let's say we will create a link for the view method of the blog module and pass a parameter id=17. You should call it as shown below,


echo $this->createLink('blog', 'view', 'id=17&cat=123')


The first parameter is the module name, the second parameter is the method name, the third parameter is the parameter, and the key1=value1&key2=value2 is used to pass the parameters.


If the request type is PATH_INFO,  the link created is blog-view-17-123.html. If it is GET, the link is m=blog&f=view&id=17&cat=123&t=html.


2. helper::createLink()

The $this->createLink () method can be directly invoked in control and view. If you want to call it elsewhere, you can use helper:: createLink (), the parameters are the same.


3. createLink() in js

zentaoPHP also has a JS version of the createLink ()  to generate links when interacting with JS. Refer to the definition in app/demo/www/js/my.js for specific codes.

However, before calling the JS version of createLink (), you have to call js:: exportVars () to output the configuration parameters of the current system.


Write a Comment
Comment will be posted after it is reviewed.