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...
Sorry, in the default.php there is a value 110 for the location of each "Panel->AddString" item. If you make that a smaller value it will weigh less and appear higher up in the Sidepanel.
now youre talking... that worked, thanks! I can't seem to get it to appear above the "start new discussion" link, even tried using negatives, but oh well its good enough for me! :)
Wont do images. You would have to modify the code at the bottom of the file as well. Might run into issues (as far as formatting?), cause your wanting to inlcude html files, allowing a possibility for malicious code to be run.
if (in_array($Context->SelfUrl, array('index.php', 'categories.php', 'search.php', 'account.php'))) { } is your friend ;) Lots of duplicated code there...
But, the code I had in comment #12 above was done to give flexibility of putting different images on different pages. If you don't need or want that, the use sirlancelot's suggestion.
Comments
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Posted: Thursday, 14 June 2007 at 1:44PM
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •<?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);
}
?>
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Any ideas how to point to another folder? That may contain subfolders?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •// 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...
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I added the lines
$extList['html'] = 'text/html';
$extList['htm'] = 'text/html';
but it just seems to ignore the .htm file
Any help would be appreciated
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •its good to know that even if i have questions about older projects, i will still get a reply.
keep up the good work, and have a most excellent day
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •if (in_array($Context->SelfUrl, array('index.php', 'categories.php', 'search.php', 'account.php'))) { }is your friend ;) Lots of duplicated code there...- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •