diff options
author | tof <> | 2007-08-27 07:16:27 +0000 |
---|---|---|
committer | tof <> | 2007-08-27 07:16:27 +0000 |
commit | 7e884b51284e83b1604c9d029d3845e77e76d802 (patch) | |
tree | 050c205b14adef43b14d8970a13ea4ff4a8a3a1b /demos/blog-tutorial/protected/layout | |
parent | 37508534ac227c4e39ba8e9eb417d559a7bf0f3e (diff) |
Add Internationalization to Blog-Tutorial
Diffstat (limited to 'demos/blog-tutorial/protected/layout')
-rw-r--r-- | demos/blog-tutorial/protected/layout/MainLayout.php | 25 | ||||
-rw-r--r-- | demos/blog-tutorial/protected/layout/MainLayout.tpl | 12 |
2 files changed, 35 insertions, 2 deletions
diff --git a/demos/blog-tutorial/protected/layout/MainLayout.php b/demos/blog-tutorial/protected/layout/MainLayout.php index 253d6c03..4b5890de 100644 --- a/demos/blog-tutorial/protected/layout/MainLayout.php +++ b/demos/blog-tutorial/protected/layout/MainLayout.php @@ -1,7 +1,30 @@ <?php
class MainLayout extends TTemplateControl
-{
+{ + + public function onLoad($param) + { + parent::onLoad($param); + + $this->languages->DataSource = TPropertyValue::ensureArray($this->Application->Parameters['languages']); + $this->languages->dataBind(); + } + + public function languageLinkCreated($sender, $param) + { + $item = $param->Item; + if($item->ItemType == TListItemType::Item || $item->ItemType == TListItemType::AlternatingItem) + { + $params = $this->Request->toArray(); + $params['lang'] = $sender->DataKeys[$item->ItemIndex]; + unset($params[$this->Request->ServiceID]); + $url = $this->Service->ConstructUrl($this->Service->RequestedPagePath, $params); + $item->link->NavigateUrl = $url; + if($this->Application->Globalization->Culture == $params['lang']) + $item->link->CssClass="active"; + } + }
}
?>
\ No newline at end of file diff --git a/demos/blog-tutorial/protected/layout/MainLayout.tpl b/demos/blog-tutorial/protected/layout/MainLayout.tpl index 1ee83bae..f2bc1f96 100644 --- a/demos/blog-tutorial/protected/layout/MainLayout.tpl +++ b/demos/blog-tutorial/protected/layout/MainLayout.tpl @@ -24,7 +24,17 @@ <com:TopicList ID="TopicPanel" />
</td>
<td valign="top">
-
+<com:TRepeater ID="languages" OnItemCreated="languageLinkCreated"> + <prop:HeaderTemplate> + <div class="languages">Available Languages: <ul> + </prop:HeaderTemplate> + <prop:ItemTemplate> + <li><com:THyperLink ID="link" Text=<%# $this->DataItem %> /></li> + </prop:ItemTemplate> + <prop:FooterTemplate> + </ul></div> + </prop:FooterTemplate> +</com:TRepeater>
<div id="content">
<com:TContentPlaceHolder ID="Main" />
</div>
|