Added some menu functions

Filed Under This Site | Comments (1) | Page Tools

I’ve had a chance to tweak the site a bit, adding some new plugins to help with the menus and using some Wordpress role capabilities to hide/control some content. Plus I’ve put a login form and logout function on the main page.

Collapsing Menu’s

As the content of this blog has grown so has the length of the menus, in particular the categories and archives menu’s. I came across two very useful plugins (by the same author) to control this better: Collapsing Archives and Collapsing Categories. Both allow expansion/compression of the menu’s.

I had to modify my sidebar code to accomodate them; checking to see if the function is loaded and if so, run it. The category mods look like this:

<h2><?php _e('Categories:'); ?></h2>
<?php
   if (function_exists('collapsCat')) {
      collapsCat('%i%');
   } else {
      echo "<ul>\n";
      wp_get_categories(0, '', 'name', 'ASC', '/', true, 0, 1);
      echo "<ul>\n";
   }
?>

The code for the archives menu is similar.

It made sense to revisit my categories and convert them from a flat structure to a hierarchical structure. This seems to work a lot better.

Hiding/Disabling Pages

I have a few pages on this site that are more for me to manage the site than for general consumption.

I had applied the Wordpress page visibility mechanism to remove general visibility to the pages in question. However it seems you can use the full URL to get to the page evan if not logged in. So I installed the Member Access plugin to control this behaviour. Now if a direct URL link is used to go to one of the restricted pages, it redirects back to the login page.

There was one more point of annoyance; even though the page itself is not visible to the unauthenticated, it showed up in the links (across the top the pages) due to the wp_list_pages() function I was using. I found that there is a way to exclude specific pages:

<?php wp_list_pages('exclude=33&title_li='); ?>

So, I’d limited access to and visibility of the page. But how to show a link to it for specific users? A feature of the Wordpress Roles and Capabilities feature is the ability to query. You can use the current_user_can() in an if loop to determine if some content is shown based on the role level of the current user.

I found a blog post, Frontend Admin Menu in Wordpress, that showed an example of this. Thanks to the author for this.

Login/Logout

From the same site I used the Admin Login on Your Front Page tutorial to add a login form to the main page of the blog. There are no registered users (except me) but it’s certainly useful for testing admin vs. unauthenticate user functions easily.

Page Tools

  • RSS
  • Email this Post
  • Print This Post

Tags: , , , ,

Related posts:

  1. Added a few more bits’n'bobs
  2. Managing WP Plugin Customisation

Comments

One Response

  1. [...] with the changes I made last weekend (Added some menu functions) I’ve added a few other plugins to make the blog a bit more usable. These included adding [...]

    Comment by Added a few more bits’n’bobs | davidedwardsphotos.com at August 7th, 2009 at 7:17 pm

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.