Welcome Guest, Not a member yet? Register   Sign In
URI Language Identifier and paths
#1

[eluser]turco[/eluser]
I'm using URI Language Identifier to build up a multilanguage website. English is the default language. The url of the homepage is, let's say, something similar to

Code:
www.website.com/en/

In the homepage there is a set of categories of products, each of them linked to the page with the relative list. For example

Code:
www.website.com/en/objects/catalog/3.html

To achieve that this is the html:

Code:
<a href="objects/catalog/&lt;?= $id ?&gt;.html">&lt;?= $category ?&gt;</a>

It works fine. But if I want to copy the same list of categories in internal pages, I have a problem of path. In fact previous html code tends to add the query string to the current one, that is great in the homepage, but doesn't work in internal page
In other hand, if I try with

Code:
<a href="/objects/catalog/&lt;?= $id ?&gt;.html">&lt;?= $category ?&gt;</a>

or

Code:
<a href="../../objects/catalog/&lt;?= $id ?&gt;.html">&lt;?= $category ?&gt;</a>

I have other different problem. The only solution I've found it's

Code:
<a >config->item('language'), $this->config->item('lang_uri_abbr')) ?&gt;/objects/catalog/&lt;?= $id ?&gt;.html">&lt;?= $category ?&gt;</a>

But it's annoying to repeat for every link. Any suggestion?
#2

[eluser]dag[/eluser]
i would suggest using the url helper for generating links
Code:
<a href="php site_url('controller/method') php">link</a>

if you then need some additional informations for the link url you can just
overwrite the site_url function by putting a url_helper.php in your application/helpers
directory which implements the desired functionality..

Code:
function site_url($str)
{
   $CI =& get_instance();
    //retrieve your language key etc
    $lang = ...
   return $CI->config->site_url($lang . $uri);
}




Theme © iAndrew 2016 - Forum software by © MyBB