I imagine you could, but not with this extension. I haven't really dug into it. I made this up in about 15 minutes when someone asked for something similar. I just used someone elses existing code for randomizing images and slapped it into Vanilla extension format.
This should actually probable be renamed to Sidepanel Image Randomizer or something the like.
If you just wanted to make the image link to the same thing every time (i.e. not a different link for each image) it should be pretty easy shouldnt it?
I would think a static link with different images wouldn't be hard. How many people want a random image with the same link? I always figured they were asking for random ad images with different links. Which shouldnt be too hard either, thats just not what this does.
Maybe I'll look into it and make some changes.
Yes, basically what I've done is to create a text file with the image filename followed by the actual link you want it to go to as a comma-delimited file. You can then read it into an array an do a random sort I think. Get the info and display.
Warning: fopen(extensions/SidepanelImage//imglinks.txt) [function.fopen]: failed to open stream: No such file or directory in /home/skubeco/public_html/friends/extensions/SidepanelRotator/default.php on line 16
Sorry, I had an extra / in the SIDEPANEL_PATH definition. The following is correct: define('SIDEPANEL_PATH', 'extensions/SidepanelImage'); and I edited the post with the entire extension code.
The code should also be in it's own folder with the style and image files and imglinks.txt. I didn't want to make a new extension unless Krak thought that would be best.
Let's look at what this does. It looks for a file containing an image name and it's link. For example, sample1.jpg,http://www.cnn.com This information allows the code to put the "a href" tag around the image. That is what I thought the original request was. You must have a different idea since you are talking about folders and sub-folders. This code is a separate add-on from Krak's.
Ah. I didn't see that small comment (sorry): // read in image names and links (for example, sample1.jpg,http://www.cnn.com) Ideally, I would like to have a random image in Side Panel selected from a main directory of my choosing. However, this main directory would also have several sub-folders each with images. Clicking the small image in Panel would enlarge the image (i.e. Thickbox).
I think I can figure out how to do the enlarging (now that I understand your 'make clickable' example). So I guess the tricky part is randomly picking a different folder/sub-folder with image thing...
Comments
Posted: Thursday, 14 June 2007 at 1:44PM
<?php /* Extension Name: Sidepanel Image Extension Url: http://lussumo.com/addons/ Description: Adds a rotating image with a link in the side panel Version: 1.0.0 Author: Justin Haury Author Url: http://mymindisgoing.com/ */ if (!defined('IN_VANILLA')) exit(); AddConfigurationSetting($Context, 'SIDEPANEL_IMAGE_VERSION', '1.0.0'); // Set the version number. define('SIDEPANEL_PATH', 'extensions/SidepanelImage'); $imgname = ""; $imglink = ""; // read in image names and links (for example, sample1.jpg,http://www.cnn.com) $fp = fopen(SIDEPANEL_PATH.'/imglinks.txt', 'rb'); if(!$fp) return; $i = 0; while ($row = fgetcsv($fp, 1000)) { list($images[$i], $links[$i]) = $row; $i++; } fclose($fp); // And then randomly choose one $pos = mt_rand(0, $i - 1 ); $imgname = $images[$pos]; $imglink = $links[$pos]; // if ($Context->SelfUrl == "index.php" ) { $Head->AddStyleSheet(SIDEPANEL_PATH.'/style.css'); $Panel->AddString(" <ul id=\"Banner\"> <li class=\"BannerImage\"><a href=\"$imglink\"><img src=\"extensions/SidepanelImage/$imgname\" class=\"center\"/></a></li> </ul>", 1); } elseif ($Context->SelfUrl == "categories.php" ) { $Head->AddStyleSheet(SIDEPANEL_PATH.'/style.css'); $Panel->AddString(" <ul id=\"Banner\"> <li class=\"BannerImage\"><a href=\"$imglink\"><img src=\"extensions/SidepanelImage/$imgname\" class=\"center\"/></a></li> </ul>", 1); } elseif ($Context->SelfUrl == "search.php" ) { $Head->AddStyleSheet(SIDEPANEL_PATH.'/style.css'); $Panel->AddString(" <ul id=\"Banner\"> <li class=\"BannerImage\"><a href=\"$imglink\"><img src=\"extensions/SidepanelImage/$imgname\" class=\"center\"/></a></li> </ul>", 1); } elseif ($Context->SelfUrl == "account.php" ) { $Head->AddStyleSheet(SIDEPANEL_PATH.'/style.css'); $Panel->AddString(" <ul id=\"Banner\"> <li class=\"BannerImage\"><a href=\"$imglink\"><img src=\"extensions/SidepanelImage/$imgname\" class=\"center\"/></a></li> </ul>", 1); } ?>
Warning: fopen(extensions/SidepanelImage//imglinks.txt) [function.fopen]: failed to open stream: No such file or directory in /home/skubeco/public_html/friends/extensions/SidepanelRotator/default.php on line 16
define('SIDEPANEL_PATH', 'extensions/SidepanelImage');
and I edited the post with the entire extension code.
The code should also be in it's own folder with the style and image files and imglinks.txt. I didn't want to make a new extension unless Krak thought that would be best.
Any ideas how to point to another folder? That may contain subfolders?
sample1.jpg,http://www.cnn.com
This information allows the code to put the "a href" tag around the image. That is what I thought the original request was. You must have a different idea since you are talking about folders and sub-folders. This code is a separate add-on from Krak's.
What is it that you want to do?
// read in image names and links (for example, sample1.jpg,http://www.cnn.com)
Ideally, I would like to have a random image in Side Panel selected from a main directory of my choosing. However, this main directory would also have several sub-folders each with images. Clicking the small image in Panel would enlarge the image (i.e. Thickbox).
I think I can figure out how to do the enlarging (now that I understand your 'make clickable' example). So I guess the tricky part is randomly picking a different folder/sub-folder with image thing...