Author Topic: [Mod] New Images in Category v2  (Read 76277 times)

0 Members and 1 Guest are viewing this topic.

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] New Images in Category v2
« on: May 14, 2003, 08:52:02 PM »
V.2. Thanks to V@no (were have I heard that before   :?:   :lol: ) and his performance tuning and 4images knowledge I have updated the part of this mod that changes the page_header.php file.

If you have already installed this mod don't worry just change the bit you added in the page_header.php file with the new code.

I'm afraid I can take no credit of this re-write at all. All must go to V@no.
I think for now on we should all come up with the ideas and V@no writes them up for us  :lol:  


This Mod creates a table that displays the number of new images in each category (that has new images)
and provides links to the search page that will only display new images for that specific category.
It will only show categories that the user has access to.

To see this in action just look at the left side column of my site under the Random Image
http://www.newman.d2g.com/

Time to add Mod:
15-20 minutes

Files Changed
- includes/page_header.php
- Search.php
- templates/your_template/home.html

Note: As usual - BACKUP all of these files before changing them.


 :arrow: Edit includes/page_header.php

At the end of the page before:
Code: [Select]
?>
Add:

Code: [Select]
//-----------------------------------------------------
//---Show New Image count in category------------------
//-----------------------------------------------------

$new_image_category = "<table border=1 cellpadding=3 cellspacing=1 width=\"100%\">";

foreach ($new_image_cache as $key => $val) {
     if ($val && check_permission("auth_viewcat", $key)) {
     $category_link = "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_new_images=1&cat_id=".$key."&sub_cat=no")."\">".$val."</a>";
     $new_image_category .= "<tr><td><a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$cat_cache[$key]['cat_id'])."\">".$cat_cache[$key]['cat_name']."</a></td><td><b>".$category_link."</b></td></tr>";
   }
}
  
  $new_image_category .= "</table>";
  $site_template->register_vars("new_image_cats", $new_image_category);
  unset($new_image_category);


 :arrow: Edit Search.php

Find:
Code: [Select]
if (isset($HTTP_POST_VARS['search_fields'])) {
  $search_fields = trim($HTTP_POST_VARS['search_fields']);
}
else {
  $search_fields = "all";
}

Add After:

Code: [Select]
//-----------------------------------------------------
//---Show New Image count in category Mod -------------
//-----------------------------------------------------

if (isset($HTTP_GET_VARS['sub_cat'])) {
  $sub_cat = trim($HTTP_GET_VARS['sub_cat']);
}
else
{
  $sub_cat = isset($HTTP_POST_VARS['sub_cat']) ? trim($HTTP_POST_VARS['sub_cat']) : 1;
}

if (isset($HTTP_GET_VARS['cat_id'])) {
  $search_cat = intval($HTTP_GET_VARS['cat_id']);
}
else {
$search_cat = (isset($HTTP_POST_VARS['cat_id']) ) ? intval($HTTP_POST_VARS['cat_id']) : 0;
}
//-----------------------------------------------------
//---End of Show New Image count in category Mod ------
//-----------------------------------------------------

Be careful with this bit, make shure you have all the }'s in place
Find:

Code: [Select]
if (check_permission("auth_viewcat", $search_id['search_cat'])) {
      $cat_id_sql .= ", ".$search_id['search_cat'];
      if (!empty($sub_cat_ids[$search_id['search_cat']])) {
        foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {
          if (check_permission("auth_viewcat", $val)) {
            $cat_id_sql .= ", ".$val;
          }
        }
      }
    }


Replace with:

Code: [Select]
if (check_permission("auth_viewcat", $search_id['search_cat'])) {
      $cat_id_sql .= ", ".$search_id['search_cat'];
      if ($sub_cat != "no") { // Show New Image count in category Mod
       if (!empty($sub_cat_ids[$search_id['search_cat']])) {
         foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {
           if (check_permission("auth_viewcat", $val)) {
             $cat_id_sql .= ", ".$val;
           }
         }
       }
     }   // Show New Image count in category Mod
}

 


 :arrow: In your home.html file

Add:
Code: [Select]
{new_image_cats}
where you want the "New images in Category" to appear.

That's all there is to it.
Have fun
Fugaziman 8)
« Last Edit: April 24, 2010, 02:07:20 AM by V@no »
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] New Images in Category v2
« Reply #1 on: May 14, 2003, 08:56:25 PM »
I saw this at your site yesterday...it's very nice!
and today u saved me from asking u to share with us that mod...hehe
good job ;)
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 Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
[Mod] New Images in Category v2
« Reply #2 on: May 14, 2003, 09:25:53 PM »
Great idea, but if I open index.php, {new_image_cats} is there instead of the new image cats.
Any idea?

Thanks and cheers,

Markus

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] New Images in Category v2
« Reply #3 on: May 14, 2003, 09:37:50 PM »
Quote from: Maweryk
Great idea, but if I open index.php, {new_image_cats} is there instead of the new image cats.
Any idea?

Thanks and cheers,
Markus


Not quite sure what you mean  :roll:
The {new_image_cats}  should be added to your template files where you want it to display.

Can you give me a little more info  :?:
Fugaziman
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
[Mod] New Images in Category v2
« Reply #4 on: May 14, 2003, 09:54:18 PM »
Now, everything works fine.

Thanks Fugaziman for his very good support.

Cheers,

Markus

Offline moritzh

  • Pre-Newbie
  • Posts: 3
    • View Profile
Fatal error: Call to undefined function:  get_permission()
« Reply #5 on: May 15, 2003, 06:46:26 AM »
Hi,

I checked out your mod on your page and it is great! So I tried to install it. However, I get this error message:

Fatal error: Call to undefined function:  get_permission() in /abc/xyz/homepage/ewb/gallery/includes/page_header.php on line 321

Line 321 is the following:
$user_access = get_permission();

When I comment out this line, the error message disappears. And the mod still works! Any idea why? Where is this function defined? Do you need $user_access anywhere? I don't see where it is used. Or can you do without this line 321???
If I am not mistaken, get_permission is not php function, right? (I searcehd  www.php.net on that.)

Any help is appreciated!
Moritz

Offline Apollo13

  • Addicted member
  • ******
  • Posts: 1.093
    • View Profile
[Mod] New Images in Category v2
« Reply #6 on: May 15, 2003, 07:38:29 AM »
great job i think i was the first beta tester... :lol:  :lol:


BTW. V@no whats wrong with your icq?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Fatal error: Call to undefined function:  get_permission()
« Reply #7 on: May 15, 2003, 11:31:00 AM »
Quote from: moritzh
Fatal error: Call to undefined function:  get_permission() in /abc/xyz/homepage/ewb/gallery/includes/page_header.php on line 321

Line 321 is the following:
$user_access = get_permission();

When I comment out this line, the error message disappears. And the mod still works! Any idea why? Where is this function defined? Do you need $user_access anywhere? I don't see where it is used. Or can you do without this line 321???
If I am not mistaken, get_permission is not php function, right?

no, u dont need that line at all.
in each main file, before page_header.php being include, $user_access = get_permission(); already executes, so, it's just doublicate line, wasting server's recources ;)


Quote from: Cr@zy Sash
BTW. V@no whats wrong with your icq?

I dont know, I'm online...but it seems none can see me and I cant receive messages? gotta try reinstall it, or... finaly reinstall the system...


@Fugaziman:
PM ;)
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 Gabi

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
    • http://www.gabis-traum.de
Error by clicking on Category
« Reply #8 on: May 15, 2003, 11:46:40 AM »
Hy ,

i istalld this Mod now i get this errormassage wen i klick on a category in the new fields:
Parse error: parse error in /homepages/3/d75848838/htdocs/main/foto-place/search.php on line 396
It´s the closingtag af search.php  ?>

What can i do to fix it ??

lg
Gabi

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] New Images in Category v2
« Reply #9 on: May 15, 2003, 12:08:42 PM »
Quote from: Fugaziman
Be careful with this bit, make shure you have all the }'s in place

;)
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 Gabi

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
    • http://www.gabis-traum.de
[Mod] New Images in Category v2
« Reply #10 on: May 15, 2003, 12:14:52 PM »
Quote from: V@no
Quote from: Fugaziman
Be careful with this bit, make shure you have all the }'s in place

;)


yepp i saw that  :D but its all there....this is the part wher i includet code:

Code: [Select]
if (!empty($search_id['search_cat']) && $search_id['search_cat'] != 0) {
    $cat_id_sql = 0;
    $sub_cat_ids = get_subcat_ids($search_id['search_cat'], $search_id['search_cat'], $cat_parent_cache);
   if (check_permission("auth_viewcat", $search_id['search_cat'])) {  
      $cat_id_sql .= ", ".$search_id['search_cat'];  
      if ($sub_cat != "no") {             // Show New Image count in category Mod
          if (!empty($sub_cat_ids[$search_id['search_cat']])) {  
            foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {  
                  if (check_permission("auth_viewcat", $val)) {  
                        $cat_id_sql .= ", ".$val;  
                  }  
            }  
          }  
     }                      // Show New Image count in category Mod
}

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] New Images in Category v2
« Reply #11 on: May 15, 2003, 12:38:17 PM »
Quote from: Gabi
yepp i saw that  :D but its all there....this is the part wher i includet code:
without putting your sample in my php editor I can see that u are missing one closing }
just add it near any of others closing }
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 toto1

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://www.gifanimer.com
[Mod] New Images in Category v2
« Reply #12 on: May 15, 2003, 01:24:20 PM »
good hack very thk

Offline balu

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • http://www.coverengine.de/4images
Great support!
« Reply #13 on: May 17, 2003, 06:20:47 PM »
:D  :D  :D  many thx to the author!!!
Jürgen
-------------------------------------------------------
Wer Rechtschreibfehler findet, darf sie behalten!


Offline bgmurphy

  • Full Member
  • ***
  • Posts: 113
    • View Profile
[Mod] New Images in Category v2
« Reply #14 on: May 28, 2003, 09:44:12 PM »
Fugaziman -

great mod !! - now for the question !!

any chance you can create an alternate mod so that rather than showing only the new images in a category - it display an (random) image from each category on the home page rather than just the random images that normally appear -

my goal is to present the home page with a quick foto of each of the events i cover and give the client the chance to do an at-a-glance of each new event (here is a site that does this ==> www.wireimage.com) and if the image rotates randomly within the event displayed ... that is good too ..

anyway .. all help is appreciated by all

thanx
bruce