Tweaking web2project – overriding the Help button

Overview

When I moved to a new position a few months back, the team that I shifted to had just started using web2project for managing and tracking project activity. It comes with the ability to setup various custom fields and do all sorts of project manage-y things that I try to avoid and let the PMPs deal with.

But despite all of the features of web2project, my peers still wanted more than it offers out of the box. There are a number of ways in which it is lacking flexibility or configurable options that my teammates need. I needed to address their concerns while avoiding altering the PHP source code of the application as much as possible. Doing so will make it easier to deploy official upgrades to the application while retaining our customizations.

So I created a tweaks.js javascript file and simply modified ui.class.php script to output a script tag to include it on all pages. I added the output for this just after where it loads the base.js file. We are not yet running the latest version here, but it seems like the most recent code has moved things around. This change will need to be included in the CAppUI.class.php in the latest vesrion of web2project. Since I’m using jQuery as well, I also modified the PHP file to include that before my tweaks.js.

The help button tweak

One other thing I did since coming on to this team is to setup an internal MediaWiki based wiki. We decided to write articles about all things useful for our team in this wiki. This will include the help information for using web2project. The tweak I created finds the Help button by the text and then replaces the functionality of the anchor tag that handles the click event when you click the button.

I also decided to make it easy to add additional help overrides for different pages throughout the site. The code implements some logic to walk a structure where you define alternative help URLs and a set of matching criteria. It takes this matching criteria and checks against the query string to see if an alternative should be used instead.

And then the final thing is to just include a call to run the setHelpUrlfunction at the end of your tweaks.js file.

$(document).ready(function(){
// Override the Help button URL on all pages
setHelpUrl();
});

After that, clicking on the Help button on any of the pages will cause it to route to a URL of your choosing. All without having to really modify the PHP code (other than that one thing to include the .js).

One thought on “Tweaking web2project – overriding the Help button”

First of all, welcome aboard. If you have any feedback, tips, or annoyances, please let me know. We treat the FAQ as a list of things that should be fixed and I’m always happy to add more.. well, not happy exactly, but along those lines. 😉

Next, instead of using the hardcoded include, you may be able to include your tweaks.js via the addFooterJavascriptFile method on the AppUI class. Its purpose is to allow modules to include their own js files, but it should work as you plan. Plus that should be upgrade safe.

Longer term, you should see a *huge* amount of refactoring in the pending v3.0 release. In terms of OO-purity, it’s pretty solid but the real goal behind that is to allow module developers to write way less code and just use core functionality *if* they follow the naming conventions. I’ve updated some of my modules and have deleted upwards of 20-40% of the code.