WordPress drill-down admin pages II

January 18, 2010

wordpress-logo-300x300I never did do a follow-up on the WordPress drill-down admin menus post. A lot of people continue to hit that article so I’ll take the time to give an example of how I easily resolved the issue.

The problem was that after an upgrade to WordPress Mu v 2.8.4a all my dynamically created, drill-down admin pages quit working because they now needed to be registered with WordPress for — completely understandable — security reasons.  As far as I can tell, the only way to register an admin page is through the menu system. Since I don’t want my drill down pages to be on the menu I needed a better way to do it.

One solution suggested was to just use the registered menu page as the callback to handle requests and that is for the most part what I did. The only issue with the solution is that the callback page has to also serve all the content since it can’t request an admin page that is not registered. Using one page to parse all requests and serve the appropriate content will get unwieldy for anything but the simplest of applications and if your application was that simple you wouldn’t be trying to figure out how to add custom drill-down admin menus.

I like modularity and easily managed code so my philosophy is that multiple small files are better than one huge file. I needed a way to solve the problem without breaking my philosophy or changing a lot of my existing code, which was already in multiple small files.

The idea is to build a container page to register on the admin menu and have the container page decide on which code to include based on analyzing the url. The included code can then handle and GET or POST requests and serve the appropriate page output.

<?php
/*
 * Descrition: gcgc admin page. This is the main container page
 * for all admin panels. All POSTS and GETS from all pages route
 * through this page and are handled by the appropriate included file.
*/
global $gcgc_Manager;
echo $gcgc_Manager->getHeader();
//analyze the url to determine which page to load

if (isset($_GET['panel'])){
    switch ($_GET['panel']){

    	case 'cache-admin' :
    	    include (dirname(__FILE__)."/gcgc-admin-cache.php");
    			break;

    	case 'vector-admin' :
           include (dirname(__FILE__)."/gcgc-admin-vector.php");
           break;

    	default :
           include (dirname(__FILE__)."/gcgc-admin-home.php");
    }
}else{
    include (dirname(__FILE__)."/gcgc-admin-home.php");
}

$gcgc_Manager->getFooter();
?>

I kept the above example brief but you can imagine that there can be an unlimited number of admin pages. And this way I didn’t have to change the included files at all — all I had to do was add the ‘&panel=’ parameter to existing request urls and problem solved.

  • Share/Bookmark

Sooo quiet in here

February 15, 2009

I finally cut power to the Dell Poweredge 6300 last night at about midnight, right before I went to bed.  It is so quiet in the TheGarage this morning I can’t hear myself think.  I bet I’ll get readjusted in no time.

I have made some changes to the doncallaway dot org domain. The top level domain, doncallaway.org (dcdo)  now points to a WordPress Mu blog and serves a static splash page that points to all my other stuff.  The splash page is quite simple at the moment but I will be setting up the BDP-RSS Aggregator plugin to replace the simple linkage with fancy aggregated RSS feeds. For a great example of what you can do with BDP-RSS plugin, check out the Edublogs site.

This blog along with several other blogs will be migrated into the dcdo Mu database today using a top level domain configuration, meaning that garagetechblog.com will still point to this blog. However, if you were linking here from doncallaway.org, which has been pointing here since I shut down the Domino web server running on the Poweredge, you need to change your bookmark. Please.

After I finish moving a couple of blogs into the dcdo Mu environment, I am going to move the Gulf Coast Texas Blog into the Gulf Coast Texas Bloggers Mu database. It’s ridiculous not to. Just like how not allowing embed tags in Mu is ridiculous. I am going to make the hack and we will have embeded video in the GCT Mu installation and the dcdo Mu installation since they are both relatively closed systems.  I don’t recommend the hack for wpmu systems open to the public.

  • Share/Bookmark

Huh? No embeded video in WordPress Mu

February 12, 2009

I just found out that WordPress Mu disallows embed tags within blog posts. No YouTube, no Flikr, no nothing. The reason given is security issues, of course. Details here.

On the one hand I can see how if you are allowing people to sign up and create free blogs on the fly you would want to be very careful with what someone is allowed to inject into your database with an embed tag. On the other hand I don’t see how  you are going to get people to use your fancy blogging service when they aren’t allowed to embed YouTube or Flikr  videos. There is an easy enough workaround that has been made even easier packaged as a WordPress plugin, but, hey, you know I really don’t want people injecting malicious stuff into my database.

I also found out that WordPress Mu disallows the execution of php and javascripts. Again, for a multi-user installation that has hundreds of users this is the only course. But for a semi-closed setup like the one I am working on now, I want the flexibility to do whatever I want. To get dynamic output in the content area of a page you can use a workaround as described here. Inserting the code for an RSS aggregator is discussed but the technique is good for many things.

To inject code directly into a WordPress Mu post, forget about it. I have a project on the drawing board where I want to use custom fields and have appended to each post a series of dynamically created MySql queries of the custom fields to create tables, charts, etc. For now, the only choice for that is to have a bunch of php pages pre-defined with the queries and then use an ajax-like method to inject the results into a page elements’s innerHTML. Even if all that can be done it’s hardly the definition of dynamic is it? The alternative is to use a stand-alone WordPress installation and install the exec-php plugin, which is probably what I’ll do.

  • Share/Bookmark

WordPress mu installations

February 3, 2009

I’ve been fighting with WordPress MU all day. I’ve installed it five times if I’ve installed once.  The problem turned out to be that you can’t install WPMU in a sub-directory off a directory that has an existing WordPress installation, as discussed here.

I finally got the beast beat down and was able to at last set up a new test blog. Unfortunately, this means I now have two more blogs to theme out like the the rest of the Gulf Coast Texas site, which is kinda the purpose of the whole exercise I guess. While I am moving the Gulf Coast Texas Blog theme over to the new WPMU blogs, I will document all the global customizations along with site specific customizations so they can be easily duplicated when setting up new blogs. When I have all my css modifications I can put them in a custom css sheet along the lines descibed here.

  • Share/Bookmark

Versatility using symbolic links

August 27, 2007

I noticed over the weekend that my domain dcdo isn’t working. The tip off was that I wasn’t getting any spam in my inbox. How likely is that not to happen, really? Ping returns the new IP address but doesn’t reply. Probably some further adjustment to the DNS records needs to be made.

I haven’t taken the time to mess with the DNS issues because I haven’t been here much except for on weekends and this past weekend I was busy trying to figure out how to run WordPressMU; the multi-blog, mult-user version of the software I am running now. This is a key step in the process of changing my infrastructure from Domino to hosted WordPress. It wont be any fun maintaining and posting to a half-dozen or so blogs that each have a seperate installation.

Like on the other thing I got it working half-assed but then I had to keep tinkering with it to make it work how I want it too. The closest configuration I found as a model was from Dan Frey at the Office of the Provost Web Team blog at the University at Buffalo:

“Our situation is interesting, but I would not call it unique. We have a server that has multiple domains pointed at it. We installed MU in a directory off of the root of our server, /wordpressmu. Our default domain name is ugly – the idea was that we wanted folks to be able to go to nicedomain.buffalo.edu and get to their blog on our server.

Easier said than done…

Yep pretty much what I’ve found out. My situation is the same except I want to point any domain to any blog regardless of where the blog is and regardless of where the domain is. This is what I have so far:

Domain setup

I know the symlinks are the way to go and that’s how I found Dan Frey’s article–by Googling wordpress mu symbolic link. I’m pretty sure Dan has it figured out I just have to tinker with it some more.

But dang I can’t mess around with it forever. It’s one of those deals that I’ll have to revisit after I get a few other things worked out, like my damn mailserver at dcdo.

  • Share/Bookmark