WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: NextGEN Gallery]: Show gallery titles on gallery page (18 posts)

  1. svb_wm
    Member
    Posted 5 years ago #

    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 (http://wordpress.org/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.

  2. Alex Rabe
    Member
    Posted 5 years ago #

    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...

  3. Alex Rabe
    Member
    Posted 5 years ago #

    Fix will be added to next release : http://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...

  4. sjardim
    Member
    Posted 5 years ago #

    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. :)

  5. svb_wm
    Member
    Posted 5 years ago #

    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?

  6. svb_wm
    Member
    Posted 5 years ago #

    @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 http://url.com/%postname%/?

  7. sjardim
    Member
    Posted 5 years ago #

    @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!

  8. sjardim
    Member
    Posted 5 years ago #

    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);
    ?>
  9. Mattias Tengblad
    Member
    Posted 5 years ago #

    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!

  10. Mattias Tengblad
    Member
    Posted 5 years ago #

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

    if ( !empty($gallery) )
    	$new_title .= __('Gallery', 'nggallery') . ' ' . $gallery . $sep ;
  11. svb_wm
    Member
    Posted 5 years ago #

    @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?

  12. Mattias Tengblad
    Member
    Posted 5 years ago #

    @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.

  13. Sascha Rossaint
    Member
    Posted 5 years ago #

    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;
    	}
  14. justinbarkhuff
    Member
    Posted 5 years ago #

    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.

  15. ollitsch
    Member
    Posted 5 years ago #

    works great - thx

  16. Barandum
    Member
    Posted 4 years ago #

    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!

  17. Barandum
    Member
    Posted 4 years ago #

    Is it possible to call

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

    within the loop of index.php?

  18. morethanever
    Member
    Posted 4 years ago #

    I made a nice & simple Breadcrumb trail in gallery.php:

    <div class="entrytitle">
    	<h2><a style="h2" href="www.website.com/gallery" alt="Gallery">Gallery</a>&nbsp;>&nbsp;<span class="gallerytitle"><?php echo $gallery->title ?></span	>
    	</h2>
    </div>

    The problem I was having was the category permalink would also show from the file index.php.

    So I duplicated the original index.php
    as index-default.php, and replaced the original
    index.php code with:

    <?php
    $post = $wp_query->post;
    if ( in_category('7') ) {
    include(TEMPLATEPATH . '/index-gallery.php'); }
    else {
    include(TEMPLATEPATH . '/index-default.php'); }
    ?>

    So index-gallery.php is a duplicate of the original
    index.php with the title & permalink code removed.

    I guess i could have just put an IF statement
    in the original index.php, but I didn't know
    how to carry the gallery title variable from
    gallery.php. Hope this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Topic