Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 03:05:20 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155533 Posts in 21713 Topics by 7739 Members
Latest Member: audillino
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Display list of Images in Random Order on each view of the Page  (Read 602 times)
sky writer

Offline Offline

Posts: 285



« on: January 27, 2010, 02:35:53 AM »

I have a business links page on a site and I want it to randomly order the links vertically each time the page is displayed so the same business link is not always on top (or bottom).  I thought I could do this with anynews (which I am already using for news page), but it requires a title, and I don't have any title or text accompanying the link images.

Am I not seeing the trees for the forest here?  I figured this would be a simple task, but can't seem to find the answer.
Logged
sky writer

Offline Offline

Posts: 285



« Reply #1 on: January 27, 2010, 03:43:50 AM »

Okay, so I created a new "Group" for the links and using the anynews module, I have isolated that group to display on my links page.  Almost there... but...

Is there a way to have different headers for different instances of anynews calls?  My main anynews displays the top five news storied on all pages with a TXT_HEADER of "Latest News".
displayNewsItems(array(6,7,8,9,11), 5, -1, 1, auto, false, '<p><a><img>', false, 3, 1, 0);
But I want the links page anynews display to have a Header that reads "MEMBER LINKS"

Is this possible?

Here is my current anynews custom_output_displ ay_mode_3.htt file:
<div class="anynews">
<h2>{TXT_HEADER}</h2>

<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
{CONTENT_SHORT}
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<hr />
<!-- END news_block -->
</div>
Logged
doc
Guest
« Reply #2 on: January 27, 2010, 07:07:05 AM »

Hi,

one possibility is to use different custom templates for different "main" Anynews calls.
You can alter the display mode (4th Parameter) to use different custom template files. How this works is explained in the README distributed with Anynews.

Doc
Logged
sky writer

Offline Offline

Posts: 285



« Reply #3 on: January 27, 2010, 03:13:03 PM »

Doc,

Thank you so much.  I have read those readme files a hundred times, but I never understood what the Custom Template section was for, or how to implement it.  Your brief reply brought it all into focus for me.  How perfect.  I appreciate your time and contribution.

Cheers,
Sky
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #4 on: January 27, 2010, 04:55:43 PM »

Hi,

I use this droplet for gallery, it randomly shoows list of images:

Code:
$folder=opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$dir.'/.');
$names = array();
while ($file = readdir($folder))  {
    $ext=strtolower(substr($file,-4));
    if ($ext==".jpg"||$ext==".gif"||$ext==".png"){
        $names[count($names)] = $file;
    }
}
closedir($folder);
reset(shuffle($names));
array_unshift($names," ");
if(isset($width)){$width=' width="'.$width.'"';}else{$width="";}
if(isset($height)){$height=' height="'.$height.'"';}else{$height="";}
$count=1;

while(($image=next($names))and(($count<=$num)or(!isset($num)))){

if( $count ==1){$class=' class="active"';}else{$class='';}

$name=substr($image,0,-4);
if($link=="y"){$images=$images.'<a href="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/'.$image.'" target=_blank>';}
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/'.$dir.'/thumbs/'.$image.'.thumb.jpg')){
$images=$images.'<img src="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/thumbs/'.$image.'.thumb.jpg" alt="'.$name.'" '.$width.$height.'/>';
}else{
$images=$images.' <li><img src="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/'.$image.'" alt="'.$name.'" '.$width.$height.$class.' /></li>';
}
if($link=="y"){$images=$images.'</a>';}
$count++;
}

return '<div class="YOURCLASS"><ul id="ADDIFANY">'.$images.'</ul></div>';

You can name it RandomGallery or anyway you want, and call it with [[RandomGallery?folder_in_media_fol der]]
It will generate the list like:

Code:
<div class="YOURCLASS">
  <ul id="ADDIFANY">
     <li><img src="http://www.yoursite.xy/media/subfolder/image2.jpg" alt="image2"  class="active" /></li>
     <li><img src="http://www.yoursite.xy/media/subfolder/image1.jpg" alt="image1"  /></li>
     <li><img src="http://www.yoursite.xy/media/subfolder/image3.jpg" alt="image3"  /></li>
 </ul>
</div>
Every refresh order 1,2,3 will be random (in my case I had 3 images)

Also you can restyle your list with css..
« Last Edit: January 27, 2010, 05:02:42 PM by crnogorac081 » Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
sky writer

Offline Offline

Posts: 285



« Reply #5 on: January 27, 2010, 06:10:41 PM »

Thanks for the variation.  For my purposes, the anynews module and DOC's guidance about custom templates works best, as I do have some business links which are mixed text and graphics, or straight text.

Glad to see others trying to provide options, though.

Cheers!
Logged
doc
Guest
« Reply #6 on: January 27, 2010, 06:14:30 PM »

Hi,

Quote from: sky writer
Thanks for the variation.  For my purposes, the anynews module and DOC's guidance about custom templates works best, as I do have some business links which are mixed text and graphics, or straight text.
Nice to read that you get it working for your purposes with the options provided by the module itself.

Doc
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!