Home · sNews Development · [ADD-ON] galleries WIP

cms-zen dot com

online web development :: art and design :: fun stuff
best-budd
sNews Development cms road trip PHP Scripts Photoshop Guides Css Guides Music and video clips Art Gallery Low Light Photography Impression Photography

sNews 17 released

NEW: sNewsCMS v1.7 Release has been made available for download.
Get it while it's hot!

[ADD-ON] galleries WIP

this is a WIP Gallery addon, maybe will turn into a mod,
i have added below the first part of the script with comments,
and a link to download package with all file needed.
 

UPDATE: 16/07/2008

alian plant.jpg

alian plant.jpg
550 X 550

bird.jpg

bird.jpg
550 X 550

sunbath.jpg

sunbath.jpg
550 X 450

shout.jpg

shout.jpg
500 X 500

burned.jpg

burned.jpg
550 X 462

potato.jpg

potato.jpg
550 X 501

jons.jpg

jons.jpg
562 X 480

velvet.jpg

velvet.jpg
550 X 501



Thank you Vasile for advise with latest fix.
 


  <?php
 
/**
   *    Easy Galleries Script ::
   *    @ Moshe Gil Lemberger
   *    July 09 2008 ::
   *    email: mymgl@yahoo.com
   *    website: http://www.cms-zen.com
   
   *   FIX: code updated 16/07/08
   *   thank you vasile for advise 
   *   http://moriscanet.blogspot.com/
   */
   
// TAG TO CALL THE GALLERY
easyGal('gallery-dir','your-galleries-root-path','y','ibox');    

// easyGal function
function easyGal$gsef$groot=''$rel=''$styl='' ) {
    global 
$errors;
    
//////////////////////////////////
    # $gsef => name for gallery directory
    
$galName $gsef.'/';
    
# $tumbs => name for tumbs directory
    
$tumbs 'tumbs/';
    
# $larg => name for pictures source directory    
    
$larg 'larg/';
    
# $groot => name for ROOT galleries directory [ contain all galleries ]     , relation to document location
    
    //// 16/07/08 FIX: galleries_root closing slash was added to code.
    //// NOTE: No need for the closing slash in function parameter, 
    ////         just the name for your galleries_root.
    //// end FIX 16/07/08.
    
$galleries_root $groot!='' $groot.'/' "galleries_root/";
    
    
# $rel => Set this for PREV - NEXT link option (  'y' or empty ) 
    
$rel $rel!='y' 'lightbox' 'lightbox['.$gsef.']';
    
    
$gallery=$galleries_root.$galName;
    
$tumbdir=$gallery.$tumbs;
    
$largdir=$gallery.$larg;
    
      if (
is_dir($tumbdir)) {
          
$fd opendir($tumbdir);  
          
$images = array(); 
          while ((
$part = @readdir($fd)) == true) {  
              
clearstatcache();
              if ( 
eregi("(gif|jpg|png|jpeg)$",$part) ) {
                  
$images[] = $part
                } 
            }    
    
# here we echo the javascript and css for the gallery
    
echo '
            <script type="text/javascript" src="js/mootools.js"></script> 
            <script type="text/javascript" src="js/slimbox.js"></script>
            <link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />
            <link rel="stylesheet" href="css/ibox.css" type="text/css" media="screen" />
            <script type="text/javascript" src="js/egfx.js"></script>
        '
;
    
# end js
    
        
$so=sizeof($images);
        for (
$x=0$x<$so$x++) {
            
$imgName=$images[$x];
            
$tumbsrc $tumbdir.$imgName;
            
$imgsrc$largdir.$imgName;    
            
$title=$imgName;
            
$title=eregi_replace("(-|_)",' ',$title);
            list(
$width,$height)=getimagesize($imgsrc);
            echo 
'<div class="'.$styl.'">';
                echo 
'<a href="'.$imgsrc.'" rel="'.$rel.'" title="'.$title.'">';
                    echo 
'<img src="'.$tumbsrc.'" alt="'.$title.'" />';
                echo 
'</a>';        
            echo 
'<p><span>'.$title.'</span><br/>';
                echo 
$width .' X  '$height;
            echo 
'</p>';
            echo 
'</div>';
        }
    } else { 
            
$errors[] = $tumbdir.' is not a directory'
            return 
false
            } 
}
//////
    
?>  <?php
   
/*    
    USE: 
        copy files in css, js directories to your server ( corresponding dir )
        include this script ( will work on any php page or cms )
        
        - make ROOT directory for all your galleries,
                # ( Preset in the function as "galleries_root/" )
                # can be set as option in function parameters.
                # can be set different root for any call to the script.
                
        - inside the ROOT, 
                for each gallery you need a directory.
                    # this will be used as the first parameter in function call.
                
                inside, make 2 sub directories, 
                1 to hold the tumbs and 1 to hold the larg pictures,
                #(   Preset in the function as 'tumbs/'  and  'larg/'  ).
                # can be set as option in function parameters.
        
        call the function where ever you want to display the gallery.
        easyGal( 'GALLERY DIR NAME' , 'ROOT GALLERIES DIR' ,  ENTER 'y' OR LEAVE EMPTY , 'THE TUMB DIV STYLE/S (i use tag ibox )' )
        
        for include within the text area of article, use:
        [MOD] Function use in articles (snews1.6)  by philmoz.  location: http://snewscms.com/forum/index.php?topic=4583.0
    */
    
?>  

***  Download package here
this package packed with the mootools and slimbox js lib

09.07.2008. 15:31

moshe on 12.07.2008. 20:47

hey Nicu Alecu :)
thank you.

Nicu Alecu on 12.07.2008. 20:30

Great job! bothe with the pics and with the add-on.

moshe on 12.07.2008. 17:06

hello from tel-aviv,
good to see you brother Sven :)

Vasile, if you have any problem with the script let me know.

awesome day my friends

funlw65 on 11.07.2008. 18:57

Thank you Moshe, downloaded!
Awesome day!

Philippe/Sven on 11.07.2008. 18:14

Hello from Paris to brothers Mo and Vasile.

moshe on 10.07.2008. 11:05

hey vasi, thank you :)
i will update very soon
with the script and how to use.

awesome day

funlw65 on 10.07.2008. 03:13

Moshe,
This looks great! I like it very much.

Write a comment

* = required field

:

:

:


4 + 5 =