• I have created some albums and into these albums I have put some galleries. Now when I show a gallery’s overview page, there is no title of the current gallery shown on the top of the overview page, I only see “show as slideshow” and then the thumbnails.

    I want to insert the current title on every gallery page automatically. I tried to modify nexgen-gallery/view/gallery.php as the template for the gallery page.

    I think the title of the current gallery should be in the array $gallery, but when I use <?php var_dump($gallery) ?>, it isn’t. I tried to use it like that:

    <?php echo $gallery->title ?>

    In this topic (https://www.ads-software.com/support/topic/170908), I think there was a solution for the problem but with version 1.0.2 of NexgGEN Gallery I think this does not work any more.

    Could you tell me how I can put the gallery title in the gallery.php or take this issue to add as an option in the backend/admin page for future releases? I think this was requested some more times. Thanks.

Viewing 15 replies - 1 through 15 (of 17 total)
  • You are right it’s a bit complicated. Due to the fact that a gallery output can contain now images from different galleries, the galler< title is part of the picture ($picture->title).

    This is of course a bit confusing, I will extract the title from the first image to the $gallery object…

    Fix will be added to next release : https://code.google.com/p/nextgen-gallery/source/detail?r=435

    Please note that tag based galleries are return the result from the first image, so a gallery title could there not useful…

    Alex, first of all thanks for this great plugin. The best out there!

    I’ve found a simple solution to this problem using query strings.

    In album-compact.php and album-extend.php I changed all the links.

    Before:
    <a href="<?php echo $gallery->pagelink ?>">
    -----------------------------------------------------------------
    After:
    <a href="<?php echo $gallery->pagelink ?>?<?php echo $gallery->title ?>">

    And I get the query string in the beginning of my gallery.php outside the for loop.

    Before:

    <div class="ngg-galleryoverview" id="ngg-gallery-<?php echo $gallery->ID ?>">
    
    <!-- Thumbnails -->

    ————————————————————
    After:

    <div class="ngg-galleryoverview" id="ngg-gallery-<?php echo $gallery->ID ?>">
    
    <strong><h3><?php echo urldecode($_SERVER['QUERY_STRING'])?></h3></strong>
    
    <!-- Thumbnails -->

    I’ve used the decode function to avoid spaces and accentuation issues.
    Maybe it’s not the best solution, but it’s a simple one and works for me. ??

    Thread Starter svb_wm

    (@svb_wm)

    Thanks for the information. Now when I use
    <?php echo $picture->title ?> to display the title of the gallery on the top above the list of thumbnails, there is no effect at all and using <?php var_dump($picture) ?> I get the result NULL. So am I doing wrong and you can tell me the right way or should I simply wait for the next release? I only want to put the gallery title at the beginning of the gallery.php template in line 18 after <div class="ngg-galleryoverview" id="ngg-gallery-<?php echo $gallery->ID ?>">

    I think a description which variables can be used in the templates would be useful, could you add this to an upcoming release?

    Thread Starter svb_wm

    (@svb_wm)

    @sjardim: Oh, thank you. We posted at the same time. I tried it according to your description but <?php echo urldecode($_SERVER['QUERY_STRING'])?> now shows page_id=9&album=4&gallery=3&Gallerytitle as headline in gallery.php. How can I delete the “page_id=9&album=4&gallery=3&”? Maybe that solution only works with mod_rewrite and permalinks like https://url.com/%postname%/?

    @svb_wm: Hum, that’s true, I’m using mod_rewrite and permalinks.
    My link looks like: example.com/nggallery/page-91/album-1/gallery-2?Hall%20of%20Fame

    But you can make it works for you by using two php functions for instance. There are other ways to do it, but let me show you how to do using the substr() and strrchr() functions;

    <?php
    $url = urldecode($_SERVER['QUERY_STRING']);
    
    /*strrchr finds the last appearance of the '&' string and returns it and the last characters. So, using substr we remove the first char of this new string, in this case the '&':*/
    
    $galleryTitle = substr(strrchr($url, '&'), 1);
    
    echo $galleryTitle;
    
    ?>

    Give it a test!

    Don’t use the function above!
    If you have an & within your gallery title, like “Blue & Bananas”, the function will return only “Bananas”, so I made an improvement:

    <?php
    
    	//function when not using permalinks with mod_rewrite
    	$url = $_SERVER['QUERY_STRING'];
    
           //eg: page_id=9&album=4&gallery=3&Blue%26Bananas"
    	/*strrchr finds the last appearance of the '&' string and returns it
    	and the last characters. So, using substr we remove the
    	first char of this new string, in this case the '&':*/
    
    	$galleryTitle = substr(strrchr($url, '&'), 1);
    	echo urldecode($galleryTitle);
    ?>

    To add to this discussion, the actual <title> of gallery pages are in English and maybe not like you really want it to show. As an example on my homepage a gallery page <title> is shown like this (i’m using AIO Seo)

    Gallery 1 ? Fotoalbum | Eyesx
    Gallery 1 ? Sida 2 ? Fotoalbum | Eyesx

    I’m guessing “Gallery 1” is simply “gallery” and the ID of the gallery. I think this rather should show the gallery name minus the “Gallery” part, like this

    My images from ? Fotoalbum | Eyesx
    My images from ? Sida 2 ? Fotoalbum | Eyesx

    This should be at least translatable. Or maybe I’m missing something here?

    Keep up the great work Ruben!

    Just found the problem part, line 191,192 in rewrite.php

    if ( !empty($gallery) )
    	$new_title .= __('Gallery', 'nggallery') . ' ' . $gallery . $sep ;
    Thread Starter svb_wm

    (@svb_wm)

    @sjardim: Thank you very much, now it works for me!

    @damst: You are right, but I think it would be better to have it like

    Your Blogtitle | Gallerypage ? Album 1 ? Gallery 1

    where “Your Blogtitle” is taken from the “settings” –> “main” page and “Gallerypage” is the name of the page the pictures are displayed on. Did you find out where to change this?

    @svb_wm, as my blog title is rewritten by AIO SEO for me thats not the answer.

    Considering what to show in the form of gallery ID or name I rather like to show the names as the IDs might not be in a logical order corresponding to the way gallerys/albums are shown on the page. Maybe the best would be to have an option in the dashboard what to show.

    Any news on this topic?
    My two questions would be:

    1. How can i make permalinks work with the image browser?
    To avoid this in the URL: /nggallery/page-162/page/315
    Until I enter the image browser permalinks work fine.

    2. How can i make NGGallery return the image description/alt/title
    in the page title rather than the image ID Number?

    And like DaMst mine is rewritten by AIO SEO.

    I found the part in rewrite.php that is responsible for question 2 but i dont know how to parse the image alttext or description.
    I figured that the line where the variable pid is triggered is responsible.
    just need the code for how to parse image description
    any help would be great.

    thanks
    sascha

    below the part of the php file

    function rewrite_title($title) {
    
    		$new_title = '';
    		// the separataor
    		$sep = ' | ';
    
    		// $_GET from wp_query
    		$pid     = get_query_var('pid');
    		$pageid  = get_query_var('pageid');
    		$nggpage = get_query_var('nggpage');
    		$gallery = get_query_var('gallery');
    		$album   = get_query_var('album');
    		$tag  	 = get_query_var('gallerytag');
    		$show    = get_query_var('show');
    
    		//TODO:: I could parse for the Picture name , gallery etc, but this increase the queries
    		//TODO:: Class nggdb need to cache the query for the nggfunctions.php
    
    		if ( $show == 'slide' )
    			$new_title .= __('Slideshow', 'nggallery') . $sep ;
    		elseif ( $show == 'show' )
    			$new_title .= __('Gallery', 'nggallery') . $sep ;	
    
    		if ( !empty($pid) )
    			$new_title .= __('Picture', 'nggallery') . ' ' . $pid . $sep ;
    
    		if ( !empty($album) )
    			$new_title .= __('Album', 'nggallery') . ' ' . $album . $sep ;
    
    		if ( !empty($gallery) )
    			$new_title .= __('Gallery', 'nggallery') . ' ' . $gallery . $sep ;
    
    		if ( !empty($nggpage) )
    			$new_title .= __('Page', 'nggallery') . ' ' . $nggpage . $sep ;
    
    		if ( !empty($tag) )
    			$new_title .= $tag . $sep;
    
    		//prepend the data
    		$title = $new_title . $title;
    
    		return $title;
    	}

    It looks like alexrabe will integrate an official solution in an upcoming nextgen release.

    Until then, if you want to display the gallery title on a gallery page, edit the ‘gallery.php’ file (it’s within the ‘view’ folder within your nextgen plugin folder), and add this code where you want the title to be displayed:

    <?php echo $images[0]->title; ?>

    This works for nextgen v.1.0.2.

    Hope this helps.

    Anonymous User 1461502

    (@anonymized-1461502)

    works great – thx

    Hi there,

    I tried

    <?php echo $images[0]->title; ?>

    within my index.php (in the loop). It does not work.

    In the loop I have the php code to post based on the post-tag the related gallery (again based on the matching gallery tags).

    I would like to post the title of the gallery right above the gallery.

    Is there a simple php code which I can place in the index.php (loop)?

    Your help is highly apreciated!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: NextGEN Gallery]: Show gallery titles on gallery page’ is closed to new replies.