Archive for category Sundry

Easy tab highlighting with included PHP menu

I recently reworked a simple PHP site that uses standalone PHP files containing only HTML. We needed to redesign the navigation bar, which was simple a series of clickable images. These files were not generated by a Dreamweaver template or anything like that, meaning that we would have had to manually change each file every time there was a change to the menu. That seemed very annoying to me, so I created a file called navbar.php and included it into all the pages, using the standard PHP include;

<?php include(‘navbar.php’);?>

The tabs are highlighted for the current page, so if you are on “About Us”, the About Us tab should be highlighted. To accomplish this, I wrote a simple function;

<?php
function isactive($filename){
$urlfilename = basename($_SERVER['SCRIPT_FILENAME']);
if($filename == $urlfilename){
echo “-hover”;
}
}
?>

A sample navigation tab would then look like this;

<a href=”consulting.php”><img src=”images/navbar-consulting<?php isactive(‘consulting.php’);?>.gif” name=”consulting” width=”104″ height=”35″ border=”0″ id=”consulting” onmouseover=”MM_swapImage(‘consulting’,”,’images/navbar-consulting-hover.gif’,1)” onmouseout=”MM_swapImgRestore()” /></a>

That simply uses the function to tell it which file name to match to the current page’s file name:

isactive(‘consulting.php’);

The end result is that on consulting.php, the HTML output for that tab would look like this:

<a href=”consulting.php”><img src=”images/navbar-consulting-hover.gif” name=”consulting” width=”104″ height=”35″ border=”0″ id=”consulting” onmouseover=”MM_swapImage(‘consulting’,”,’images/navbar-consulting-hover.gif’,1)” onmouseout=”MM_swapImgRestore()” /></a>

.. and that is done automatically using a single included file.


Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
1 Comment

please vote for EXIHT in Afric…

please vote for EXIHT in Africa.. an anti human trafficking nonprofit. Your vote will help with their funding: http://bit.ly/d3p5Ip

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

Using MySQL to insert missing text depending on field length

Suppose you have a MySQL database table containing US 5-digit zip codes, except some of them are just three or four digits long because they had leading zeros, and those sometimes get dropped. Here’s how to add them back in;

For 3-digit zip codes:

UPDATE zipcodes SET zip = CONCAT(’00′, zip) WHERE LENGTH(zip) = 3

This will turn ’123′ into ’00123′.

For 4-digit zip codes:

UPDATE zipcodes SET zip = CONCAT(’0′, zip) WHERE LENGTH(zip) = 4

This will turn ’1234′ into ’01234′.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

Impressions of Joomla 1.6 Beta 3

Well, Joomla came out with another 1.6 beta, and it has certainly come a long way. I remember testing a 1.6 beta two years ago. Here are some highlights;

Access Level Control (ACL)

It now features a robust ACL system, though some of the inheritance rules will take some getting used to. This is often cited as a feature Drupal has and Joomla lacks, but soon enough that will be a moot point. From my understanding there will be just one more beta in about two weeks, and then it should be time for 1.6!

Nested categories

Joomla always suffered from a rigid approach to categorization, with Sections and Categories. A section could contain categories, but there could be no sub-categories. This long-running annoyance has finally been been vanquished with Joomla 1.6. It uses only categories (no more sections!), and they can be nested as deeply as you want. I’m sure at some point someone will nest a category 666 levels down, and run into a terrible bug there … but in theory it should be fine, because a category would simply be assigned to a parent category .. the number of sub-levels should have no bearing on it.

Drupal has of course supported nested categories for a long time, where they are called Taxonomy. I think Drupal’s Taxonomy is still more advanced than Joomla 1.6′s category system, but for many, perhaps most users, just having nested categories is en0ugh. Those who want to do more advance PHP magic will naturally be more inclined towards Drupal anyway, and to words like Taxonomy.

The elimination of Joomla’s sections does mean that template code that relies on section IDs will have to be changed to be 1.6-compatible. It will have to check for category IDs instead. It also opens up an interesting possibility of (for example) using a database query to select only those categories that are nested within the current category. That could come in handy in displaying category ‘blogs’ or headlines in a more automated fashion than creating menu links. And speaking of menu links;

Menu Management

Joomla’s menu management has gotten very slick;

  • Changing the menu type is now faster.
  • Much more control over the menu items: meta data, page titles, robot rules, page class styling,  menu link title & CSS attributes.
  • Module assignment from a menu item. You can still assign modules to menu items, but now you can also do this from the menu item itself, rather than having to edit the module separately.
  • Batch processing multiple menu items
  • Language filtering; show your menu item only for certain languages, or for all of them. Would be nice if you could select several languages and hide it on others, but that may be coming.
  • Set template style

Redirect manager

Joomla 1.6 has a new component for managing URL redirects. Presumably this writes to the .htaccess file and created a 301 redirect.

Banner Manager

This is not too different from the 1.5 version, but features “Tracks”, which tracks clicks and impressions in date-filterable and CSV-exportable fashion. Finally we will be able to do some more robust reporting.

I am however baffled that banner clients still have no way to log in and view their banner’s statistics. I think most clients would want that, and offering that ability will help site owners gain more advertisers.

I wrote a Joomla 1.5 hack that got around this by using the “alias” field of the banner client to hold a username. That allows us to associate a banner client with a username, and then we can use that to display banner statistics to a given Joomla user (and only that user). Looks like I will have to port that hack to 1.6. Sigh.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags: , , ,

2 Comments

loving @freshbooks for my invo…

loving @freshbooks for my invoicing. http://bit.ly/aGjNTp

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
1 Comment

Freshbooks and time management

FreshBooks is a great tool for managing and monitoring time spent on projects. That helps make you more efficient and profitable. We have been using it for nearly two months, and it has worked wonders for us in terms of time tracking and invoicing. We highly recommend it.

It’s a wonderful invoicing tool, offering smooth integration with Basecamp, online payment for your customers, and even snail mail for those times you need to mail an invoice the old-fashioned way. Using Authorize.net you can also set up recurring payments.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags: , , , , , ,

No Comments

Monitoring Joomla for file changes

It is often desirable to monitor a site for file changes, so that you can be alerted to unwanted file changes. Those could indicate hacker activity. There is server-side software that can do this for sites, but since our focus is Joomla, we wanted to take a moment to recommend the Eyesite component: http://extensions.lesarbresdesign.info/eyesite. To get the most out of this, you will need to set up a cron job so that it will email you whenever there are outstanding file changes.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

Find Joomla section ID for article or category

Sometimes when coding a Joomla template it may be handy to know the section ID of the article or category the user is viewing.

Here is some PHP code you could insert in your template to achieve this (for Joomla 1.5);

$db =& JFactory::getDBO();
if(JRequest::getVar(‘view’)==’article’){
$query = “SELECT sectionid FROM #__content WHERE id=’”.JRequest::getVar(‘id’).”‘”;
$db->setQuery($query);
$sectionid = $db->loadResult();
}
if(JRequest::getVar(‘view’)==’category’){
$query = “SELECT sectionid FROM #__content WHERE catid=’”.JRequest::getVar(‘id’).”‘”;
$db->setQuery($query);
$sectionid = $db->loadResult();
}

Using this, you could for example control which graphics or CSS file are loaded depending on the section of the article/category.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
4 Comments

Skype “Call Me” button – no SSL support!!

To my dismay and total surprise, Skype does not offer an SSL version of its Call Me or Status buttons (link). I emailed them about this and they confirmed that it is not possible at this time, but that they would keep it in mind as a feature request. To me this is not a feature, but a basic must-have. HTTPS connections are a staple and a fact of life that should not have been overlooked. It should not be complicated to enable that, but considering that they have been in business for seven years, perhaps there is some fundamental roadblock preventing this.

Google Analytics uses JavaScript to determine whether the connection uses HTTP or HTTPS. Skype also uses an external JavaScript file, but forcibly loads it over HTTP, which is a problem for sites running on an HTTPS connection (SSL), because it will trigger “mixed content” and “potentially unsafe” content warnings in some browsers, depending on visitors’ browser settings. That can reduce customer trust, which in turn can have an impact on online sales or user stickiness.

If you need to use Skype buttons on a site that is accessed over SSL, beware.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags: , , ,

1 Comment

Basecamp & project management

We’ve recently started using Basecamp for project management and love it. It lacks robust user access level control, but this is not a must-have for us at the moment. The software makes it very easy to track tasks, comment on them, attach files, set milestones, and so forth. While using it I did notice a usability issue related to the commenting system. Normally, new comments are highlighted with a green icon. However, the system was highlighting even your own comments – if they were new.  Now, why would I want to re-read my own comment? I’m only interested in new comments by others!

Thankfully, I let Basecamp staff know about this usability glitch, and the VERY NEXT DAY they had resolved it! It’s nice to see that kind of responsiveness.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags: , ,

No Comments