Hi
Please find the my query below. i am using to get random metakeywords from the page
Myfiles:
/code/Page.php
/code/Homepage.php
themes/<theme>/Page.ss <- my Layout template
themes/<theme>/Layout/Homepage.ss <- my template
MetaKeywords: "youtube clone, video scripting, video software
Page.php
...
class Page_Controller extends ContentController {
function RandomMetaKeywords()
{
if ($this->MetaKeywords)
$HomePageValue = $this;
else
$HomePageValue = DataObject::get_one('HomePage', '', '', '', '');
$keywords = explode(', ',$HomePageValue->MetaKeywords);
$rand_keys = array_rand($keywords,1);
$retKey = $keywords[$rand_keys];
unset($keywords);
return ($retKey);
}
}
Page.ss
...
<div>$Title</div>
$RandomMetaKeywords
$RandomMetaKeywords
<div>$Layout</div>
HomePage.ss
...
<div>$Title</div>
$RandomMetaKeywords
$RandomMetaKeywords
above my code, In Page.ss file successfully get the random values while function call but in layout file ie (HomePage.ss) it will get same value for all the function call.
output of Page.ss
youtube clone
video scripting
output of HomePage.ss
youtube clone
youtube clone
Please help to clear this issue.
Regards,
thisIsRam