WordPress.org

Forums

[resolved] [Plugin: NextGEN Gallery] Gallery in template file? (4 posts)

  1. Travis Ballard
    Member
    Posted 6 years ago #

    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

  2. Travis Ballard
    Member
    Posted 6 years ago #

    nevermind, a little echo did the trick.

  3. deWINTER
    Member
    Posted 6 years ago #

    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.

  4. Travis Ballard
    Member
    Posted 5 years ago #

    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>';
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic