I'm running Kohana 3 (latest) and I don't know how to handle links in my views. For example. My base url is http://localhost/foo/. I have a menu like and this menu is shared between bar and baz page:
If i'm in my home page, my links are:
These links are in the same. If i click into bar link, for example the my links will be something like:
What's wrong? How should i handle urls?
The simplest way would be to use:
This will make a relative URL, including the base_path and index.php (if it's enabled, ofc).
You can also use
Route::url() to produce the same thing using a route.
Route::url('route_name', array('id' => $id));
This doesn't concern views only but all sitelinks.
Also you can use Kohana's Html::anchor() method:
echo HTML::anchor('bar', 'Bar');
You could also just include
<base> tag in your
<head>, something like this:
<head> ... <base href="<?php echo url::base(); ?>" /> ... </head>
With this inside your view, every link you use will be relative to
<base> not to the current address. This way
<a href="bar">Bar</a> will always be pointing to
http://localhost/foo/bar no matter on which page you use it.