Musings of ErisDS
beta
ErisDS

WordPress Pages MenuBack in June I posted about tidying up the WordPress admin dashboard. Recently I got a comment on that article asking if the admin menu could be altered for different users in a similar way. This turned out to be ever-so-slightly more complicated that I expected because there is no way to distinguish between the permission to edit and the permission to add a page or post. However, like most things in WordPress with a bit of graft it’s usually possible!

Code Example: You can download the complete code sample with comments right here: functions.php [ZIP File]

I like to think that I have a few social skills… enough at least to say I’m not “socially inept”.

Have you ever stumbled across the issue where wp_list_pages isn’t spitting out the text you define for link_before and link_after? I came across this some time ago: one minute my lovely pipe bars ‘|’ where there, the next they weren’t. It turns out this is due to the EXTREMELY popular All in One SEO Pack plugin (if you’re not using this you should be!).

The new WordPress 3.0 menu system is pretty powerful and provides some very interesting new options for creating menus in WordPress. Previously, I have always used wp_list_pages and a custom Walker class to provide hierarchical menus based on the page structure, but that’s a topic for another post. This super-short snippet shows you how to add a login / logout link to one of your WordPress menus.

I’m still pretty new to Magento, and am learning more about it every day. I’ve been trying to learn all I can about internals such as managing collections & recently stumbled on trying to filter a collection by two attributes. I wanted to build a list of all products that had one OR another attribute set to certain values.

This is a super short snippet that I ALWAYS forget how to do! Often I want to build more complex where clauses with Propel Criteria which use SQL functions such as UCASE, LCASE, LEN and the date functions DAY, MONTH and YEAR. This is possible using Propel & Criteria, but how to do it is not immediately obvious.

The snippet below shows how to select objects from the database which were created in a specific month and year. Using Criteria::CUSTOM, it’s possible to specify a column and a comparison to do with that column. This is quite useful for doing things like building archive lists.

1
2
$c->add(MyObjPeer::CREATED_AT, 'MONTH('.MyObjPeer::CREATED_AT.')='. $month, Criteria::CUSTOM);
$c->addAnd(MyObjPeer::CREATED_AT, 'YEAR('.MyObjPeer::CREATED_AT.')='. $year, Criteria::CUSTOM);