Posts Tagged ‘drupal’

Drupal multiple Views on same page

If you’re using Drupal 6.x and you need to display multiple ‘Views’ on your homepage (or any other page for that matter) here’s the code that will do it for you…

In this example I will be displaying the View called ‘showcase’, just change it to whatever name you called your View. The only text you need to change is highlited in red.

You can paste this code into your page.tpl.php file for as many Views as you need!

<?php
    $viewname = 'showcase';
    $display_id = 'showcase'; // or any other display
    $args = array();
    $args [0] = 'foo'; // These values are optional
    $args [1] = 'bar';

    $view = views_get_view($viewname);
    $view->set_display($display_id);
    $view->set_arguments($args);
    print $view->preview();
?>

If you just want to display a View without passing in any variables (args) then you can simply have:

<?php
    $viewname = 'showcase';
    $display_id = 'showcase'; // or any other display
    $view = views_get_view($viewname);
    $view->set_display($display_id);
    print $view->preview();
?>

Boom! Job done.

All the best

Simon

Cron on Windows

If you’re running cron on your server you will need to setup a scheduled task that will effectively call the cron.php file for your domain.

You can simply do START > RUN

schtasks /create /tn “Drupal Cron Job” /tr “php -f ‘{path-to-cron}/cron.php’” /sc hourly

So for my Astrophysics website the command would be:

schtasks /create /tn "Drupal Cron Job" /tr "php -f 'http://manonmars.co.uk/cron.php'" /sc hourly

You will then need to type in the administrator password.

Job done, or should I say ‘cron done’

Devel block not appearing.

Here is a serious case of the Devel block not working:

I’m having the same problem. If I enable the Devel module it does not get listed in ‘Blocks’ where I should be able to drag it from ‘disabled’ to one of my side bars.

I’ve even gone to the extent of removing all modules (except Devel)I have run update.php, flushed all caches, run cron and everything comes up clean – no errors whatsoever.

I go again into into modules where I have ONLY ‘core optional’, ‘core required’ and ‘Devel 6.x-1.18′(as of 30/09/09 the latest version) that’s all. I have unticked and saved configuration then re-ticked Devel and saved configuration and still nothing.

When I go into Blocks (In the Garland theme) I have:

Left Sidebar
Navigation
User login

Footer
Powered by Drupal

Disabled
Execute PHP
Primary Links
Secondary Links
Switch User
Syndicate
Who’s Online
Who’s New

And that’s it. There simply isn’t a ‘Development’ block listed. I have tried this with multiple themes and the Development block just simply isn’t there. How is it possible I’m missing something when the Devel module is the only one insalled? Everything I can think of has been checked and re-checked and still the Development block can not,does not, and just WILL NOT appear!

I am not excluding the fact that I’m probably working too many hours at the moment, but to completely eliminate every conceivable possibility I’m even happy to provide anyone from Devel a temporary URL to this site with the Admin Username/Password and I’m pretty sure they will have as little success as I’ve had.

Having now stripped everything down to it’s utter minimum all that is left for me to do now is to backup my site’s theme and start the whole site again from scratch – The only problem here is – what happens when/if this happens again?

Yup, that quote was made by me on the Drupal.org website. Seeing as I’ve only just posted it I haven’t had a reply yet, but to anyone else who’s experiencing a serious problem with their Devel block I would recommend double checking there are no conflicts with DHTML or the Administrator block – because you might be able to solve your problem. But if you’ve had about as much luck as I have in stripping your site down to absolutely nothing and still it doesn’t work, I would at this point suggest that the Devel module still had a serious bug problem.

Will keep you posted!

Drupal mailhandler smtp localhost error

As you know I always write my own technical articles and tutorials. However on this occasion I have come across an article that is so well written and the instructions (if followed) work so smoothly that there is nothing I have to say that I could add to make it any better.

If you have just installed mailhandler for Drupal and you would like to use it with GMail you may have come across a bunch of errors along the lines of:

Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in… and the like.

There are some other errors I’ve seen along the lines of  ‘check the file includes\mail.inc line 194′ that were reported by Drupal. Well I checked the the mail.inc folder and lo and behold there was no function of the correct name and it certainly wasn’t on line 194…

Anyway to cut a long post short I hate Microsoft Exchange – it’s an over bloated overly complex, un spam filtered pile of pap and it also costs money to.

The answer is to use GMail (Google Apps) which is completely free, very stable, highly available, spam filtered and uses SSL.

If you’re running a Windows server with PHP you’ll find that the php.ini file doesn’t support SSL/TLS and a number of other things – That’s where this article comes in. Check it out!

http://digiex.net/guides-tutorials/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html

Also check out this article for receiving mail to your Drupal site using mailhandler here:

http://www.willisbros.net/blog/2007/11/06/want-to-use-drupals-mailhandler-module-with-gmail/