Author Topic: [REQUEST] Script that Lists New Content  (Read 7607 times)

0 Members and 1 Guest are viewing this topic.

Offline Jmartz

  • Pre-Newbie
  • Posts: 5
    • View Profile
[REQUEST] Script that Lists New Content
« on: June 10, 2003, 06:06:23 AM »
I appologize if I missed this during my search.  But I am looking for a mod or some code that will allow me to by category, list new items.  Now, I would like them to be in list format, without thumbnails, and one per line, seperated by category.  I would also like the ability to tell the software how many days worth of new content this script should list.

How I plan to implement something if it is ever developed:

I would like to be able to place this list in a popup window that opens when the person first views the site.  I already have the code that allows me to do this, and I currently have the popup point to the "New Images" page, which just shows a huge list of Thumbnails, and it has the login form and everything on the side.

If possible, I would like to just display this list, and not the login form and all of the other content that is displayed on the "New Images" page.

Does anyone know if this is possible? And if a MOD doesn't already exist, would someone be willing to create it?  Because I think it could be a nice feature.  It would also be nice if there was a way to list all the categories without the thumbnails as well... (user preference).

Thanks in advance for your help,
Jeff

Offline PuCK

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.acidarts.net
[REQUEST] Script that Lists New Content
« Reply #1 on: June 10, 2003, 10:23:45 AM »
I made something like this using a mod a found here:

Jus make a new file named new.php or something and javascript open a new window without borders e.d. Don't know how to make it open first time only...

Change the lay-out yourself, I used a stylesheet of it's own...

Code: [Select]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="ltr">
<head>
<title>acidarts.tracker</title>
<link rel="stylesheet" href="./templates/acidarts/stylenews.css" />
</head>
<body bgcolor="#fff">
<div id='tableHeight' style="position:relative;width:100%;">
<table width="150" class="newsborder" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="head">last weeks photos:</td>
</tr>
<tr>
<td class="row2">
<?php
define
&#40;'ROOT_PATH', './'&#41;; 
include&#40;ROOT_PATH.'global.php'&#41;; 
require&#40;ROOT_PATH.'includes/sessions.php'&#41;; 
$user_access get_permission&#40;&#41;; 
$cat_id_sql get_auth_cat_sql&#40;"auth_viewcat", "NOTIN"&#41;;
$number_of_new_pics 5;
$days_to_be_new 7;

$new_cutoff time&#40;&#41; - 60 * 60 * 24 * $days_to_be_new; 
$cat_id_sql get_auth_cat_sql&#40;"auth_viewcat", "NOTIN"&#41;;

    
$sql "SELECT MAX&#40;cat_id&#41; as max_id FROM ".CATEGORIES_TABLE
    
$row $site_db->query_firstrow&#40;$sql&#41;; 
    
$cat_max_id = &#40;!empty&#40;$row['max_id'&#93;&#41;&#41; ? $row['max_id'&#93; &#58; 0;

for &#40;$i = 0; $i <= $cat_max_id; $i++&#41;&#123; 

   
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name 
          FROM "
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i"
   
$result $site_db->query&#40;$sql&#41;; 
   
$row $site_db->fetch_array&#40;$result&#41;; 
   
$images_in_category $site_db->get_numrows&#40;$result&#41;; 
   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$category_id = &#40;$row['cat_id'&#93;&#41;; 
   
$category_link = &#40;"<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">"&#41;; 

if &#40;$images_in_category&#41; &#123; echo "<div class=\"clickstream row1\"><b>$images_in_category</b> new photos in $category_link<b>$category_name</b></a> &#58;</div>"; &#125;  

  
$sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name 
          FROM "
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c 
          LEFT JOIN "
.USERS_TABLE." u ON u.user_id = i.user_id 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i 
          ORDER BY i.image_date DESC 
          LIMIT 
$number_of_new_pics"

   
$result $site_db->query&#40;$sql&#41;; 
   
while &#40;$row = $site_db->fetch_array&#40;$result&#41;&#41; &#123; 
   
$image_name = &#40;$row['image_name'&#93;&#41;; 
   
$image_id = &#40;$row['image_id'&#93;&#41;; 
   
$category_name = &#40;$row['cat_name'&#93;&#41;; 
   
$user_name = &#40;$row['user_name'&#93;&#41;; 
   
$media_path = &#40;$row['image_media_file'&#93;&#41;; 
   
$image_date format_date&#40;$config['date_format'&#93;." ".$config['time_format'&#93;,$row['image_date'&#93;&#41;;  
   
$image_link = &#40;"<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">"&#41;; 
   
$allnew_link = &#40;"<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">"&#41;; 

   
echo "$image_link<b>$image_name</b></a><br />";
   
// - $image_date<br />"; 
  
&#125; 
&#125;
if &#40;$image_name == ""&#41; &#123;
 echo "No new photos last 7 days.<br />";
&
#125;
  
echo "</td></tr><tr><td class=\"row1\" align=\"right\"><a href=\"search.php?search_new_images=1\">All new images</a>
  "

?>

</td>
</tr>
</table>
</div>
</body>
</html>

Offline Jmartz

  • Pre-Newbie
  • Posts: 5
    • View Profile
[REQUEST] Script that Lists New Content
« Reply #2 on: June 10, 2003, 03:09:14 PM »
Thanks for the reply.  But last night, my SQL database corrupted so I might have to do a reinstall.  I will let you know if I have any luck with the code you provided.

Thanks again!!

Offline Ted

  • Pre-Newbie
  • Posts: 2
    • View Profile
[REQUEST] Script that Lists New Content
« Reply #3 on: June 15, 2003, 07:13:40 PM »
it works very well.

however is there away that it would just display

"no new images"

or if there are new images

"3 new images" (i.e how ever many there are regardless of categories)
view all new images

thanks  :D

Offline renicolay

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: [REQUEST] Script that Lists New Content
« Reply #4 on: June 12, 2005, 08:02:04 PM »
I like the posted MOD, but there were a few errors on the previous post.  I am not a PHP coder, but I seemed to have it working now after some fixes.  Although I am having problems in the sort order.  I would like the parent category in alpha order.  Can anyone help?

Code: [Select]
<?php
define
('ROOT_PATH''./'); 
include(
ROOT_PATH.'global.php'); 
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission(); 
$cat_id_sql get_auth_cat_sql("auth_viewcat""NOTIN");
$number_of_new_pics 25;
$days_to_be_new 30;

$new_cutoff time() - 60 60 24 $days_to_be_new
$cat_id_sql get_auth_cat_sql("auth_viewcat""NOTIN");

    $sql "SELECT MAX(cat_id) as max_id FROM ".CATEGORIES_TABLE
    $row $site_db->query_firstrow($sql); 
    $cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;

for (
$i 0$i <= $cat_max_id$i++){ 

   $sql "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, c.cat_id
          FROM "
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i
          ORDER BY c.cat_id"
;
   $result $site_db->query($sql); 
   $row $site_db->fetch_array($result); 
   $images_in_category $site_db->get_numrows($result); 
   $category_name = ($row['cat_name']); 
   $category_id = ($row['cat_id']); 
   $category_link = ("<a href=\"" ROOT_PATH "categories.php?cat_id=" $category_id "\">"); 

if (
$images_in_category) { echo "<br /><table border=\"0\"><tr><td class=\"row1\" width=\"300\" height=\"30\">Category: $category_link<b>$category_name</b></a> <b>$images_in_category</b>  new file(s):</td></tr>"; }  

  $sql 
"SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name 
          FROM "
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c 
          LEFT JOIN "
.USERS_TABLE." u ON u.user_id = i.user_id 
          WHERE i.image_active = 1 AND i.image_date >= 
$new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i 
          ORDER BY "
.$config['image_order']." ".$config['image_sort']."
          LIMIT 
$number_of_new_pics"

   $result $site_db->query($sql); 
   while ($row $site_db->fetch_array($result)) { 
   $image_name = ($row['image_name']); 
   $image_id = ($row['image_id']); 
   $category_name = ($row['cat_name']); 
   $user_name = ($row['user_name']); 
   $media_path = ($row['image_media_file']); 
   $image_date format_date($config['date_format']." ".$config['time_format'],$row['image_date']);  
   $image_link 
= ("<a href=\"" ROOT_PATH "details.php?image_id=" $image_id "\">"); 
   $allnew_link = ("<a href=\"" ROOT_PATH "search.php?search_new_images=1" "\">"); 

   echo "<tr><td class=\"row2\" height=\"30\">$image_link<b>$image_name</b></a></td></tr>";
   // - $image_date<br />"; 
  
}
if (
$image_name == "") {
echo "There have been no new files added in the last 30 days<br />";
}
  echo "<tr><td class=\"row1\" align=\"right\"><a href=\"search.php?search_new_images=1\">All new images</a></td></tr></table>
  "

?>

Offline short_up

  • Pre-Newbie
  • Posts: 5
    • View Profile
    • http://www.short-up.com
Re: [REQUEST] Script that Lists New Content
« Reply #5 on: August 23, 2005, 12:25:51 AM »
This is great!  Thanks a lot, but I still have a quick question.  How do I change the home.html page so that it links and opens up to the new.html page I made?  If I link it to new.html, it takes me to the page but without the header and link.css and footer that is in the template folder.
 Basically, I think that my problem is that my "new images" don't work haha
 Thanks!

by the way, if it's any use to you; the site I'm trying to get to work is http://www.lohanpictures.com
and this is the "new" page I made: http://www.lohanpictures.com/new.php and at http://www.lohanpictures.com/templates/default/new.php
new.php is also new.html if that means anything

TheOracle

  • Guest
Re: [REQUEST] Script that Lists New Content
« Reply #6 on: August 26, 2005, 02:09:57 PM »
Quote

$image_name = ($row['image_name']);


You don't need the () in these cases. That goes for all the rest of that paragraph (except, of course, for the while statement). ;)

As for the :

Code: [Select]

echo "<tr><td class=\"row2\" height=\"30\">$image_link<b>$image_name</b></a></td></tr>";
   // - $image_date<br />";
  }
}
if ($image_name == "") {
echo "There have been no new files added in the last 30 days<br />";
}
  echo "<tr><td class=\"row1\" align=\"right\"><a href=\"search.php?search_new_images=1\">All new images</a></td></tr></table>
  ";


You could always use the : $msg string and remove the echo command by equalizing it into a new $lang['your_line_name'] then by registring the initial in order to use in the templates. ;)