You are hereDrupal 6

Drupal 6


Find files or directories on linux

Trying to locate some directory or file, use

find / -name 'drush'

or

find / -iname 'drush'

to ignore case.

Node export tips and problems

Currently I am moving nodes from one domain to other, with many images and cck fields. Problem I have other then browser timing out on large files when uploded through node export module is that also on smaller files, with few nodes seems that module sometimes works and sometimes doesnt. What I realized is that if you quickly select code to paste or export file, importing breaks. Like something is proper only after some time you leave it, a minute or so. Maybe this is wrong and doesn't seem smart enough but this is how it seems to me it works.

Redirect Old domain to New domain using htaccess redirect

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Please REPLACE www.newdomain.com in the above code with your actual domain name.

Panels h1 title inline with sidebar

Currently many drupal themes like fusion have h1 title use all the width of the grid so you can't have a panel where h1 tag is just part of the grid, using content area and in the same line there is sidebar. What I did is removed h1 tag from page.tpl.php and manually added panes in each panels that outputs title, I choose it from "page elements" where you have page title, and put it in the part of layout I want it to be. Then just leave default settings for it h1 selected in config and that is it.

Setting Cron job on Linux for Drupal site

You can edit your cron runs over SSH as user with proper permissions if you type ine

crontab -e

There you will have a file where you edit your cron runs. You will find here details explanations what is what. But for drupal setup you should put this line if you wish to run cron every 10 minutes

*/10 * * * * cd /srv/www/yoursite/public_html/; php -q cron.php

There are also some good advanced cron modules, very advanced is

Drupal massive comment enable

When you enable, or dissable commenting in drupal, you will only affect new nodes, there is no bulk action for this in core (but it should be in my opinion, not every damn useful functionality does have to be in separate module). There are few ways to do it, some proper way would be to built action and then run VBO on nodes, but this is the most time consuming for sure. There are few simpler, most used one is probably just the

update node set comment = 2 where type = "page";

this work for drupal 6, for drupal 7 you need to make this twice

Filefield paths best practices

Recently I had a site with +30 000 images, they were all in default drupal folder /files and ofcourse this started to make problems for my server but also if I wanted to manually do something, delete a file or use it this made that directroy unusable. So filefield paths (which should be in core) helps here. One of the best practices so far is to have directories by dates, so each year has it's own, each month, own and day its own, but months are subfolders of years, days are subfolders of months. So to set this up add this to filefield configuration

Linux - Change owner and group in a directory to include subdir and all files

Just go to your ssh client and run

chown -R someuser:somegroup public_html/

Making it accessible to drupal you would probably run

chown -R www-data:www-data files/

Migrating drupal site from one server to other

Migrating drupal site from one server to other could be easy and fast task, then again if not prepared you could run into many problems and have lots of work.