Author Topic: Newest images - List Only?  (Read 5743 times)

0 Members and 1 Guest are viewing this topic.

Offline MoshinInvader

  • Newbie
  • *
  • Posts: 14
    • View Profile
Newest images - List Only?
« on: October 22, 2011, 07:43:41 PM »
Hi,

Has anyone ever done this -- or does anyone know how?  I've been trying to make a way of outputting a simple text list of the newest images but I'm not having any luck.  I've tried reusing some of the code in the index.php file, and I also tried using...

http://www.4homepages.de/forum/index.php?topic=1179.msg5288#msg5288

...but I'm still dead in the water! (Mostly because I'm not too familiar with php & sql, yet.)  All I am shooting for is a vertical list like this...

ht tp://mydomain.com/my4imagesgallery/data/thumbnails/10/apples.jpg
ht tp://mydomain.com/my4imagesgallery/data/thumbnails/12/oranges.jpg
ht tp://mydomain.com/my4imagesgallery/data/thumbnails/19/peaches.jpg
ht tp://mydomain.com/my4imagesgallery/data/thumbnails/24/pears.jpg

...and so on. Is there a simple way to do this? Any help VERY MUCH APPRECIATED! :)

Thanks

Rembrandt

  • Guest
Re: Newest images - List Only?
« Reply #1 on: October 22, 2011, 09:14:48 PM »
Hi!

search in your Templates/home.html "{whos_online}" and insert above ,or where ever you want:
Code: [Select]
                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="head1" valign="top">{lang_new_images}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                    <tr>
                      <td class="head1">{last_upload}</td>
                    </tr>
                  </table>
                  <br />

search in index.php:

//-----------------------------------------------------
//--- Print Out ---------------------------------------

insert above:

//###################################### End Mod Last Upload #################################################
$last_upload_num ="100"// number e.g. 1,2,3,10,15,20,50,100,500... e.t.c
 
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").") 
        ORDER BY i.image_date DESC
       LIMIT 
$last_upload_num";
$result $site_db->query($sql);

  
$last_upload "<table style=\"width:".$config['image_table_width']."; border-style:none;\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"summary=\"new thumbs\">";
  
$last_upload .= "<tr class=\"imagerow2\">\n";
  
$last_upload .= "<td  class=\"head\"style=\"width:5%;text-align:center; \"><b>Nr.:</b></td>\n";
  
$last_upload .= "<td  class=\"head\"><b>".$lang['image_name']."</b></td>\n";

  
$last_upload .= "</tr>\n";
  
$count 0;
  
$bgcounter 0;
  
$rank 1;

  while (
$image_row2 $site_db->fetch_array($result)){
    
$row_bg_number = ($bgcounter++ % == 0) ? 2;
    
$last_upload .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    
$last_upload .= "<td  style=\"width:5%;text-align:center; \">".$rank++."</td>\n"
    
$last_upload .= "<td><a href=\"".$script_url."/".THUMB_DIR."/".$image_row2['cat_id']."/".$image_row2['image_media_file']."\">".$script_url."/".THUMB_DIR."/".$image_row2['cat_id']."/".$image_row2['image_media_file']."</a></td>\n";

    
$count++;
    if (
$count == $comments_num) {
      
$last_upload .= "</tr>\n";
      
$count 0;
    }
  } 
// end while
  
  
if ($count 0)  {
    
$leftover = ($comments_num $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$last_upload .= "<td style=\"width:".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$last_upload .= "</tr>\n";
    }
  }
  
$last_upload .= "</table>\n";

$site_template->register_vars("last_upload"$last_upload);
unset(
$last_upload);
//###################################### End Last Upload #################################################


i hope this is what you want...

mfg Andi

Offline MoshinInvader

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Newest images - List Only?
« Reply #2 on: October 22, 2011, 10:51:43 PM »
Hi Rembrandt... and thanks.

If I'm reading your code correctly, what you've demonstrated is pretty much what I have and what the gallery already does very nicely. Outputting formatted HTML. What I was after was sort of a utility php script that, when called, simply outputs a bare, raw ascii text list of the newest images.  I've been successful at a fair amount of tweaks and changes to my gallery but -- for whatever reason -- I haven't yet figured out how to make a simple script that does away the the html for a bare bones text list display of the newest pics...  I'm such a n00b! HAHA

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Newest images - List Only?
« Reply #3 on: October 23, 2011, 07:49:07 AM »
Upload attached file to your 4images root directory
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline MoshinInvader

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Newest images - List Only?
« Reply #4 on: October 26, 2011, 06:10:44 PM »
Upload attached file to your 4images root directory

Thanks V@no...  Reading your code, this is exactly what I've been trying to do. My attempts at the script were very similar to yours.  However, I'm still having problems. The script does not error -- but it does not echo anything, just a blank white page. The source of the page is blank as well -- same thing my scripts were doing.

I entered the $path as required. (i.e., "ht tp://mydom/mygallery/")
The 'ROOT_PATH' is... define('ROOT_PATH', './');   ...same as it is in my RSS.php (and everywhere else)
I can't seem to find anything else that looks like it should be edited. My 4images installation (v. 1.7.7) is pretty much default - no major mods. That's why I'm left scratching my head why this doesn't display.
Is there anything else I might need to edit?

Thanks V@no!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Newest images - List Only?
« Reply #5 on: October 26, 2011, 08:15:26 PM »
The mysql query I used shows only images available for guests. Try remove these two lines and see if it show you anything:
Code: [Select]
AND c.auth_viewcat=".AUTH_ALL." /*only categories accessible for guests*/
AND c.auth_viewimage=".AUTH_ALL." /*only images accessible for guests*/
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline MoshinInvader

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Newest images - List Only?
« Reply #6 on: October 28, 2011, 05:26:18 PM »
The mysql query I used shows only images available for guests. Try remove these two lines and see if it show you anything:
Code: [Select]
AND c.auth_viewcat=".AUTH_ALL." /*only categories accessible for guests*/
AND c.auth_viewimage=".AUTH_ALL." /*only images accessible for guests*/


MOST EXCELLENT!!  That did it!!

I thought that specifying "guest" was the right way to approach this, but removing it took care of the problem. In hindsight however, my gallery FULLSIZE views are restricted, login is required for FULLSIZE.  I didn't notice before, but since the script(s) are fetching from the IMAGES_TABLE, is that what was causing the blank return?

Also, the output was returning...

   ht tp://mydom/mygallery/ht tp://mydom/mygallery/data/media/...(etc)

...so I changed the path back to "/" and that took care of that.  And also changed MEDIA_DIR to THUMB_DIR for lists of the smallers pics.

This is working really well. Do you think I would be able to apply this same method to a custom search script? This will be VERY HANDY.  THANKS a TON V@no!!!  :)