Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Sidepanel Rotator

KrakKrak New
edited November 2006 in Vanilla 1.0 Help
Sidepanel Rotator
«1

Comments

  • How do you make the image clickable?
  • Cant. All it does is randomly display an image from the specified folder. Thats it just a random image, not really an ad rotator.
  • wouldn't it be great if you could though...any thoughts? Or is that completely impossible
  • 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?
  • Either way it would be useful. Not only for ads, but images that you could then have enlarged, or other information.
  • 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.
  • Not hard at all, lots of sample scripts on the web, both in JavaScript and PHP.

    Posted: Thursday, 14 June 2007 at 1:44PM

  • 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.
  • Sadly sorry I can't be of much help with this. Not the best Java and PHP, but I appreciate the interest in the subject.
  • @Krak: I had some time and made an extension based upon yours. Here it is:
    <?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); } ?>
  • I get the following when pasting in your code:

    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.
  • Hmm..still getting an error...shouldn't it be SidepanelRotator rather than SidepanelImage?

    Any ideas how to point to another folder? That may contain subfolders?
  • 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.

    What is it that you want to do?
  • 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...
  • I think that could be done in the rotator.php script included in Krak's add-on by making it recurse sub-directories.
  • How can I choose where on the side panel this is displayed? I would like it to be higher up in the order then it is.
  • There is probably something in there for SIDEPANEL_POSTITION. Make it a smaller number to move up.
  • in where? i cant find that in any of the files
This discussion has been closed.