-
AuthorPosts
-
October 1, 2010 at 10:05 am #154812
Hi Folks,
maybe these problem is solved somewhere, but I doesn’t found the answer by searching this forum.
You know that in Purity II the header images rotate by a random generator. Now I won’t this. I’ve 2 categories on my homepage and I want Image1 by clicking on Menulink1 and Image2 by clicking on Menulink2.
Is this possible?
Thanks
DamonWilderDon Lee FriendDon Lee
- Join date:
- March 2010
- Posts:
- 923
- Downloads:
- 0
- Uploads:
- 13
- Thanks:
- 41
- Thanked:
- 274 times in 238 posts
October 8, 2010 at 8:52 am #358193<em>@damonwilder 196333 wrote:</em><blockquote>Hi Folks,
maybe these problem is solved somewhere, but I doesn’t found the answer by searching this forum.
You know that in Purity II the header images rotate by a random generator. Now I won’t this. I’ve 2 categories on my homepage and I want Image1 by clicking on Menulink1 and Image2 by clicking on Menulink2.
Is this possible?
Thanks
DamonWilder</blockquote>Hi,
What’s about header image as you mentioned? Did you mean it’s menu image?January 28, 2011 at 12:30 pm #374242Hi,
I mean following images: […]/templates/ja_purity_ii/images/header/header[1-3].jpg
This 3 images should not change randomly, but by the categories. For Example: Klick on tab#1 -> image1; Klick on tab#2 -> image2, and so on.Many thanx for your answers.
Would be nice, if this could work.Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
January 31, 2011 at 1:58 am #374517Yes, mate!
Presently, header images are displayed in the random way. You can try the following to complete your idea
1) open the templates/ja_purity_ii/libs/ja.templates.helper.php and find the following code:
[PHP]
function getRandomImage ($img_folder) {
if (!is_dir ($img_folder)) return ”;
$imglist=array();mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi(“gif”, $file) || eregi(“jpg”, $file) || eregi(“png”, $file))
$imglist[] = $file;
}
closedir($imgs->handle);if(!count($imglist)) return ”;
//generate a random number between 0 and the number of images
$random = mt_rand(0, count($imglist)-1);
$image = $imglist[$random];return $image;
}
[/PHP]replace:[PHP]
function getRandomImage ($img_folder) {
if (!is_dir ($img_folder)) return ”;
$imglist=array();mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
$itemID = (int)JRequest::getVar(‘Itemid’,0);
//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi(“gif”, $file) || eregi(“jpg”, $file) || eregi(“png”, $file))
$imglist[] = $file;
if( $file == ‘header-‘.$itemID.’.jpg’ ){
closedir($imgs->handle);
return $file;
}
}
closedir($imgs->handle);if(!count($imglist)) return ”;
//generate a random number between 0 and the number of images
$random = mt_rand(0, count($imglist)-1);
$image = $imglist[$random];return $image;
}[/PHP]when done,
rename your images in this format:
header-+ValueOf ItemId+”.jpg”
1 user says Thank You to Saguaros for this useful post
September 5, 2011 at 11:32 am #410736Since this thread is already 8 months old, the posted idea doesnt work any more for the newest version.
The solution seems to be simple by replacing the “rand(1,3)”-php command in head.php, but i don’t know how to insert the ID of the current category instead.
Could someone tell me, which php-variable contains the category-ID ?
/templates/ja_purity_ii/blocks/head.php
#ja-header .main {
background-image: url(<?php echo T3Path::getUrl('/images/header/header'. rand(1,3).'.jpg'); ?>);
}
Thanks in advance 🙂
jooservices Friendjooservices
- Join date:
- October 2014
- Posts:
- 8556
- Downloads:
- 0
- Uploads:
- 130
- Thanked:
- 1245 times in 1121 posts
September 5, 2011 at 11:35 am #410737Hi
Please make new thread for another issue . It could help us easier for maintaince and follow up.
Thank you
Viet Vu -
AuthorPosts
This topic contains 6 replies, has 5 voices, and was last updated by jooservices 13 years, 3 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum