3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 873 Views |
-
Random Function not working ss File

15 November 2009 at 2:14am
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 templateMetaKeywords: "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
$RandomMetaKeywordsabove 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 scriptingoutput of HomePage.ss
youtube clone
youtube clonePlease help to clear this issue.
Regards,
thisIsRam
| 873 Views | ||
|
Page:
1
|
Go to Top |

