Better links for Neuron.

Published 3.08.2006 by ~mattg

So Scott emailed me yesterday enquiring about utilizing the link categories available in Wordpress. A quick search of the codex and some minor mods to the template and presto, categorized link menus, independently expandable and collapsible.

Eventually I’ll get around to releasing a new version of Neuron for version 2.0 (although the 1.5 theme works fine in 2.0, AFAIK). So I’ll post the code here, and if you want it in your Neuron theme, replace the current Blogroll List code in sidebar.php with the code below. Thanks to Scott for making me switch gears long enough to get this little fix done.

<!– Begin Blogroll list –>
<?php
$link_cats = $wpdb->get_results(“SELECT cat_id, cat_name FROM $wpdb->linkcategories”);
foreach ($link_cats as $link_cat) {
?>
                <div class=“menuheader”><div><?php _e($link_cat->cat_name); ?></div><a href=“javascript:switchit(’<?php echo $link_cat->cat_id; ?>_list’,'<?php echo $link_cat->cat_id; ?>_img’,'<?php bloginfo(’stylesheet_directory’);?>’)”><img id=“<?php echo $link_cat-/>cat_id; ?>_img” alt=“Open/Close button” src=“<?php bloginfo(’stylesheet_directory’);?>/img/up_light.gif”/></a></div>
                <ul id=‘<?php echo $link_cat->cat_id; ?>_list’>
                <?php get_links($link_cat->cat_id,‘<li>’,‘</li>’,‘ ‘,false,‘id’,false,false,-1,false,true); ?>

                </ul>
<script type=“text/javascript”>initit(‘<?php echo $link_cat->cat_id; ?>_list’,‘<?php echo $link_cat->cat_id; ?>_img’,‘<?php bloginfo(’stylesheet_directory‘);?>’,‘false’);</script>
<?php } ?>
<!– End Blogroll list –>

Here is a “copy-and-paste” formatted version.

Filed under Web Development

Comments (4)

Comments RSS - Trackback - Write Comment

  1. PeterBey says:

    Also came here looking for the categories fix, looks like I came on the right day!

    Anyway copied the code accross and then got “Parse error: parse error, unexpected T_STRING” Did I do something wrong? I have WP2. Peter

    Posted 3.12.2006 @ 10:04
  2. ~mattg says:

    Peter,

    In noticing how the code is formatted on my site, make sure the PHP code is one a single line, particularly the string inside the get_results() call. I’ll post a link in the post with copy-and-paste formatted code.

    Posted 3.13.2006 @ 07:57
  3. PeterBey says:

    Thanks, that’s got it going. PHP for dummies with me I’m afraid. P.S. I got your theme from the competition at WP, nice work. Miles ahead of some of the opposition that’s for sure.

    Posted 3.13.2006 @ 15:13
  4. ~mattg says:

    Thanks for the compliment… If I ever find time I’ll have to see what’s changed between 1.5 and 2.0 and make some adjustments to the theme.

    Let me know if you have any troubles.

    Posted 3.13.2006 @ 20:09

Write Comment