PHP

WordPress Custom Menus Issue Solved!

5

In the recent release of wordpress 3.2.4 and the 3.2.3 security release, a change was introduced that caused custom navigation menus to default to the standard page list menu of EVERYTHING!

Not ideal, and as most people found out, the fix for this was to add 'fallback_cb' => false to the wp_nav_menu() calls in their theme, however for me, and some other people, this didn't fix the problem alone.

In fact as well of this, for some people, including myself, it seems that the wordpress upgrade ALSO removed the association between menu locations and the custom menus themselves from the database (i.e. The values set in the "Theme Locations" section of the menu editor were lost.

So, if you're still having issues with custom menus in wordpress, and your code for creating them and including them in your theme appears correct, check the menu editor and see if you need to re-associate your menus to your theme locations!





A Simple News System For Basic Websites

0

This is a very simple news system with comment support which is ideal for adding simple blog/news system functionality to any website needing that kind of system. In the past I'd usually use wordpress as a pre-built solution for adding this kind of content to a site and although you get a lot of extra benefits by using wordpress (as a result of its plugin system) there can be a lot of issues with tweaking the wordpress theme to suite the site. The method of embedding this system is so simple that it can be used easily within any site template and as such it's perfect for quickly adding blogging or news system style functionality to previously static sites or E-Commerce systems where an attempt at tying in wordpress could be very messy

More here:
A Simple News System For Basic Websites





AeroSQL an alternative to phpMyAdmin

0

Another really useful item from Oleg Burlaca. AreoSQL is a free web based database management solution which, given some development could be a decent replacement for the awful phpMyAdmin. I say awful, phpMyAdmin is in a lot of ways actually a pretty good tool, however it's also notorious for going wrong when you least expect it and, to be honest needs a throrough interface overhaul. AreoSQL doesn't provide anything like the level of functionality that phpMyAdmin does (yet) BUT the interface is better, especially for people who like to use a componentised view of databases as a lot desktop app's provide. Overall I personally don't think it's going to beat other projects like Chive ( chive-project.com ) to being an immediate successor to phpMyAdmin but it's certainly an alternative to be considered...


More here: AeroSQL an alternative to phpMyAdmin





Handling CType Data With SimpleXML in PHP

0

If you're new to SimpleXML then the output and representation of complex XML data produced by the library can be daunting and sometimes confusing, but once you're used to it, SimpleXML is a massively useful tool for processing XML information.

When debugging other people's implementations of simpleXML however, one of the biggest issues I come across time and again is the apparent loss of CType data from the processed feed.

Luckily this is very easily remedied, but not well documented so here's how to deal with it.

PHP 5.1.0 introduced the options parameter to functions such as simplexml_load_string() which allows you to specify additional paramters to Libxml the underlying library PHP uses to interpret XML.

The default Libxml setting ignores any data in CType blocks, but you can override this behaviour by passing the LIBXML_NOCDATA option to the function.

In other words, in cases where you might usually do this to load some xml data and not find the CType fields in the resulting object:

$xml = simplexml_load_string($feed);

Doing this instead, will allow the CType fields to be added to the object and used in your scripts where you need to

$xml = simplexml_load_string($feed, NULL, LIBXML_NOCDATA);

Unfortunately the options parameter is the 3rd in the list, and 9 times out of 10 the second option (which is the name that's given to the class containing the parsed xml) doesn't need to be changed/overridden so I personally choose to pass NULL in as the second option, though you can enter whatever you like here.

It's as easy as that  - I hope you found this note useful icon smile Handling CType Data With SimpleXML in PHP

ctype_digit rtfm!

1

For the last 5-10 minutes I've been wondering why a check on a variable which should be valid has been returning false.

The check is ctype_digit, which returns true if all characters in a string are digits.

So if $var = 1;, you might expect it to return true, but it doesn't.

Why not? Well, as the PHP manual states, this function acts on strings not integers.

Therefore checking something that has been specifically set as an integer (as in the example above) or typecast to be an integer at some point (as is my case) ctype_digit will fail as the data it is checking is not a string in the first place!

So there you go. Although 99% of data handled in PHP is in string form at some point, and therefore a ctype_digit check is generally completely valid, in some special cases it might be worth combining a ctype_digit() check with a preceding is_string() check depending on your application.

Rant over...

Go to Top