Topic Title: [RELEASE] Gallery Search Block

Forum Index » Blocks » [RELEASE] Gallery Search Block
Topic URL: http://www.nukedgallery.net/postt508.html

AuthorMessage
Post Title: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Dec 19, 2003 8:53 am
A very simple block to add to your site to allow Gallery searching from anywhere. A sample can be found at http://phpnuke.nukedgallery.net [nukedgallery.net]. The file can be downloaded from here [nukedgallery.net]

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
Aylwin
Joined: Sep 16, 2003
Posts: 27

Posted: Sat Dec 27, 2003 5:56 pm
Very, very nice! Very Happy

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
cosmic
Joined: Nov 25, 2003
Posts: 3

Posted: Thu Jan 01, 2004 5:40 am
Just what I've been looking for - excellent!

I do have one problem though, when I activate the block all my topic icons disappear! Any ideas on this please?

Nuke 6.5 gal 1.4.2

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Thu Jan 01, 2004 8:31 am
Not used the search box - but try this:

modules/News/index.php:

$s_sid = $row[sid];

to

$s_sid = "$row[sid]";


admin.php:

$sid = $row[sid];

to

$sid = "$row[sid]";

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
cosmic
Joined: Nov 25, 2003
Posts: 3

Posted: Thu Jan 01, 2004 8:41 am
Perfect - thanks! Wink

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Thu Jan 01, 2004 8:47 am
Smile

You may need to edit your /modules/Top/index.php also if you use it.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
Bongolonian
Joined: Jun 20, 2003
Posts: 9

Posted: Sun Jan 04, 2004 3:47 pm
Cheers man, had the same prob, fixed it thanks to your post

Also if your using the "Last 5 Articles" block then you have to change that also

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Tue Sep 21, 2004 12:30 pm
Maybe this is too much to ask from the already marvelous search, but is there anyway to get the results to display the immediate parent album's title and then the search result album's title?

My site goes ABC>series>sets, and to save space, I didn't put the series name in the set albums themselves (you can see the parent album at the top anyway), but in the search results, you don't have that, and without a highlight, you don't really know what a set is sometimes. It'd be nice if it could display series album title : set album title... Smile

Any help would be appreciated!

Anisa.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Sep 21, 2004 8:18 pm
hmm...good idea...BUT...(there's always a "but")...this block uses the built-in search function in Gallery (no use in me reinventing the wheel). so, such a mod would have to go into the core gallery code. i will see what i can dig up and will submit a patch for inclusion in the next release. once such a patch is available, i'll post it here.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Sep 21, 2004 8:42 pm
i've got a preliminary version working, search for "dog" in the gallery.

you'll notice the last result, the "are you having fun yet?" image, is inside the "december 2002" album of the "sugar" master album, however, i haven't gotten the parent recursion to root working (efficiently) yet. for now, it's bedtime, but i will tackle this soon.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Wed Sep 22, 2004 8:35 am
http://www.nukedgallery.net/modules/gal ... g&go=Go%21

i believe is what you're looking for. i'm speaking with the devs now about including it in the next CVS build. there is concern that it may be a substantial performance hit on large galleries, though.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Wed Sep 22, 2004 9:09 am
here is the patch code, submitted at http://sourceforge.net/tracker/?func=de ... tid=307130 and http://sourceforge.net/tracker/?func=de ... tid=307130

Note that these patches are against 1.4.5-cvs-b200
Patch to util.php:
Code: › --- util.php   2004-09-21 20:43:43.000000000 -0400
+++ /home/httpd/xxxxx/htdocs/modules/gallery/util.php   2004-09-22 09:50:10.000000000 -0400
@@ -3502,6 +3502,28 @@
 
 }
 
+/*
+ * Returns an array of the parent album names for a given child
+ * album.
+ * Code by: Dariush Molavi
+ */
+function getParentAlbums($childAlbum) {
+   $tAlbum = new Album();
+   $tAlbum = $childAlbum;
+   $parentNameArray = array();
+   do{
+      $pAlbumName = $tAlbum->fields['parentAlbumName'];
+      if($pAlbumName) {
+         $pAlbum = new Album();
+         $pAlbum->load($pAlbumName);
+         $parentNameArray[] = $pAlbumName;
+      }
+      $tAlbum = $pAlbum;
+   } while($pAlbumName);
+   $parentNameArray = array_reverse($parentNameArray);
+
+   return $parentNameArray;
+}
 
 require_once(dirname(__FILE__) . '/lib/lang.php');
 require_once(dirname(__FILE__) . '/lib/Form.php');


Patch to search.php:
Code: › --- search.php   2004-09-21 01:15:45.000000000 -0400
+++ /home/httpd/xxxxx/htdocs/modules/gallery/search.php   2004-09-22 09:53:24.000000000 -0400
@@ -219,6 +219,17 @@
                      // One of the parents of this item is hidden do not show it to users
                      continue;
                   }
+
+                  $parentNameArray = getParentAlbums($searchAlbum);
+                  if(count($parentNameArray) != 0) {
+                     $parentURLString = '';
+                     for($z=0; $z<count($parentNameArray); $z++) {
+                        $temp = new Album();
+                        $temp->load($parentNameArray[$z]);
+                        $parentURLString .= "<a href=\"".makeAlbumUrl($parentNameArray[$z])."\">".$temp->fields['title']."</a> &raquo; ";
+                     }
+                  }
+
                   $photoMatch = 1;
                   $id = $searchAlbum->getPhotoId($j);
                   // cause search word to be bolded
@@ -228,7 +239,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>';

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Wed Sep 22, 2004 8:32 pm
Ok, as of 1.4.5-cvs-b201, my patch to util.php was made available in the main branch of Gallery. The updated patch for search.php is:

Code: › --- search.php   2004-09-21 01:15:45.000000000 -0400
+++ /home/httpd/xxxxxx/htdocs/modules/gallery/search.php   2004-09-22 21:23:21.000000000 -0400
@@ -219,6 +219,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 +237,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>';

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Thu Sep 23, 2004 2:43 am
Thank you for your help! I have Gallery 1.4.4, but I will try it on a testing board. Smile

I am not absolutely sure that this exactly the way I want to go, but I will test it out.

In my case, the images are not actual photos, they're trading card scans. Smile

My site is set up like this:
Code: › # A B
    Series 1 title
         Set A
         Set B
         Set C
    Series 2 title
         Set A
         Set D
         Set E


I don't know if my explanation makes sense, so here is the link: http://64.17.165.160/modules.php?name=gallery

(Sorry about the pink. ^.^)

I have some empty albums basically as placeholders, so they will pop up in the search, but not have a highlight image to show what set they're from. These are all invariably (for my site) subsubalbums, so it would be nice to show the subalbum name in the search result. For example, if someone types Set A , the two set A albums will popup, but without a highlight image, it's impossible to distinguish between the two. Or even if it does have a highlight image, if the user is unfamiliar with the series, it doesn't help much.

Similarly, when I search on your site for July, the July subalbums popup, but I have no way of knowing which dog album they come from.

Another thing I was hoping to be able to do is be able to search for Series 1 Set A and get just that set, but I haven't figured a good way to do that.

Anisa.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Thu Sep 23, 2004 7:04 am
ah, i gotcha....you want the album paths displayed for photos and for the albums themselves that are returned.

let me make a quick mod and i'll post the updated patch.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Thu Sep 23, 2004 7:35 am
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.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Thu Sep 23, 2004 3:02 pm
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.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Thu Sep 23, 2004 3:09 pm
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; '?>

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Fri Sep 24, 2004 10:57 am
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.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Sep 24, 2004 11:02 am
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...

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Fri Sep 24, 2004 1:16 pm
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.

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Sep 24, 2004 1:18 pm
*phew* glad we got it sorted..had our wires crossed there for a bit. this will be included in 1.4.5 Smile

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
mystavash
Joined: Sep 07, 2004
Posts: 14

Posted: Sat Sep 25, 2004 5:00 pm
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]

AuthorMessage
Post Title: Re: [RELEASE] Gallery Search Block
boardsource
Joined: Oct 10, 2006
Posts: 7

Posted: Fri Oct 13, 2006 11:50 am
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

All times are GMT - 5 Hours
Powered by PHPNuke and phpBB2 © 2006 phpBB Group