WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: NextGEN Gallery] Gallery title and Back-link hack (10 posts)

  1. Tommie Hansen
    Member
    Posted 5 years ago #

    Unfortunately when using Nextgen Gallery and browsing sub-albums a user doesn't really know in which album they are in a simple manor and if for example they get a link directly to a gallery from a friend where the gallery is a child page of an album they have no way of easily returning to the Nextgen Album root (like http://www.YOUR-URL.com/gallery).

    This hack takes care of that problem in a simple manor by editing functions.php;

    1. Open nextgen-gallery/functions.php
    2. Find line 315 & 316:

    if (is_array($picturelist)) {
    	$out  = '<div class="ngg-galleryoverview" id="ngg-gallery-'. $galleryID .'">';

    3. Give it the finger and replace with;

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// begin ugly hack
    
    	global $wpdb, $nggRewrite;
    
    	$ngg_options = nggallery::get_option('ngg_options');
    
    	$galleryID = $wpdb->escape($galleryID);
    	$gallerycontent = $wpdb->get_row("SELECT * FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
    
    	// choose between variable and page link
    	if ($ngg_options['galNoPages']) {
    		$args['album'] = $albumID;
    		$args['gallery'] = $galleryID;
    		$link = $nggRewrite->get_permalink($args);
    	} else {
    		$link = get_permalink($gallerycontent->pageid);
    	}
    
    	if (is_array($picturelist)) {
    	$out  = '
    	<h2 class="gallerytitle">'. $gallerycontent->title .'</h2>
    	<a>YOUR-WP-GALLERY-SUBPAGE" class="arrowleft">Go back</a>
    
    	<div class="ngg-galleryoverview" id="ngg-gallery-'. $galleryID .'">
    	';
    
    	////////////////////////////////////////////////////////////////////////////////////////////////////////////// end ugly hack

    4. Change "YOUR-WP-GALLERY-SUBPAGE" with the url of your Nextgen Album-page (like ./gallery if you have WordPress in your root directory and your gallery in http://www.YOUR-URL.com/gallery)

    Optional
    5. Apply styling to the link with the class "arrowleft" or just edit/add a class in any way you want.
    6. Apply styling to the h2 with the class "gallerytitle" in order to make it look better or change the class or heading to whatever you want. It's simple html.

    Good luck and make sure to have backups of your original functions.php! Also be aware of that if you upgrade nextgen gallery this hack will be long gone.

    Also have in mind that i just share this so that others that wants the same output can have it, my PHP-coding skills aren't really there but this will still take care of the job even if it takes some editing in the core of Nextgen Gallery. :)

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. Alex Rabe
    Member
    Posted 5 years ago #

    This should work, but this requires always a modification of the code, I need to find some more global solution for all combination.

  3. Tommie Hansen
    Member
    Posted 5 years ago #

    Yeah, well.. it isn't that dynamic and to truly have it that way it would take a lot of more work. A simple hook like "ng_url" + an admin option or something would be ugly but it would work a bit at least. ;)

  4. jaumedejuan
    Member
    Posted 5 years ago #

    well that snippet produced some invalid code in my current installtion of WP 2.5.1 and NG 0.95

    I have replaced the line
    <a>YOUR-WP-GALLERY-SUBPAGE" class="arrowleft">Go back</a>

    with
    <a href="YOUR-WP-GALLERY-SUBPAGE" class="arrowleft">Go back</a>

    which in my case ended as
    <a href="../gallery" class="arrowleft">Go back</a>

    by the way, great hack!

  5. Tommie Hansen
    Member
    Posted 5 years ago #

    ops, that's just because i was a bit tired when i wrote that i guess. I'n not a tutorial-guru exactly. :)

  6. Morgan Roussel
    Member
    Posted 5 years ago #

    I have replaced the line
    <a>YOUR-WP-GALLERY-SUBPAGE" class="arrowleft">Go back</a>

    with
    <a href="javascript: history.go(-1)" class="arrowleft">Go back</a>

  7. dkalamatianos
    Member
    Posted 5 years ago #

    How can I implement this hack as an album template?

  8. bento
    Member
    Posted 5 years ago #

    When I open nextgen-gallery/functions.php, I can`t find the line where it says:

    if (is_array($picturelist)) {
    	$out  = '<div class="ngg-galleryoverview" id="ngg-gallery-'. $galleryID .'">';

    Did the code for the nextGen gallery change in the meantime?
    I really want to implement this hack, please let me know if it still works with the current version of NG.

    Thanks.

  9. Tommie Hansen
    Member
    Posted 5 years ago #

    It's for an older version of Nextgen Gallery for use with WP 2.5- WP 2.6.2. Haven't yet implemented the new version for WP 2.7+ on any sites but i'll do it in a couple of days and will bash Alex Rabe if one simply can't make the hack work any more. :)

    I thought it was implemented in the new versions of NGG actually. Hacking it kinda sucks since one will loose all hacks every time you wish to update NGG. :f

  10. Jackson
    Member
    Posted 5 years ago #

    Current version this code is in view/gallery.php

    Here's what I added, starting at line 17:

    <div class="ngg-galleryoverview" id="ngg-gallery-<?php echo $gallery->ID ?>">
    <h3><?php echo $gallery->title ?></h3>
    <a href="javascript: history.go(-1)" class="arrowleft">&larr; Return to gallery index</a>
    <?php if ($gallery->show_slideshow) { ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.