Support » Plugin: NextGEN-Galleryview » Replaces all galleries, not just ones with specified template

Viewing 14 replies - 1 through 14 (of 14 total)
  • I believe the problem is that function add_template() in nggGalleryview.php does not check for the galleryview template before altering the path.

    I think changing that function to the code below will correct that problem:

    // Add our Template
    		function add_template( $path, $template_name = false) {
    			if ($template_name == 'galleryview') {
    			   // Check theme for template first
    			   if ( file_exists (get_stylesheet_directory() . "/nggallery/gallery-galleryview.php")) {
    				   $template_name == 'gallery-galleryview';
    				   $path = get_stylesheet_directory() . "/nggallery/gallery-galleryview.php";
    				}
    				else  {
    				   $template_name == 'gallery-galleryview';
    				   $path = WP_PLUGIN_DIR . '/' . plugin_basename( dirname(__FILE__) ) . '/view/gallery-galleryview.php';
    				}
    			}
    			return $path;
    		}

    Note also the change to get_stylesheet_directory() instead of TEMPLATEPATH. This allows the plugin to work with child themes.

    Small change to allow multiple galleryview galleries:

    // Add our Template
    		function add_template( $path, $template_name = false) {
    			if ( preg_match('/^galleryview(-.+)?$/', $template_name) ) {
    			   // Check theme for template first
    			   if ( file_exists (get_stylesheet_directory() . "/nggallery/$template_name.php")) {
    				   $path = get_stylesheet_directory() . "/nggallery/$template_name.php";
    				}
    				else  {
    				   $path = WP_PLUGIN_DIR . '/' . plugin_basename( dirname(__FILE__) ) . '/view/gallery-galleryview.php';
    				}
    			}
    			return $path;
    		}

    This makes it possible to use template names like template=’galleryview-frontpage’ to load the gallery-galleryview-frontpage.php file, thus using different templates for different galleries.

    I am always too quick to post. Disregard the last post. I can’t get this to work on a live site – only on my test site using this code:

    // Add our Template
    		function add_template( $path, $template_name = false) {
    			if ( preg_match('/^gallery-galleryview(-.+)?$/', $template_name) ) {
    			   // Check theme for template first
    			   if ( file_exists (get_stylesheet_directory() . "/nggallery/$template_name.php")) {
    				   $path = get_stylesheet_directory() . "/nggallery/$template_name.php";
    				}
    				else  {
    				   $path = WP_PLUGIN_DIR . '/' . plugin_basename( dirname(__FILE__) ) . '/view/gallery-galleryview.php';
    				}
    			}
    			return $path;
    		}

    OK – the code above is working. The problem on the live site was a conflict with another plugin. Disabling that plugin fixed the problem.

    Plugin Author Brandon Hubbard

    (@bhubbard)

    @vtxyzzy – Thanks for the fix. Updated the plugin.

    Kudos for the quick response!

    Hello … this thread makes me think that it’s possible to have different galleryview templates at work at the same time. However, I can’t seem to find any indication of what exactly which files need to be copied/renamed/edited to permit such a super thing. Probably a matter of my being extra dense, but I would greatly appreciate any direction you can provide me. Thank you very much! Greg

    Yes, it is possible. Follow the instructions for “Installation->Advanced Usage” for the NextGEN-Galleryview plugin.

    Thank you very much for your quick response. I thought I had read that section, but must have missed it and will go hunt it down now. Thanks!

    Well okay … either I wasn’t clear initially or I’m missing something now. The advanced instructions explain how to edit the galleryview template to change parameters such as where the film strip appears, sizes and so on and I’ve done that successfully. However, what I’m hoping to do but don’t see how to do is to create a new and additional gallery view template with different characteristics so I can use different galleries at different locations.

    Again, I’m probably just being super dense and I apologize if that’s the case. Above you reference creating multiple galleries, for example one for use on the front page “galleryview-frontpage.” I’ve tried creating copies of the gallery view.php file with new names and editing them and calling their template name, but I do not get any different behavior. So I’m doing something wrong obv and figured I was missing several steps.

    Sorry again for being dense and any further direction would be greatly appreciated.

    It may be because of the way the template names are used. The actual template name you use (in the “template=xxx” parameter in the shortcode) is prefixed automatically with ‘gallery-‘ to get the file name.

    The ‘galleryview-‘ part is required by the plugin.

    So, ‘template=galleryview’ would look for file ‘gallery-galleryview.php’. Similarly, ‘template=galleryview-frontpage’ would look for ‘gallery-galleryview-frontpage.php’.

    Okay … I’ll dink around further and see if I can’t get it working. Thank you for reassuring me that it is possible and it sounds like there isn’t something major I’m failing to do. Thanks again!

    One other point: the templates must be in a directory named ‘nggallery’ in your theme directory.

    Bingo! I had created a nggallery directory within the overall themes directory, not within the specific theme. Thanks so much once again! Greg

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Replaces all galleries, not just ones with specified template’ is closed to new replies.