• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Random Images Plugin Mod

Baraka

Chevereto Member
Well i thought i should start to share mod(s) and all with you all, i coded this pretty late sorry if the code is sh**ty

Guide lines -

No database needed at all supports 2.0.9 +
Requires Danny.Domb's [Unofficial] Very Simple Plugin System (http://chevereto.com/forums/topic940-unofficial-very-simple-plugin-system.html) with minor modifications (i'll include)
(thanks Danny.Domb :D)
You must code your own set of css/html for the ul/li for custom skin users sorry (but for default users your in luck)

1. After you've set up Danny.Domb's system go back into the chevereto.php in the includes dir and find
Code:
foreach (glob(__CHV_PATH_MODS__."*.php") as $file)
you will then see include($file); above it add this code

Code:
define('__CHV_PATH_THEME__', __CHV_PATH_THEMES__.$config['theme'].'/');
    define('__CHV_URL_THEME__', absolute_to_url(__CHV_PATH_THEME__))

Reasons for so the with the mod executes it'll have these defined for the exact path then a path like C:\ etc , makes it easier :)

2. open your favorite text editor and paste this code :

Code:
<?php

/*============================================================*/
/********** IMAGE RAMDOMS By Baraka Aka 1Only ****************/
/*********** BARAKADESIGNS © COPYRIGHT 2011 *****************/
/*=========================================================*/ 
  function imgRandoms($where='' ,$extensions = 'jpg|png|gif'){
   //Error Box
   $baraka_errorbox_s = '<div style="background: #FFCECE; border-color:#DF8F8F; color: #665252;width:auto;margin:0 auto;padding: 0; -moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-khtml-border-radius:5px;font: 9pt arial, helvetica, sans-serif; font-weight: bold; padding: 1em; text-align: center;border: 1px solid;font-size: 13px;">';
   $baraka_errorbox = '</div>';
   $toggle= false; 
   if(!$toggle) {
   $where = trim($where);
   //$where = __CHV_PATH_THEME__.'FOLDER_NAME';  // Here You can make a folder of your choice and add images to display from the `DIR` MUST be put in your THEME folder
   $where = __CHV_ROOT_DIR__.'images'; // Gets The Folder Path To Where The Images Are Located/uploaded to change to your prefs
   $limit = 4; // Allow Me To Set Limits To How Many Images To Display Randomally 
      if (!isset($_SESSION['randoms'])) {
      //Allow Me to Check Your Selected `DIR`
      if(is_dir($where)) {
      if($dir = opendir($where)) {
       // Allow Me To Scan Your Selected `DIR` For The Amount Of Images
      while (($file = readdir($dir)) !== false) { 
      // Allow Me To Check Your Dir's File Extention
            if (!preg_match('/^\.+$/', $file) and 
                preg_match('/\.('.$extensions.')$/', $file)){
              // Allow Me To Give The Array Some Food 
                $files[] = $file;    
            }  
      }
       // Allow Me To Close Your Selected DIR
      closedir($dir);
      }
      else { // Allow Me To See If This `DIR` Exist, If Not Then The Below Message Will Display
      die($baraka_errorbox_s."Opps! Could not open the your folder called '{$where}'".$baraka_errorbox);
           }
      }
       // This Allows Me To See If There Are No Images In The `DIR` , If There Is This Message Will Be Ignored :) 
      if (count($files) == 0){
        die($baraka_errorbox_s."Opps! No files where found in your folder called '{$where}' :-(".$baraka_errorbox);
       }
    
     // This Allows Me To Count
    $rand = rand(0, count($files)-1);
 
    // Allow Me Make Sure The Array(); Isn't Fishy >.>
    if (!isset($files[$rand])){
     die($baraka_errorbox_s."Array for Image 'Randoms' wasn\'t either found or it\'s invaild :( ".$baraka_errorbox);
    }
       
      shuffle($files);
      $_SESSION['randoms'] = array_chunk($files,$limit);
      }
      $limits = 1;
      $files[] = $file;
      $randoms =& $_SESSION['randoms'];
      // This Allows Me To Count
      $total = count($randoms);
      $files[] = $file;
      if (isset($randoms[$limits-1] )) {
      $files = $randoms[$limits-1];
      $i = 0;
      foreach($files as $image) {
      // Since The Above Where Will Echo Out The Folder Location as /home/public_html/ or C:\xampp\htdocs etc\ I'll Go Ahead And Change The
      // Path To Where Themes Are Because Chevereto Understands That Theme Path Is Important
     // $where=__CHV_URL_THEME__.'FOLDER_NAME/';      
      $where=__CHV_URL_THEME__.'../../../images/thumbs/'; // for thumbnails set to your own prefs
      $link= '?v=';
      $display .= "\t\t<li><a href='{$link}{$image}'><img width='117' height='93' src=\"{$where}{$image}\" /></a></li>\n";
      $i++;
      }
      print_r($display);
        } 
      } else {
       die($baraka_errorbox_s."Opps! The Photo Stream is Currently Unavailable At This Time".$baraka_errorbox);
       }
   }

?>

and name it Random.php

3. Take Random.php and upload it to content/mods

4. To display it you'll need to edit either the footer.php or where/what ever you wish to display the images, in this case we'll edit the footer.php , To which your theme is ex Peafowl go to content/themes/Peafowl and open up footer.php
(as stated above i'm not going to include the css/html part for custom skins its pretty simple and not needed for default skin users and not sure for custom skin users so hell with it)
Find :
Code:
<div id="in-foot">

after the closed </div> to in-foot add this code above it

Code:
        <div id="RandomPhotos">
                    <ul>
                    <?php $random1 = array_rand(imgRandoms($where));?>
                    </ul>
                   </div>
(RandomPhotos id css is not included as it wasn't needed but you may add your own to your liking ;))


then save it and you should be good to go :)

Notes: if you changed your uploads `DIR` from the config file you must edit the code above to your prefs to the folder, you also don't even have to use the uploads folder with in your theme just make a new folder to what ever you like and add some images in it and from the line //$where = __CHV_PATH_THEME__.'FOLDER_NAME'; change FOLDER_NAME to your folder name you just made :). You can also disable the mod from the variable $toggle, true for disable, false for on ;), it have a mini error system.

This also allows for extension outputs so that only images display nothing more ;)

Also include limits to how many images should display :) at line code
Code:
$limit = 4;

Edit to your liking and enjoy this mod :)

ScreenShot(s):
dejcnz.png

example no files
IrzPsi.png



All the Best,
Baraka Aka 1Only
 
Danny.Domb said:
Nice ;) I'm happy to know I didn't coded Very Simple Plugin for nothing ;)

hehhhe :p, i'm happy you did make it, i'm planing to make more plugins with it, easy to use and work with :)
 
Thanks to Danny.Domb for his awesome mod called "[Unofficial] Modifications Manager" now making mods are even better and easier.

First you must install Danny.Domb's `Modifications Manager` from here: http://chevereto.com/forums/topic1194-unofficial-modifications-manager.html

note this still requires [Unofficial] Very Simple Plugin System which is included with his `Modifications Manager`

Once installed download this .xml
Download:
Code:
http://www.mediafire.com/?uq0wpbdag4aj8ox

Install:
take the downloaded .xml and place it in the dir called content/xml.
Then on your browser's address bar type your site in following /mods.php and type your password once done find and
click `Simple Plugin System` to install if you haven't installed Danny.Domb's `Simple Plugin System` . if you have ignore this and move on and find and click `Random Images Plugin Mod` to install ;)
Note for custom skin users step one may fail as results to changes made on your skin its not recommended you install this unless you make changes for to the .xml and make it port to your skin as this is meant for default skin users via Peafowl
More documentation is listed in the mod's manager under Random Images Plugin Mod -> Documentation -> view enjoy :)
 
Hi,

I just installed your mod and it works fine but I would like to create a new folder "random" at the root of my website with only a script inside to see random image (with the image url too). How can I do that ?

Here, it works on the footer but I don't know how create a new page on which we see only a random image + url.
 
My site get's white when I try to install this mod..I've installed Danny.Domb's without errors. I'm a bit confused though, maybe I'm the one doing it wrong, but should it look like this?

Code:
/*** Include the mods ***/
foreach (glob(__CHV_PATH_MODS__."*.php") as $file)
{
define('__CHV_PATH_THEME__', __CHV_PATH_THEMES__.$config['theme'].'/');
    define('__CHV_URL_THEME__', absolute_to_url(__CHV_PATH_THEME__))
    include($file);
}
 
feral, the defines should not be inside the foreach(){} add it after or before...

Also each functions needs a ; at the end, so if you check your second define, it doesnt have it, so php wont compile the script, that is why you have your blank screen.

PHP:
/*** Include the mods ***/
define('__CHV_PATH_THEME__', __CHV_PATH_THEMES__.$config['theme'].'/');
define('__CHV_URL_THEME__', absolute_to_url(__CHV_PATH_THEME__));
foreach (glob(__CHV_PATH_MODS__."*.php") as $file)
{
    include($file);
}
 
Danny.Domb said:
feral, the defines should not be inside the foreach(){} add it after or before...

Also each functions needs a ; at the end, so if you check your second define, it doesnt have it, so php wont compile the script, that is why you have your blank screen.

PHP:
/*** Include the mods ***/
define('__CHV_PATH_THEME__', __CHV_PATH_THEMES__.$config['theme'].'/');
define('__CHV_URL_THEME__', absolute_to_url(__CHV_PATH_THEME__));
foreach (glob(__CHV_PATH_MODS__."*.php") as $file)
{
    include($file);
}

Worked, but did'nt fit with my current design. :/ Thanks for your help!
 
Danny.Domb's `Modifications Manager`is not working i guess anymore (404 not found on his download page)

Any suggestion Baraka ?
Thanks for sharing the mod(s) though
 
Back
Top