UDT inside a another tag?
Posted: Wed May 23, 2007 1:34 pm
Is it possible to insert a UDT inside another tag? I've installed a multilanguage site and was having trouble changing headlines made in my template so I came up with this solution.
my urls look like this:
www.mypage.com/index.php/uk/welcome or www.mypage.com/index.php/da/velkommen
I made a UDT to get the language out of the current url like this:
UDT = current_url
This looks at my url and gets the 2 letters (uk, da) for use later.
I then put that in top of my templatebody.
Now, I had a headline for my news in my template like this:
UDT = newshead
I then inserted the {newshead} instead of news and viola... The header changes
Now here comes the tricky part and my question (at last)
I now want the news to change category when I change language, but how do I do that. I have tryid this but no can do...
I made a UDT called newscat like this:
I then tryid to insert into my template like this...
my urls look like this:
www.mypage.com/index.php/uk/welcome or www.mypage.com/index.php/da/velkommen
I made a UDT to get the language out of the current url like this:
UDT = current_url
Code: Select all
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}I then put that in top of my templatebody.
Now, I had a headline for my news in my template like this:
I have created my page in both english and danish and now wanted the "News" headline to change to the dansih language "Nyheder" when I went on the danish version of the site. This was done by making a UDT like this:
News
{news number="3" detailpage="news"}
UDT = newshead
Code: Select all
$url = selfURL();
$last_slash = strrpos($url, "/");
$temp = substr($url, 0, $last_slash);
$second_last_slash = strrpos($temp, "/");
$page = substr($url, $second_last_slash+1, $last_slash-$second_last_slash-1);
if($page == 'da') {
echo 'Nyheder'; }
if($page == 'en') {
echo 'News'; }Now here comes the tricky part and my question (at last)
I now want the news to change category when I change language, but how do I do that. I have tryid this but no can do...
I made a UDT called newscat like this:
Code: Select all
$url = selfURL();
$last_slash = strrpos($url, "/");
$temp = substr($url, 0, $last_slash);
$second_last_slash = strrpos($temp, "/");
$page = substr($url, $second_last_slash+1, $last_slash-$second_last_slash-1);
if($page == 'da') {
echo 'news_DK'; }
if($page == 'en') {
echo 'news_UK'; }but that didnt work... Can somebody please help me with this problem...{news number="3" detailpage="news" category="{newscat}"}