Posts Tagged ‘gallery2’

  1. WPG2 and new theme

    After failing to find a theme for my blog I liked well enough, I finally took the plunge and designed this one, as much as possible from scratch. There’s stuff in from the default theme, as well as good colours from all over the place. I may eventually release it when I’m sure that it’s actually complete, and that weird bugs are mostly ironed out.

    The plus side is that the WPG2 plugin I couldn’t get to work on my previous theme now works perfectly, which is good news as I can stop using the kludged together iframe tag gallery page I used before.

    The only problem I encountered was using the wp_list_bookmarks() function so that I could use WordPress’s built in link manager. The default list outputs the description seemingly as an afterthought, which is very annoying when you would like to style it. Using get_bookmarks() is more flexible but doesn’t allow you to pull out the categories.

    By digging into the core files I found out how the WordPress team did it, and wrote my own (much simpler) bit of code, put it in as a template and produced my own links section with a styleable link description:

    Place this in a template, I called mine links
    	<ul class="link-list">
     
    	< ?php
     
    		// This line gets all of the link categories
    		$cats = get_terms('link_category', array('name__like' => '', 'include' => '', 'exclude' => '', 'orderby' => 'name', 'order' => 'ASC', 'hierarchical' => 0));
     
    		// loop through the categories
    		foreach($cats as $cat)
    		{
     
    			// Put the categories into a list
    			echo "<li id='linkcat-".$cat->term_id."' class='linkcat'>";
     
    			echo "<h2>".$cat->name."</h2>";
     
    			// Get the bookmarks that are a part of the current category in the loop
    			$bookmarks = get_bookmarks(array('category'=>$cat->term_id));
     
    			echo "<ul>";
     
    			// Loop through each of the bookmarks that are part of the category
    			foreach($bookmarks as $bookmark)
    			{
     
    				echo "<li>";
     
    				echo "<a href='".$bookmark->link_url."' >".$bookmark->link_name."</a>";
     
    				// if the link description exists, output this
    				if($bookmark->link_description)
    				{
    					echo " &raquo; ";
     
    					echo "<div class='link-description'>".$bookmark->link_description."</div>";
     
    				}
     
    				// If an image exists as part of the link, output that.
    				// The image is linked to the URL of the link it is a part of
    				if($bookmark->link_image)
    				{
     
    					echo "<div>";
    					echo "<a href='".$bookmark->link_url."' >";
    					echo "<img src='".$bookmark-/>link_image."' alt='Image for ".$bookmark->link_name."' />";
    					echo "</a>";
    					echo "</div>";
     
    				}
     
    				echo "</li>";
     
    			}
     
    			echo "</ul>";
     
    			echo "</li>";
     
    		}
    	?>
     
    	</ul>
  2. WordPress and Gallery 2

    There appear to be two ways of doing this:

        WP2G plugin This way is supposed to be quick and painless, but I found it was pretty much the other way. Lots of things you need to do to get initially setup, and does not integrate well with themes that are not specifically designed for it1. Overall, a lot of effort.
        use an iframe Ok, not XHTML strict compaitible, so you could use the object tag2, but this does allow the gallery to work flawlessly without any fuss, apart from long pages causing scroll bars. The gallery was embedded in a page using the template system, and is currently hard coded. This isn’t perfect, but it works.
    The widgets that come with the WP2G plugin are tightly integrated with it, so I ended up making my own. Needs a lot of work before I can release it though, as it’s current state is about as secure as a prison made of jelly.
    1. strange things happened with this one, causing the gallery to appear in the sidebar
    2. Something I’ll get around to doing myself