Drupal stores time information (such as created date, modified date, etc) in unix date format as int(11).
Using a simple statement:
SELECT n.`created` FROM node n
Formats the data as date & time:
SELECT FROM_UNIXTIME(n.created) FROM node n
Just the date:
SELECT DATE(FROM_UNIXTIME(n.created)) FROM node n
Theming CCK forms initially appears to be a bit of a black art, but is very simple. The simplest method is to add:
function phptemplate_node_form($form) { if(file_exists(path_to_theme().'/'.$form['type']['#value'].'_form.tpl.php')) { return _phptemplate_callback($form['type']['#value'].'_form', array('user' => $user, 'form' => $form)); } }
The code design of Zen Cart is sometimes baffling, sometimes plain ugly and other times just plain WTF?! Even the most seemingly obvious task takes longer as there is no central location for themeing and for something that touts itself as "not for programmers", there is a hell of a lot of editing of obscure code files scattered throught the installation.
Here I have tried to note down some of the more common, or at least common to me, items I need to keep track of.
Zen Cart is a very popular shopping cart system forked from oscommerce. While the Zen Cart homepage claims that it is easy to install, configure and use, sometimes the method of changing options and features can be a little confusing. Whatever you do, don't get me started on their theming - it's not pretty.
I was recently updating some features of the Missing List, specifically how the UK Postcodes are handled. Due to the nature of the site, it was requested that only certain roles had access to full postcodes not entered by the current user (i.e. only the main Administrator). Everyone else would only get the first part of the postcode (e.g. EC1V instead of EC1V 4PY). This was recently requested to be expanded to include other roles.
Sometimes you need to copy a table from one database to another. itmay be that you need o take a backup before messing around with the structure, or to copy information from a live database to a development database. Initially I thought the following would do the trick:
DROP TABLE IF EXISTS target_db.target_table; CREATE TABLE target_db.target_table SELECT * FROM source_db.source_table;
MySQL is a great alternative to Microsoft's SQL Server. Yes, it does have it's downsides, but for a lot of people and organisations both large and small, it is more than sufficient for their needs and doesn't cost an obscene amount of money. Before any of you go on about PostgreSQL, I am fully aware of it, but it's support under Drupal leaves a lot to be desired.
Anyway, useful snippets, tips and tricks abound, hopefully some will be of use to you!
For some reason, the default layout code for the exposed filters gives some very strange results. To force the filters to be rendered in a series of divs to be styled as required, add the following to your theme's template.php:
Synopsis:
Your main website Drupal installation is in /home/[user]/public_html) and you want to create www.mainwebsite.com/subsite
When using CCK Numeric fields, entering 1,000,000 is displayed as 1e+06 (which is nothing like that we were looking for when displaying rewards). To display the value correctly use:
sprintf("%01.2f",$node->field_amount[0]['view'])