21492 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 413 Views |
-
widgets with page translations

23 June 2011 at 4:04am
When using the code below for a widget in a site with translations,
the widget for a page in one language will be shared across all translated pages - this means that when on a translated page the widget possibly links to a page not in the same locale
is there any known fix for this?
class LinkWidget extends Widget
{
static $db = array(
'LinkPage' => 'Text',
);static $has_one = array(
'LinkToSiteTree' => 'SiteTree',
);
function LinkToPage(){
$strURL = '';
if (isset($this->LinkToSiteTreeID) && is_numeric($this->LinkToSiteTreeID)){
$page = DataObject::get_by_id('SiteTree',$this->LinkToSiteTreeID);
if ($page){
$strURL = $this->BaseHref().$page->RelativeLink();
}
}
return $strURL;
}
}//template
<a href="{$LinkToPage}"></a>
However each widget will link to the page one page in one language. for example, if I had a site with 2 translation (English and German) if i add a widget to a English page linking it to another English page, then the German translation of this page will also have that widget with the same image as the engliah page and it will link to the english page instead of the translated German page.
-
Re: widgets with page translations

29 June 2011 at 2:54am Last edited: 29 June 2011 4:50am
Let me rephrase this.
Is there anyway to have different widgets on each translation of a page?
Rarther than each translation of a page to have the same widgets no matter which language it is.
Thanks
| 413 Views | ||
|
Page:
1
|
Go to Top |

