Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

[RELEASE] Gallery Search Block
Goto page Previous  1, 2
 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Issues » Blocks View previous topicPrinter friendly versionView next topic
Author Message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6274
Location: Washington Township, NJ, USA

PostPosted: Thu Sep 23, 2004 7:35 am    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

http://www.nukedgallery.net/modules/gal ... string=feb is what you want?
Code: › --- search.php   2004-09-21 01:15:45.000000000 -0400
+++ /home/httpd/xxxxxxx/htdocs/modules/gallery/search.php   2004-09-23 08:30:55.000000000 -0400
@@ -132,12 +132,18 @@
          $searchTitle = eregi_replace("($searchstring)", "<b>\\1</b>", $searchTitle); // cause search word to be bolded
          $searchDescription = eregi_replace("($searchstring)", "<b>\\1</b>", $searchDescription); // cause search word to be bolded
          $searchSummary = eregi_replace("($searchstring)", "<b>\\1</b>", $searchSummary); // cause search word to be bolded
+         $parentNameArray = getParentAlbums($searchAlbum, true);
+                        $albumURL = '';
+                          foreach($parentNameArray as $pName=>$pTitle) {
+                             $albumURL .= '<a href='.makeAlbumUrl($pName).'>'.$pTitle.'</a> &raquo; ';
+                          }
+         $albumURL = substr(trim($albumURL),0,-9);
          $photoURL = makeAlbumUrl($searchAlbum->fields['name']);
          $searchdraw["bordercolor"] = $borderColor;
          $searchdraw["top"] = true;
          $searchdraw["photolink"] = $searchAlbum->getHighlightTag($thumbSize);
          $searchdraw["photoURL"] = $photoURL;
-         $searchdraw["Text1"] = '<table cellpadding="0" cellspacing="0" width="100%" border="0" align="center" class="mod_title"><tr valign="middle"><td class="leftspacer"></td><td><table cellspacing="0" cellpadding="0" border="0" class="mod_title_bg"><tr><td class="mod_title_left"></td><td nowrap class="title"><a href="'. $photoURL .'">'. $searchTitle .'</a></td><td class="mod_title_right"></td></tr></table></td></tr></table>';
+         $searchdraw["Text1"] = '<table cellpadding="0" cellspacing="0" width="100%" border="0" align="center" class="mod_title"><tr valign="middle"><td class="leftspacer"></td><td><table cellspacing="0" cellpadding="0" border="0" class="mod_title_bg"><tr><td class="mod_title_left"></td><td nowrap class="title">'.$albumURL.'</td><td class="mod_title_right"></td></tr></table></td></tr></table>';
          $searchdraw["Text2"] = '<span class="desc">'. $searchDescription . '</span>';
          if ($matchSummary)  { // only print summary if it matches
             $searchdraw["Text3"] = '<span class="desc">'. $searchSummary .'</span>';
@@ -219,6 +225,15 @@
                      // One of the parents of this item is hidden do not show it to users
                      continue;
                   }
+
+                  $parentNameArray = getParentAlbums($searchAlbum);
+                  if(count($parentNameArray) != 0) {
+                     $parentURLString = '';
+                     foreach($parentNameArray as $pName=>$pTitle) {
+                        $parentURLString .= "<a href=\"".makeAlbumUrl($pName)."\">".$pTitle."</a> &raquo; ";
+                     }
+                  }
+
                   $photoMatch = 1;
                   $id = $searchAlbum->getPhotoId($j);
                   // cause search word to be bolded
@@ -228,7 +243,7 @@
                   $searchdraw["top"] = true;
                   $searchdraw["photolink"] = $searchAlbum->getThumbnailTag($j, $thumbSize);
                   $searchdraw["photoURL"] = makeAlbumUrl($searchAlbum->fields['name'], $id);
-                  $searchdraw["Text1"] = '<div class="desc">'. _("From Album") .":&nbsp;&nbsp;<a href=\"" .
+                  $searchdraw["Text1"] = '<div class="desc">'. _("From Album") .":&nbsp;&nbsp;".$parentURLString."<a href=\"" .
                                          makeAlbumUrl($searchAlbum->fields['name']) . "\">" .
                                          $searchAlbum->fields['title'] . "</a></div>";
                   $searchdraw["Text2"] = '<span class="desc">'. $searchCaption .'</span>';


EDIT: Fixed incorrect URL character.
_________________


Last edited by dari on Thu Sep 23, 2004 3:12 pm; edited 1 time in total
Back to top
Offline View user's profile Send private message Visit poster's website
AdBot
   Post subject: Re: [RELEASE] Gallery Search Block  

Back to top
mystavash

Beginner
Beginner


Joined: Sep 07, 2004
Posts: 14

PostPosted: Thu Sep 23, 2004 3:02 pm    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

My apologies for my late reply. Thank you for your help and your time!

Yes, what you have on your site is more what I was looking for. I ran it though my test site. Instead of showing the album titles on my site, though, it shows the album names, is that some difference between Gallery 1.4.4 and 1.4.5?

The test site is here:
http://www.mystavash.net/nuke/
A search for 'PP' will explain. Smile

Also, for my site, although the URLs for the photo are are fine, the URLs for the albums all have a trailing \... the same problem is on your site. Perhaps from this line?
Code: › $searchdraw["Text1"] = '<div class="desc">'. _("From Album") .":&nbsp;&nbsp;".$parentURLString."<a href=\"" .


Not absolutely sure. Smile On my computer, all \ come out as yen signs anyway. Confused

Anisa.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6274
Location: Washington Township, NJ, USA

PostPosted: Thu Sep 23, 2004 3:09 pm    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

delete the code i gave you for your util.php.

add this into classes/Album.php:

PHP: › <?php /*
        ** Returns an array of the parent album names for a given album.
        ** Key is albumname, value is albumtitle
        ** Array is reverted, so the first Element is the topalbum.
        ** If you set $addChild true, then the child album itself is added as last Element.
        ** Based on code by: Dariush Molavi
        */
        
function getParentAlbums($addChild=false) {
                global 
$gallery;

                
$parentAlbum $this;
                
$parentNameArray = array();
                
$depth=0;

                if (
$addChild == true) {
                        
$parentNameArray[$this->fields['name']] = $this->fields['title'];
                }

                while ((
$parentAlbum $parentAlbum->getParentAlbum(FALSE)) && 
                                
$depth $gallery->app->maximumAlbumDepth) {
                        
$parentNameArray[$parentAlbum->fields['name']] = $parentAlbum->fields['title'];
                        
$depth++;
                }

                
$parentNameArray array_reverse($parentNameArray);


                return 
$parentNameArray;
        } 
?>


underneath

PHP: › <?php function &getParentAlbum($loadphotos=TRUE) {
                if (
$this->fields['parentAlbumName']) {
                        
$parentAlbum = new Album();
                        
$parentAlbum->load($this->fields['parentAlbumName'], $loadphotos);
                        return 
$parentAlbum;
                }
                return 
null;
        } 
?>


for the odd URL behavior, open search.php and find:
PHP: › <?php $albumURL .= '<a href=\"'.makeAlbumUrl($pName).'\">'.$pTitle.'</a> &raquo; '?>


and replace with:
PHP: › <?php $albumURL .= '<a href='.makeAlbumUrl($pName).'>'.$pTitle.'</a> &raquo; '?>

_________________
Back to top
Offline View user's profile Send private message Visit poster's website
mystavash

Beginner
Beginner


Joined: Sep 07, 2004
Posts: 14

PostPosted: Fri Sep 24, 2004 10:57 am    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

Hrm。
I keep getting the following error:
Code: › Fatal error: Call to undefined function: getparentalbums() in /home/mystavas/public_html/nuke/modules/gallery/search.php on line 133


I thought it might be because I was mucking with the Album file earlier but even when I put a clean file in, it still comes up with that error.

Anisa.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6274
Location: Washington Township, NJ, USA

PostPosted: Fri Sep 24, 2004 11:02 am    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

hmm..my mistake...
add:
PHP: › <?php /*
 * Returns an array of the parent album names for a given child
 * album.
 * Array is reverted, so the first Element is the topalbum.
 * If you set $addChild true, then the child album itself is added as last Element.
 * Based on code by: Dariush Molavi
 */

function getParentAlbums($childAlbum$addChild=false) {
        
$pAlbum $childAlbum;
        
$parentNameArray = array();

        if (
$addChild == true) {
                
$parentNameArray[$pAlbum->fields['name']] = $pAlbum->fields['title'];
        }

        while (
$pAlbum $pAlbum->getParentAlbum(FALSE)) {
                
$parentNameArray[$pAlbum->fields['name']] = $pAlbum->fields['title'];
        }

        
$parentNameArray array_reverse($parentNameArray);

        return 
$parentNameArray;
?>


at the end of util.php, before the "require_once.." lines...
_________________
Back to top
Offline View user's profile Send private message Visit poster's website
mystavash

Beginner
Beginner


Joined: Sep 07, 2004
Posts: 14

PostPosted: Fri Sep 24, 2004 1:16 pm    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

Thank you! That works neatly! Smile

I'll put it on my main page and post a link here so people can see what it looks like.

Anisa.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6274
Location: Washington Township, NJ, USA

PostPosted: Fri Sep 24, 2004 1:18 pm    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

*phew* glad we got it sorted..had our wires crossed there for a bit. this will be included in 1.4.5 Smile
_________________
Back to top
Offline View user's profile Send private message Visit poster's website
mystavash

Beginner
Beginner


Joined: Sep 07, 2004
Posts: 14

PostPosted: Sat Sep 25, 2004 5:00 pm    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

Thank you so much for your help!

So, just so it's clear to anyone reading this, for Gallery 1.4.4, here are add a bread crumb to a search result to show the parent albums, as shown here [nukedgallery.net], here are Dari's instructions:

Files changed:
search.php
util.php
classes/Album.php

1) BACKUP ALL FILES Smile

2) Open search.php

around line 132, look for
Code: ›           $searchTitle = eregi_replace("($searchstring)", "<b>\\1</b>", $searchTitle); // cause search word to be bolded
          $searchDescription = eregi_replace("($searchstring)", "<b>\\1</b>", $searchDescription); // cause search word to be bolded
          $searchSummary = eregi_replace("($searchstring)", "<b>\\1</b>", $searchSummary); // cause search word to be bolded


and add this after it.

Code: ›
         $parentNameArray = getParentAlbums($searchAlbum, true);
                        $albumURL = '';
                          foreach($parentNameArray as $pName=>$pTitle) {
                             $albumURL .= '<a href='.makeAlbumUrl($pName).'>'.$pTitle.'</a> &raquo; ';
                          }
         $albumURL = substr(trim($albumURL),0,-9);


Find this line:

Code: › $searchdraw["Text1"] = '<table cellpadding="0" cellspacing="0" width="100%" border="0" align="center" class="mod_title"><tr valign="middle"><td class="leftspacer"></td><td><table cellspacing="0" cellpadding="0" border="0" class="mod_title_bg"><tr><td class="mod_title_left"></td><td nowrap class="title"><a href="'. $photoURL .'">'. $searchTitle .'</a></td><td class="mod_title_right"></td></tr></table></td></tr></table>';


[EDIT: In my version of Gallery for my real site, this line looked like this:
Code: › $searchdraw["Text1"] = '<span class="title"><a href="'. $photoURL .'">'. $searchTitle .'</a></span>';
, doesn't matter, just replace it with the new line.]


and REPLACE it with this line:

Code: ›          $searchdraw["Text1"] = '<table cellpadding="0" cellspacing="0" width="100%" border="0" align="center" class="mod_title"><tr valign="middle"><td class="leftspacer"></td><td><table cellspacing="0" cellpadding="0" border="0" class="mod_title_bg"><tr><td class="mod_title_left"></td><td nowrap class="title">'.$albumURL.'</td><td class="mod_title_right"></td></tr></table></td></tr></table>';


Around line 219, find this line:

Code: ›                       // One of the parents of this item is hidden do not show it to users
                      continue;
                   }

                   $photoMatch = 1;
                   $id = $searchAlbum->getPhotoId($j);
                   // cause search word to be bolded


And REPLACE it with:

Code: ›                       // One of the parents of this item is hidden do not show it to users
                      continue;
                   }

                  $parentNameArray = getParentAlbums($searchAlbum);
                  if(count($parentNameArray) != 0) {
                     $parentURLString = '';
                     foreach($parentNameArray as $pName=>$pTitle) {
                        $parentURLString .= "<a href=\"".makeAlbumUrl($pName)."\">".$pTitle."</a> &raquo; ";
                     }
                  }

                   $photoMatch = 1;
                   $id = $searchAlbum->getPhotoId($j);
                   // cause search word to be bolded


Find this line:
Code: ›                   $searchdraw["Text1"] = '<div class="desc">'. _("From Album") .":&nbsp;&nbsp;<a href=\"" .


and replace it with:
Code: ›                   $searchdraw["Text1"] = '<div class="desc">'. _("From Album") .":&nbsp;&nbsp;".$parentURLString."<a href=\"" .


SAVE. Smile

3) Open classes/Album.php

Find:

Code: › function &getParentAlbum($loadphotos=TRUE) {
                if ($this->fields['parentAlbumName']) {
                        $parentAlbum = new Album();
                        $parentAlbum->load($this->fields['parentAlbumName'], $loadphotos);
                        return $parentAlbum;
                }
                return null;
        }


And ADD AFTER it:

Code: › /*
        ** Returns an array of the parent album names for a given album.
        ** Key is albumname, value is albumtitle
        ** Array is reverted, so the first Element is the topalbum.
        ** If you set $addChild true, then the child album itself is added as last Element.
        ** Based on code by: Dariush Molavi
        */
        function getParentAlbums($addChild=false) {
                global $gallery;

                $parentAlbum = $this;
                $parentNameArray = array();
                $depth=0;

                if ($addChild == true) {
                        $parentNameArray[$this->fields['name']] = $this->fields['title'];
                }

                while (($parentAlbum = $parentAlbum->getParentAlbum(FALSE)) &&
                                $depth < $gallery->app->maximumAlbumDepth) {
                        $parentNameArray[$parentAlbum->fields['name']] = $parentAlbum->fields['title'];
                        $depth++;
                }

                $parentNameArray = array_reverse($parentNameArray);


                return $parentNameArray;
        }


SAVE.

4) Open util.php

At the end, find

Code: › require (dirname(__FILE__) . '/lib/lang.php');
require (dirname(__FILE__) . '/lib/Form.php');
require (dirname(__FILE__) . '/lib/voting.php');


And add ABOVE it:

Code: › /*
* Returns an array of the parent album names for a given child
* album.
* Array is reverted, so the first Element is the topalbum.
* If you set $addChild true, then the child album itself is added as last Element.
* Based on code by: Dariush Molavi
*/

function getParentAlbums($childAlbum, $addChild=false) {
        $pAlbum = $childAlbum;
        $parentNameArray = array();

        if ($addChild == true) {
                $parentNameArray[$pAlbum->fields['name']] = $pAlbum->fields['title'];
        }

        while ($pAlbum = $pAlbum->getParentAlbum(FALSE)) {
                $parentNameArray[$pAlbum->fields['name']] = $pAlbum->fields['title'];
        }

        $parentNameArray = array_reverse($parentNameArray);

        return $parentNameArray;
}


Save and done! If I made any mistakes, please feel free to edit them. o.o

You can see this function implemented at my site as well, http://64.17.165.160/ [64.17.165.160]. The 'Scans Search' is the gallery search. An example search [64.17.165.160] with an album and photo displayed.

Anisa.
[/url]
Back to top
Offline View user's profile Send private message
boardsource

Beginner
Beginner


Joined: Oct 10, 2006
Posts: 7

PostPosted: Fri Oct 13, 2006 11:50 am    Post subject: Re: [RELEASE] Gallery Search Block Reply with quote

i noticed this was a pretty old topic so i was wondering if it was still compatible with the newest version of gallery (cuz i wasnt able to find any other) and where exacly you have to place the NG-GallerySearch.php
is it by any chance in here
0:/gallery2/modules/imageblock/templates/blocks/

thanks
Back to top
Offline View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Issues » Blocks View previous topicPrinter friendly versionView next topic
Goto page Previous  1, 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Web HostingDedicated ServersDomain NamesDomain Name RegistrationDedicated Web HostingSearch Engine OptimisationSEOWeb Design New YorkSEO Web DesignWeb hosting AustraliaSEO

6th year online! 2003-2008
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia