Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Sidepanel Rotator

KrakKrak New
edited November 2006 in Questions
This discussion is related to the Sidepanel Rotator addon.
Sidepanel Rotator

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
  • 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! :)
  • I am trying to add a little panorama into the rotator as a .htm with hotspots, but it doesn't seem to work.

    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
  • 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.
  • thank you very much for the comment...

    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
  • Re: Sidepanel Rotator # 12

    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.
This discussion has been closed.