Okay all. I'll try explain it.
I have a section on the website called Adsense this is a clone page that i have created. I have then placed into another page the code snippet. <cms:pages masterpage='adsense/index.php' > Now i want to limit this to lets say 5 adverts. Now the plan is i want to have it that they are show randomly.
The full code that goes onto pages,
KK sorted this out for me last time, bellow. and wasnt too sure if this could be done for showing random posts, so if refreshed it would change, and pick random clone pages and post the most random ones.
I have a section on the website called Adsense this is a clone page that i have created. I have then placed into another page the code snippet. <cms:pages masterpage='adsense/index.php' > Now i want to limit this to lets say 5 adverts. Now the plan is i want to have it that they are show randomly.
The full code that goes onto pages,
- Code: Select all
<cms:pages masterpage='adsense/index.php' >
<div id="tt_area">
<div id="feature_title"><a href="<cms:show adlink />" target="_blank">
<cms:excerpt count='40' truncate_chars='1'><cms:show k_page_title /></cms:excerpt></a></div>
<div id="feature_image"><img src="<cms:show ad_image />" alt="" width="90" height="80" /> </div>
<div id="feature_text"><cms:excerpt count='120' truncate_chars='1'><cms:show ad_content /></cms:excerpt></div>
</div>
</cms:pages>
KK sorted this out for me last time, bellow. and wasnt too sure if this could be done for showing random posts, so if refreshed it would change, and pick random clone pages and post the most random ones.
- Code: Select all
<cms:php>
$path_to_images = 'uploads/image/random-images/';
$count_rand = 4; // Number of random images to pick
// Valid extensions
$extensions = array( 'jpg','jpeg','gif','png','bmp' );
// Open folder and get files
$images = array();
if( $handle = opendir('<cms:show k_admin_path />' . $path_to_images) ){
while (false !== ($file = readdir($handle))) {
if( $file != "." && $file != ".." ){
$ext = strtolower( substr(strrchr($file, "."), 1) );
if( in_array($ext, $extensions) ){
$images[] = '<cms:show k_admin_link />' . $path_to_images . $file;
}
}
}
closedir($handle);
}
// Select the indicated number of random images
$count_rand = ( count($images)<$count_rand ) ? count($images) : $count_rand;
$rand_keys = array_rand( $images, $count_rand );
for( $x=0; $x<count($rand_keys); $x++ ){
echo '<img src="'.$images[$rand_keys[$x]].'" /><br/>';
}
</cms:php>