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 )
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
you will then see include($file); above it add this code
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 :
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 :
after the closed </div> to in-foot add this code above it
(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
Edit to your liking and enjoy this mod
ScreenShot(s):
example no files
All the Best,
Baraka Aka 1Only
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 )
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)
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>
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):
example no files
All the Best,
Baraka Aka 1Only