2016-05-22 45 views
0

例如,使用rainlab translate插件,我們可以有這個{{ 'translatable text'|_ }}我想在動態標題的代碼部分調用它們。如何在代碼部分運行標記部分的功能?

title = "Product" <-- I want to translate this 
url = "/product" 
layout = "default" 
== 
<section id="product-section"> 

</section> 

另一個例子是博客插件。我希望根據博客文章標題設置標題。我可以在標記部分使用{{ post.title }}

title = "Blog Title" <-- I want to put the blog title here 
url = "/blog-post/:slug" 
layout = "default" 
== 
<section id="blog-section"> 
    <h1><span>{{ post.title }}</span></h1> 
</section> 

回答

0

將此代碼放入代碼部分(當您在CMS中編輯頁面時)。

function onEnd() { 
    $this->page->title = $this['post']->title; 
} 

根據這一點,你也可以寫這樣的事情:

$this->page->title = 'My page title'; 

我現在寫這個解決方案很抱歉,但也許它可以幫助別人。