• Resolved Travis Ballard

    (@ansimation)


    basically i want to know if there is a way that i can include an image gallery through a template file. i have a page that basically has a map on it and queries the database to see if a poast was written with the same title as the page, if so, it includes the post on that page. i was going to query the nextgen database to see if a gallery exists with the name of that page and if it does, include a gallery on that page as well. unfortunately this isn’t something that can be done through the post section and would need to be done in the template file so any help here would be great. even if i have to call nggShowGallery() (tried this but i cant get it to work..) so any help here would be great.

    Thank you,
    Travis

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Travis Ballard

    (@ansimation)

    nevermind, a little echo did the trick.

    Hello,

    I am trying to do something similar, but I have got nowhere yet. Would you mind sharing the bit of code you used ? That would be great, thanks.

    Thread Starter Travis Ballard

    (@ansimation)

    well basically i ended up just checking to see if the gallery existed with the same name as the title of the current page and if it did, showed a link to it. if you still need it, 10 months later… the code is below.

    // GALLERY FUNCTIONS - 07.06.08
    	function has_gallery($title)
    	{
    		global $wpdb;
    		$table = $wpdb->prefix . "ngg_gallery";
    		$sql = "select count(gid) from " . $table . " where title like '%" . str_replace(".","",$title) . "%'";
    		if ( $wpdb->get_var($sql) != 0 )
    			return true;
    		else
    			return false;
    	}
    
    	function get_gallery($title)
    	{
    		global $wpdb;
    		$table = $wpdb->prefix . "ngg_gallery";
    		return $wpdb->get_var("select gid from " . $table . " where title like '%" . $title . "%' limit 1;");
    	}
    
    	function gallery_link( $title )
    	{
    		global $wpdb;
    		$table = $wpdb->prefix . "ngg_gallery";
    		return '<p class="gallery-link">For more photos from ' . $title . ', please visit the <a>get_var("select name from " . $table . " where title like '%" . str_replace(".","",$title) . "%' limit 1") . '/">' . $title . ' Photo Gallery</a></p>';
    	}
    
    	function gallery_link_no_article( $title )
    	{
    		global $wpdb;
    		$table = $wpdb->prefix . "ngg_gallery";
    		return '<p class="gallery-link">Even though we haven\'t written an article about ' . $title . ' yet, we have been there and have added a gallery for you to view. Please visit the <a>get_var("select name from " . $table . " where title like '%" . str_replace(".","",$title) . "%' limit 1") . '/">' . $title . ' Photo Gallery</a> to view the photos from this park.</p>';
    	}
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: NextGEN Gallery] Gallery in template file?’ is closed to new replies.