I'm learning Kohana 3.2.0 together with KSmarty for Kohana 3. I'd like to write an anchor on the page like this:
<a href="http://www.mysite.cz/page/list">Page list</a>
I can build the url in the controller and pass it to Smarty as a variable but. Is there a way to build the anchor or URL in Smarty template (including "http://www.mysite.cz" part)?
If it is not possible to build the anchor. Is it at least possible to build full URL?
The Reason: I have a main template which includes another template. The main template will be used by multiple controllers and I would like to avoid building the URL in each controller. Therefore I'll be happy if KSmarty will be able to do it for me.
The only solution I have found is to write custom function. Save following code into function.url.php file in Smarty plugins directory:
Examples of use in Smarty template:
The first block in which variables are set I had to write otherwise Smarty was generating notice "Undefined variable...". I'm just PHP student, suggestions for code improvement are welcome.
Hope it will help the others.