[RC1] Easy Guide for : Get images from TS gallery

[RC1] Easy Guide for : Get images from TS gallery

Postby Admin on Sat Jun 14, 2008 8:45 pm

hi friends ,
this is the easy guide for install the Mod on the title.
It was request from some people.

The mod allow to get images from TS gallery and put them everywhere.
With everywhere we mean for example at the top or bottom of the topic pages or at the top of index page and so on ...
So for the first step you need to choose where you want to put it. For example we choose index.php page.
Note : this page have to be a php page and not a template page (html file)

Step one :
Add php function where you want :
Code: Select all
/**
*
* @package TS Gallery mod by futuresquare.net
* @fiorefrank Exp $
* @license Affero GNU Public License
*
*/

function get_gl_images($gl_imm_limit_def=3 , $ordine="random")
{

switch ($ordine)
         {
            case "random":
               $or_by = "RAND()";
            break;

            case "most_view":
               $or_by = "pic_views";
            break;

            case "time":
               $or_by = "pic_time";
            break;
         }
global $db , $template , $phpbb_root_path , $phpEx;

// for change images number from url
if(@$_GET["gl_limit"] != "") $gl_imm_limit = $_GET["gl_limit"] ;
   else $gl_imm_limit = $gl_imm_limit_def ;

/////////CONFIGURATION PART
$title_on = true; // true make title information able to be view
$nview_on = true; // true make nview information able to be view
$rate_on = true; // true make rate information able to be view
$by_on = true;  // true make by information able to be view
$comment_on = true; // true make comment link able to be view

   $sql = 'SELECT a.* , b.*
               FROM ' . GALLERY_PICS_TABLE . " AS a
      LEFT JOIN  " . GALLERY_ALBUMS_TABLE . " AS b ON (b.album_id = a.pic_album_id) 
      WHERE b.album_password = '' ORDER BY $or_by DESC LIMIT $gl_imm_limit ";
      $result = $db->sql_query($sql);
      
      

      while ($row = $db->sql_fetchrow($result))
      {   //if ($row['rate_point'] != "" ) $punteggio = $row['rate_point']; else $punteggio = "-";
         $sql_pic = 'SELECT rate_point            
               FROM ' . GALLERY_RATE_TABLE . '
               WHERE rate_pic_id = ' . $row['pic_id'] ;
         $result_pic = $db->sql_query($sql_pic);
         
         $rate = 0; $n=0;
         while ($row_pic = $db->sql_fetchrow($result_pic)){
            $rate = $rate + $row_pic['rate_point'];
            $n++;
         
         }

$sql_com = 'SELECT * FROM ' . GALLERY_COMMENT_TABLE . "
                    WHERE comment_pic_id = '" . $row['pic_id'] ."'";
         $result_com = $db->sql_query($sql_com);
         $rows_com = $db->sql_fetchrowset($result_com);
         $db->sql_freeresult($result_com);
         $num_com = count($rows_com);


         $flag = false; // di default è spento il flag per la visualizzazione delle stelle

         if ($n)   {
            $flag = true;
            $med = $rate / (2 * $n) ;
            $count = 1;
            $intero = (int) $med ;
            $non_int =  $med - $intero;
            $totale = "" ;
            while($count <= 5)
            {
            if ( ($count - $intero) > 0 )
               {
               if ( ($count - $intero) == 1 && $non_int != 0) $imm_link = "includes/arcade/images/star3.gif";
               else $imm_link = "includes/arcade/images/star2.gif";
               }
            else    {
               $imm_link = "includes/arcade/images/star1.gif";
               }

            //creo le immagini (stelline) con tag html pronte per l'utilizzo
            $totale = $totale . "<img src=". $imm_link . "  />" ;
            $count ++ ;
            }
         }
         $template->assign_block_vars("imm_galleria", array(
         'VIEW'      => "./gallery/views.php?start=0", //Image points
         //'U_LINK'      => $phpbb_root_path. "gallery/upload/cache/small_" . $row['pic_physical_filename'],
         'U_LINK'   => $phpbb_root_path. "gallery/pic.{$phpEx}?mode=small&amp;pic_id=". $row['pic_id'] ,
         'BY'      => $row['pic_username'],
         'FLAG_STAR'     => $flag,
                        'BY_ON'      => $by_on, // Flag
                        'TITLE_ON'   => $title_on, // Flag
                        'NVIEW_ON'   => $nview_on, // Flag
                        'RATE_FLAG'   => $rate_on ,
                        'TITLE'      => $row['pic_title'],
                        'N_VIEW'   => $row['pic_views'],
                        'COMMENT_ON'   => $comment_on,
                        'COMMENT_LINK'  => "gallery/viewpic.php?pic_id=" . $row['pic_id'],
                        'COMMENT_COUNT' => $num_com,
         'STAR'       => $totale,
         ));
      }
      $db->sql_freeresult($result);
}
get_gl_images(3 , "most_view") ;


Step two :
Well . The function added in the step one is the fuction that make everything possible.
Now look at the last line get_gl_images(3 , "most_view") ;

you can mod it using for example :
get_gl_images(3 , "random") ; <--- random pics
get_gl_images(3 , "time"); <-- recent pics


It's time to mod the template.
The template file is the HTML file that is associated to the php page.
For example if we are using index.php of phpbb board we have to mod the index_body.html file
So open your template file associated to the php page and deverything at step 3
Note : if you don't know what is your html file just open the php fiel and find
Code: Select all
$template->set_filenames(array(

Read the html file after that code.

Step three :
Into template you have to add this :

Prosilver theme :
Code: Select all
<br>
<div class="forabg" align="center">
   <div class="inner">
      <span class="corners-top"><span></span></span>
         <h4 class="titlemenu" style="color:#FFFF00"><em>--- From Albums</em>> ---</h4>
   <div class="navbar" style="font-size:12px;">
   <br />   


   <table ><TR>
   <!-- BEGIN imm_galleria -->
   <TD class="gallery-pics-td">
   <div >
      <div align="center" >
      <a href="{imm_galleria.VIEW}"> <img style="float:left" src="{imm_galleria.U_LINK}" alt="{imm_galleria.TITOLO}" /></a>
      </div>
      <hr />
      <!-- IF imm_galleria.FLAG_STAR -->
         <div align="center">{imm_galleria.STAR}</div>
      <!-- ENDIF -->
      <!-- IF imm_galleria.BY_ON --><div>by {imm_galleria.BY} </div> <!-- ENDIF -->
<!-- IF imm_galleria.TITLE_ON --><div>Title : {imm_galleria.TITLE} </div><!-- ENDIF -->
<!-- IF imm_galleria.NVIEW_ON --><div>View : {imm_galleria.N_VIEW} times</div><!-- ENDIF -->
<!-- IF imm_galleria.COMMENT_ON --><div> <a href="{imm_galleria.COMMENT_LINK}"> Comments ( {imm_galleria.COMMENT_COUNT} )</a></div><!-- ENDIF -->
         
   </div>
   </TD>
   <!-- END imm_galleria -->
   </TR></table>

   <a class="icon-register" href="http://www.futuresquare.net">By futuresquare.net</a>
   </div>
      <span class="corners-bottom"><span></span></span>
   </div>
</div>

Subsilver theme
Code: Select all
<br>
<div class="forabg" align="center">
   <div class="inner">
      <span class="corners-top"><span></span></span>
   <div class="navbar" style="font-size:12px;">
    <table class="tablebg" width="100%" cellspacing="{$CA_SPACING}">
      {$CA_CAP_START}<a href="./gallery/menu.php">--- From Albums ---</a>{$CA_CAP_END}
      <tr>
        <td class="row1" width="100%"><span class="genmed">
    </span><table width="100%" align="center" >
      <tr>
       <!-- BEGIN imm_galleria -->
       <td align="center" width="{S_COL_WIDTH}" class="row1"> <span class="genmed">
          <p align="center"><a href="{imm_galleria.VIEW}"> <img src="{imm_galleria.U_LINK}" alt="{imm_galleria.TITOLO}" align="middle" vspace="10" /></a><br />
              </div>
          </p>           
          <p>&nbsp;</p>
          <!-- IF imm_galleria.FLAG_STAR -->
               <div align="center">
               <hr width="200" />
               <p>{imm_galleria.STAR}</p>
             </div>
          <!-- ENDIF -->
          <div>by {imm_galleria.BY} </div>         
       </div>   </TD>
       <!-- END imm_galleria -->
      </tr></table>
    <br />    </td>
      </tr>
      </table>

   <a class="icon-register" href="http://www.futuresquare.net">By futuresquare.net</a>
   </div>
      <span class="corners-bottom"><span></span></span>
   </div>
</div>


Some suggestions, questions or requests are welcome!
Online demo is here : http://www.futuresquare.net
For help maybe i'm here http://www.futuresquare.net/chat/
we don't see things like they are but we see them like we are
User avatar
Admin
Site Admin
Site Admin
 
Posts: 113
Joined: Wed Mar 05, 2008 6:31 am
Location: Internet
Highscores: 6

google adsense
Google
 

Return to MOD Reviews

Who is online

Users browsing this forum: No registered users and 0 guests

cron