Notions

Archive for the ‘Web Design’ Category

Finding the perfect gallery

September 6th, 2009

galleryWhile I have found Wordpress to be an extremely extensible, flexible and usually friendly platform to use as a CMS, there is one area where it lacks.  I can’t believe that with all its revisions there isn’t a more integrated, easier to manage photo package to handle galleries, albums and individual images.

Without the use of a plugin, the stock tools are fairly simplistic.  Out of the plugins out there today, the only one that outshines the rest is NextGEN gallery.  That said, NextGEN isn’t without its limitations and I have been finding myself torn between using it for its friendly interface and just forgoing an integrated solution–sticking to HTML/CSS on custom template pages.

But why choose?  I have decided on the following solution.  I am going to have two separate paths.  Instead of just one “Photography” section with all photographs underneath, I am splitting that into “Snapshots” and “Gallery.”  This way I can use the speed of NextGEN on the bulk of photos not meriting much attention.  Then, the photos I decide to showcase I can handcode a custom design template within the existing theme to display them in a more more stylish manner.

Look for changes to come!

I just had a question pertaining to my post on replacing a widget title with an image in the widgets.php file.  The question was “Can I keep the title AND add an image?”  The answer is of course.  Basically you just keep the $title variable in the script and add to it depending on where you want the image.

Calendar widget example from 2.7 widgets.php file in the wp-includes folder (make backup!!):

/**
* Display calendar widget.
*
* @since 2.2.0
*
* @param array $args Widget arguments.
*/
function wp_widget_calendar($args) {
extract($args);
$options = get_option(‘widget_calendar’);
$title = apply_filters(‘widget_title’, $options['title']);
if ( empty($title) )
$title = ‘ ’;
echo $before_widget . $before_title . $title . $after_title;
echo ‘<div id=”calendar_wrap”>’;
get_calendar();
echo ‘</div>’;
echo $after_widget;
}

You will be working on the line:

echo $before_widget . $before_title . $title . $after_title;

Basically, you decide where you want the image (before or after the title), then insert:

‘<img src=”path to your image”>’

either before:

. $before_title

or after:

.  $after_title

Just make sure you place periods before and after the image declaration and make sure the line ends with a semi-colon.  I would also add a class to the image to better control its position in CSS.  I guess you could try just using .widget img {property: xx;} to your CSS, but that would alter all images in the widget class.

i.e.

echo $before_widget . $before_title . $title . $after_title . ‘<img src=”images/accent.gif” class=”whatever”>’;

Hope that helps!

Header titles for Wordpress widgets are pretty much hardcoded into the guts of default code.  Changing some of the titles to custom image files was easy except for the Blogroll.  There I had to find the workaround  after digging around a bit.  Here is the solution I have seen others ask for.

If you would like to change each of the titles to an image, you need to hack the widget.php file. For each widget you are going to use, look for the following (using the calendar entry as an example):

function wp_widget_calendar($args) {
    extract($args);
    $options = get_option('widget_calendar');
    $title = apply_filters('widget_title', $options['title']);
    if ( empty($title) )
        $title = '&nbsp;';
    echo $before_widget . $before_title . $title . $after_title;
    echo '
';
    get_calendar();
    echo '
';
    echo $after_widget;
}

Replace:

echo $before_widget . $before_title . $title . $after_title;

with:

echo $before_widget . $before_title . '' . $after_title;

For the links widget, you need to edit the bookmarks-template.php file.  Look for the following block:

 function wp_list_bookmarks($args = '') {
    $defaults = array(
        'orderby' => 'name', 'order' => 'ASC',
        'limit' => -1, 'category' => '', 'exclude_category' => '',
        'category_name' => '', 'hide_invisible' => 1,
        'show_updated' => 0, 'echo' => 1,
        'categorize' => 1, 'title_li' => __('Bookmarks'),
        'title_before' => '

', 'title_after' => '

',
        'category_orderby' => 'name', 'category_order' => 'ASC',
        'class' => 'linkcat', 'category_before' => '
  • ',
  •         'category_after' => '
    
    '
        );

    Change:

    'categorize' = 1, 'title_li' = __('Bookmarks'),

    to:

    'categorize' = 0, 'title_li' = __(''),



    That should take care of it without resorting to some third party plugin. Remember, make a backup of both these files so you can return to normal if you want in the future. Also know that if you upgrade your installation, the changes will disappear. So make a backup of the altered files as well.

    Reblog this post [with Zemanta]