Archive for the 'Wordpress' Category

Searching through image tags with Nextgen Gallery

July 13th, 2009 posted in Code, Wordpress | 4 Comments »

I’ve been looking at the image tags functions in Nextgen Gallery and it was painfully obvious that there should be a way in there to search images by tags using only the regular search box. While i did some research I found some solutions but they were awkward or not functioning, but with some piecing together of different code I found a way. Find the following line in your search.php file. If you don’t have a search.php file you can copy the index.php and rename it too search.php.

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

And then place the following code just below it. It basically adds the [nggGalleryTags] shortcode to the page and lists the pictures using NGG formatting on the page.

<?php
if(is_search()) {
$search = $wp_query->get('s');
$keywords = preg_replace('/\+/',' ',$search);
if (function_exists ('nggShowGalleryTags')) {
$nggpictures = nggShowGalleryTags($keywords);
if ($nggpictures) {
echo "<h2>Pictures</h2>"
echo $nggpictures;
}
}
}
?>;

If you type some keywords in the standard searchbox you will see that it lists an additional search results with your images.

MTG-Helper V1.1.1 deck listing fix

July 8th, 2009 posted in Code, Wordpress | No Comments »

I was trying to add my favourite MTG decks to the site in with help of the MTG-Helper. The plugin offers a nice presentable way to showcase your decks. Beats writing your own! One thing i noticed was that the decklist had an error with generating urls. In the file MTG-Helper-parser look for the sentence ‘//cardname and link to the cardbox’. Replace the code there with the code below.

//cardname and link to the cardbox
$content .= "<span class='cardname'><a style='font-size:'.get_option(mtghFontSize).'";
if( $add_class == "" )
$content .= "color:".get_option(mtghFontColor)."";
$content .= "' class='$add_class' href='#' onmouseover=\"jQuery('#{$id}_box').show().attr('src','" . get_source_from_name($cards[$j]["cardname"])."');"
onclick=\"return false;\"> ".$cards[$j][&quot;cardname&quot;].:</a></span></li>";
}

That should fix the links and show the card images.

Rebuilding the Next-Gen templates

June 8th, 2009 posted in Code, Wordpress | No Comments »

With the new release of Next-Gen I figured i should finally clean up my templates and make them behave a little better. The old version doesnt really work with the ng floating css so it impossible to place an item to the right side. I got that fixed now so you can position the images to the left and right. Actually havent tried centering it yet  but it’s still a work in progress at the moment. Once i’m happy with it i’ll put it on the website for download.

I also read the code should be able to load templates from the theme directory, while this worked in the previous version it didnt go very smoothly. If this indeed is working better now, i can finally use the templates in my themes without losing them each upgrade.