Looking for Simple Next and Previous buttons under my Images

brianpthomas - February 9, 2009 - 02:33

I installed drupal on my churches website at www.cornerstonealive.com. I have everything working good. I use the Jupload (java uploader) to upload all my images into the appropriate galleries. What's annoying is that when people click on an image to enlarge it and they're looking at the bigger version, they cant just go to the next image or back to the previous image, they have to go back out to the gallery and click on the next one. Its horribly annoying. Anyone know a really quick way to just add some code into the image module or something so I can add the previous and next buttons. I dont really know how to apply patches. Ive noticed there are a couple patches for such a thing but i cant figure out how to use them. I Just want to kind of open up a file and paste some code in. Im not a programmer, im a designer, so the easier the better. Dont need anything advanced, just a simple link that says "Next" and "Previous". I dont even need thumbnails. Any help would be greatly appreciated.

Lightbox 2

Keyz - February 9, 2009 - 02:43

Hey Brian, great looking site. The module you need (I believe it will work with your Image module powered gallery) is Lightbox 2. Check its settings page, which I believe has some options specifically for Image module.

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

As far as lightbox goes, i

brianpthomas - February 9, 2009 - 03:53

As far as lightbox goes, i actually had that installed at one point and it worked great but realized that you cant leave comments on the images that way the same way you would if you just view the image node page itself. I want my users to be able to comment on the images if possible. Any other way?

Or custom pagers

Keyz - February 9, 2009 - 02:55

Forgot to mention... if you prefer previous/next links "on" the page and not a Javascript based popup, then consider http://drupal.org/project/custom_pagers

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

Alright, im going to give

brianpthomas - February 9, 2009 - 03:58

Alright, im going to give these custom pagers a try, thanks for the advice, much appreciated. Im new with this whole drupal thing, just learned it a few months ago.

I dont really understand the

brianpthomas - February 9, 2009 - 04:29

I dont really understand the part of making the pager visible. I installed it, told it to attach to the image node, but then it wants me to select a view or something and there is nothing in the dropdown that contains a images view, Im not sure how the spitting out an array thing works either, like i said, im a designer not a programmer, they think completely different most of the time.

I had trouble understanding

Keyz - February 9, 2009 - 05:22

I had trouble understanding it too when I first tried it (I'm not a programmer either... just enough to get by).

I'm going to go ahead and write some improved documentation for getting the "basics" of it working (I'm on the Drupal documentation team). Hold tight a few minutes and I'll post a link :)

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

Basic easy setup of Custom Pagers module

Keyz - February 9, 2009 - 07:27

Here's my new guide:
Basic easy setup of Custom Pagers module

Make sure you note the part about using the DEV version for now. Please let me know if everything is clear and works as expected. If you run into any areas of confusion let me know so I can improve the guide.

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

Your new directions worked

brianpthomas - February 10, 2009 - 02:21

Your new directions worked great. I have the previous and next buttons working, however (and this is just me being picky), I noticed it just lumps all the photos together that i have in all my photo galleries, so for instance, it says 662 of 886 (photos). Is there a way for that to just say how many are in that particular photo gallery instead of in all my photo galleries combined so it would say like 12 of 60 instead. I realized right now its grabbing ALL Image nodes but just wondering if it can be broken apart somehow by photo gallery. If not no big deal, its not that important, just wondering. Im sure its pretty complex if it can be done.

One more thing. When im

brianpthomas - February 10, 2009 - 03:21

One more thing. When im viewing the nodes and going to each one by clicking previous and next it seems like it displays backwards. I end up jumping into the next gallery when i hit next instead of cycling through the ones in that gallery. I have to hit previous instead of next when i click on the first image in a gallery. Kind of weird. Im sure it has to do with how their uploaded.

Nevermind, i guess i just

brianpthomas - February 10, 2009 - 03:26

Nevermind, i guess i just need to read, lol. I didnt realize you could reverse the node order.

I'll add this to the guide

Keyz - February 10, 2009 - 04:38

I'll add this to the guide also... but in the View you created, you can add any "Sort criteria" you want (by adding items to the Sort criteria area of the View). For instance you could sort by Node: Post date backwards or forwards, sort alphabetically by title, use Node statistics: Total views to sort in order of popularity (if you have the Statistics core module enabled and setup I believe), or many other options.

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

I'll have to ponder this a

Keyz - February 10, 2009 - 04:43

I'll have to ponder this a bit... would certainly be nice :) My hunch is it would have to do with a taxonomy term argument (since Image module's gallery uses taxonomy terms for gallery categories), or maybe a Filter if Image module gives the right filters over to Views. However I don't know for sure whether Custom Pagers will "play along". I'll let you know if I come up with a way.

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

Did anyone solve this? Our

merrillie - February 25, 2009 - 01:13

Did anyone solve this? Our image gallery is set up the same way in Drupal 6 using the custom pager and views and I have the same problem.
I would prefer it to only show how many for that term not all the images.

Path issue

Keyz - February 9, 2009 - 03:21

One more thing... I noticed that your Paths are a bit off from how they "ideally" should be. For instance I see /content/ministries whereas you probably would prefer /ministries (and down the line sub-pages such as /ministries/children, etc). Drupal adds the /content part in the default setup so that there aren't uncontrolled paths being made at the root of the site, but you can change this easily.

To do this you need to setup Pathauto settings (you probably already have Pathauto, but if not, get it now). Here's a video to get you on the right track: http://mustardseedmedia.com/podcast/episode18

I noticed on your Resources page, a -0 was appended to the path also. This happens when the system already finds the path you're trying to create, so since there can't be two of the same path, it increments a number on new versions of the same path. This will get fixed automatically when you build all your automated paths (see below) though I wanted to explain what was happening. If you ever need to fix this kind of thing manually you can search for paths using the Find URL Alias module (no longer needed in Drupal 6, though I see you're using Drupal 5).

Before beginning, you'll want to clear the old paths so that new ones can be built in their place, so go to admin/build/path/delete_bulk (only do this if it's ok to lose the old paths and replace them with the new patterns you specify... if you must retain old URLs, then look into the Path Redirect module to forward old paths to new ones. If the site is new though you won't need to worry about this). Then set up Pathauto (in Drupal 5) at: admin/settings/pathauto. The "Node path settings" is the main area you will want to configure. What I usually use for Pages is [menupath-raw] so that it will automatically create a path that reflects the content's position in the menu system (e.g. if "Children" is a child page of "Ministries" in the menu, then the path would be /ministries/children). Also set paths for all the other content types (e.g. your Images), and then check the "Bulk generate aliases for nodes that are not aliased" box, and then press "Save configuration". Paths for your image gallery can be set in "Category path settings".

Make sure you upgrade to Drupal 5.15 as soon as possible, as it has important security fixes.

Hope this helps :D

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

.

dbeall - July 9, 2009 - 07:07

This may be a good place to start again on this treasure hunt for a simple working photo gallery.. I am back on it again after many attempts to get a photo gallery in the past and gave up on it... This is one of those things that makes you wish you were a php god and just make a good one for everyone to use.. try, try, and try again..

...

Keyz - July 9, 2009 - 08:07

This looks pretty cool: http://www.lullabot.com/articles/photo-galleries-views-attach

Also I'm working on my own guide (with exports and templates provided):
http://www.davidnewkerk.com/book/128

I'll also be using a lot of ideas from that first link (which improve some on my original method and have some other useful additions).

.

dbeall - July 10, 2009 - 22:25

I tried the custom pagers and it kinda works, but not really,, inconsistent. Call me picky, but I do want to stay with core Drupal way of building. I am useing pathauto and token with a path of
[ www.example.com/photo-gallery/name-of-gallery/name-of-photo ]
I like image.module with the built in image.gallery. I am thinking views set up properly with views pagers, and the right arguments might get it close... I do have trouble figuring the views out. Some days i get it and some days I don't...

Editing.. I looked at the lullibot video and I think it was a neat set up, but I did not see a pager on the individual photo node pages which is my first wish... I can duplicate the add photo button easy with a side menu, but you have to choose gallery with drop down list...

Previous / Next API

Keyz - July 10, 2009 - 23:12

Try the Previous / Next API instead of Custom Pagers. Here is some code (which works but it's possible it could be improved once I know if/how Imagefield may offer a function to access this data without a custom query).

This is two functions for template.php... the first makes a variable for your node template, and the second part is a custom implementation of the Previous / Next API code, which instead grabs the imagefield from a "Photo" node. You can use the example from the module's documentation if you use Image module instead (this is for Imagefield/Imagecache). The content type and field have to be the same as the example (photo) or you need to adjust the code. Also the query assumes the Imagefield is set to Required (the database tables are different if it is not). It also uses a "photo-mini" Imagecache preset... you can rename this one line to your own preset's name, or else make a preset with this name.

/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_node(&$vars) {
  $node = $vars['node'];
  $prev_next  = '<ul id="node-navigation" class="clear-block">';
  $prev_next .= '<li class="prev">'. pn_node($node, 'p') .'</li>';
  $prev_next .= '<li class="next">'. pn_node($node, 'n') .'</li>';
  $prev_next .= '</ul>';
  $vars['prev_next'] = $prev_next;
}



/**
* Prev/Next API.
*/
function pn_node($node, $mode = 'n') {
  if (!function_exists('prev_next_nid')) {
    return NULL;
  }

  switch($mode) {
    case 'p':
      $n_nid = prev_next_nid($node->nid, 'prev');
      $link_text = t('previous');
      break;

    case 'n':
      $n_nid = prev_next_nid($node->nid, 'next');
      $link_text = t('next');
      break;

    default:
      return NULL;
  }

  if ($n_nid) {
    $n_node = node_load($n_nid);

    $options = array(
      'attributes' => array('class' => 'thumbnail'),
      'html'  => TRUE,
    );
    switch($n_node->type) {
      case 'photo': // This is a Photo node, get the thumbnail
        $fid = db_fetch_object(db_query("SELECT f.field_photo_fid FROM {content_type_photo} f WHERE nid = %d", $n_nid));
        $img_path = db_fetch_object(db_query("SELECT f.filepath FROM {files} f WHERE fid = %d", $fid->field_photo_fid));
        $img_path = file_create_path($img_path->filepath);

        $image = theme('imagecache', 'photo-mini', $img_path);
       
        $html  = l($image, "node/$n_nid", $options);
        $html .= l($link_text, "node/$n_nid", array('html' => TRUE));
        return $html;
    }
  }
}

Add anywhere in your Photo node template (e.g. node-photo.tpl.php):

<?php print $prev_next; ?>

Add to your style.css:

/**
* Previous / Next API.
*/
#node-navigation {
  padding: 10px;
}

#node-navigation li.prev,
#node-navigation li.next {
  background: none;
  float: left;
  list-style-image: none;
  list-style-type: none;
  margin: 0 10px 0 0;
  padding: 0;
  text-align: center;
}

#node-navigation li img {
  display: block;
  padding: 5px;
  border: 1px solid;
  border-top-color: #FAFAFA;
  border-right-color: #CCC;
  border-bottom-color: #CCC;
  border-left-color: #FAFAFA;
  background-color: #fff;
}

Clear the theme registry once the files are saved. You should then have thumbnails from the previous and next nodes. Make sure you also configure any necessary settings for Previous / Next API and ensure that it has indexed your nodes.

Hope this helps.

.

dbeall - July 11, 2009 - 08:07

Thank you Keyz, I will try it. I had a look at your site, you have been busy. The site that I am working on is a single user site, well right now it is. http://www.debrafetty.us . It may be a few days before i report back.. i have boat in the shop waiting for a cover to get done-work-. Then I will be back on it.

.

dbeall - July 17, 2009 - 19:48

After messing around more with this, I think http://drupal.org/project/node_gallery will get things close as I need them with no trickery involved other than a few settings in pathauto and some normal user file path settings. It supports users, has pagers, drag sorting, has a an access mod, but says it may be buggy. I like it because it's Drupal core way of nodes and comments, and it's easy. I like the easy part with so many other tasks to deal with on the many sites I host.... They have a demo, and I will have one on my test site http://www.davebeall.com , test pages.
If it goes wacko on me I will report back.. Happy photography everyone

.

dbeall - July 18, 2009 - 02:54

well, the project node gallery has gone wacko when editing an image after a gallery has been saved.. It looks as the xmlsitemap is causing the error or page not found after an edit. The error disappears after disabling the xmlsitemap and a cron run.
This is the best photo gallery Drupal has in my opinion that I have tried so far,, and I have tried them all except the Gallery2 bridge hack.

very good

zhaocai8 - July 18, 2009 - 18:01

very good

.

dbeall - July 20, 2009 - 22:26

if anyone has any questions or needs help with project/node_gallery 6.x-2.0-alpha10, just send me a note or see the notes on my test site davebeall.com, test pages. I have added project/custom_breadcrumbs 6.x-2.x-dev to enhance that part and have added a view to it. My view code is posted in my notes. and some other stuff. Will be working another view for it. I have put this into 2 sites so far.

.

dbeall - August 5, 2009 - 09:14

If anyone is watching this thread, I have been working on a handbook page for the node_gallery. Just started working with 6.x-2.x-dev last week, it's looking good. I have it on 2 sites so far. the handbook will be here for a day or so davebeall.com/node-gallery-handbook until it's ready to post in this section http://drupal.org/node/206776

.

dbeall - August 10, 2009 - 19:34

Here is the new Handbook for node_gallery ( http://drupal.org/node/544050 ). Hope this helps some people get a gallery up and running with some real nice features that are core Drupal.

next prev api

askibinski - August 12, 2009 - 10:15

I would recommend building galleries with views 2, cck and imagefield (imagecache,imageapi) and use the prev_next api module as described above to build your navigation. It involves a bit of themeing but I think the solution is more flexible and lightweight.

 
 

Drupal is a registered trademark of Dries Buytaert.