Drupal tips

Include a page in another page

<?php
 
print node_view(node_load(array('nid' => 123)), 1);
?>

where 123 should be replaced with the number (nid) of the node you want to include. Set the "input format"  to "php code".

Login after disabling the login block

Point your browser to your website and add /?q=/user/login to the url

Setting the crontab job

  • login through ssh or some other kind of session
  • open the crontab editor with this command: crontab -e
  • enter the following line to execute the cron job every day at 06.30 am:

                30 6 * * * /usr/bin/lynx -source http://www.yourdomainname.com/cron.php

Disable the read more link on a page

Add this comment / code to the end of your page to disable the read more behavior of many templates:

<!--break-->

Open all external links in a new browser window

(Thanks to krikit)

In your template.php add:

drupal_add_js('misc/newwindow.js', 'theme');

Then in drupal_install/misc/newwindow.js add: (if the file does not exist, create it)

$(function() {
$('a[@href^=http]').not('[@href*=yourdomainname.com]')
.addClass('external-link')
.click(function() {
window.open(this.href, '_blank');
return false;
});
});

Change 'yourdomainname.com' to your website's domain name, now any http prefaced links not from that domain will open in a new window.