You are hereDrupal 6

Drupal 6


How many modules

Often you can see if drupal site is bloated with modules if you just check how many of them are enabled, you can do this quickly with mysql command.

select name from system
where type = 'module' and status = 1
order by name;

Views: display only original revisions/only latest versions

I used revisions and almost emidietly regreted. Revisions are just like other nodes. So if you use views to display them, then you will have by default both original nodes and their revisions displayed. What you could probably do is use content revision type of view, but you still get all the nodes there. I tried with some relationships but no luck. Then finally I installed revisioning module and there was one new filter that counted number of revisions. So you add "Content: Revisions (> 1)" and you will get all the new revisions.

Localhost Error 101 in admin section

So you bring your site on localhost for some testing or faster developing and then you get not accessable admin section? Somehow drupal has problem with this and "check update module", so what you need to do is disable it.

To disable the Check Update module without, go to your mySQL database page (phpmyadmin) and select system table. Select the record which filename field="modules/update/update.module". Change the value of status field to 0.

Creating SFTP user for easy SFTP access (limit user to a single directory)

This is more or less what you need

http://library.linode.com/security/sftp-jails

Just add user before with useradd and then add this as on the link before.

Colorbox and video (you tube, vimeo....)

Adding colorobox to link is not so hard. You need to follow module instructions and it will work, just be careful to add EMBED code to URL, not just plain link. For example when adding You Tube video do this

<a class="colorbox-load" href="http://www.youtube.com/embed/5fMR_VsMs6k?width=853&height=480&iframe=true&autoplay=1"><img alt="" src="/sites/default/files/comp-arrow.png" style="width: 92px; height: 92px; " /></a>

Custom Token and languages for titles and labels

As views and even more panels are not perfect when it comes to translations if you need to have some fixed label with translation for some view/panel. You can create custom token for it and then just translate it over translation interface. Token creation is simple, just use this guide

1. Go to Admin > Structure > Custom Token, click on Add Token
2. Enter a Token Name and Description
3. Choose "Custom Tokens" for the Token Type or "Nodes Token" if you want it to be available on for example node panels overide.
4. In the PHP Replacement text area enter something like this:

MySQL Tuner

I just installed mysql tuner to try and tune mysql,

http://www.ubuntugeek.com/mysqltuner-check-your-mysql-server-performance...

Hopeing it helps with drupal and hogging of apache.

Microdata for voteing modules

Well the year is 2012 and you must use microdata, there is a microdata module for drupal 7, but if you are still at drupal 6 you will need to customize. I have been using vote up/down module for my ratings so I needed to change template file of the module to add this microformats to node display so I added this code at the end of widget.tpl.php

<?php
// Output of microdata snnipet for ratings
$node=node_load($content_id);
$title = $node->title;
?>

Tracing available variables in template file

I often forget this one, if you need to see what available variables are in some specific template file of any contributed module you will write this on top of the tpl file

<pre> <?php print_r(get_defined_vars());?></pre>

and will get a nice list of variables you can use.

Drupal site and how to manually put it offline

Go to phpmyadmin and start this 2 commands

put site offline
UPDATE variable SET value='s:1:"1"' WHERE name = 'site_offline'
put site online
UPDATE variable SET value='s:1:"0"' WHERE name = 'site_offline

depending what you need, if you have drush you could also do that with drush.