Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Check Snippet Working

Submitted by on February 16, 2011 – 4:38 pm2 Comments

If PHP-snippet has an error the whole website could be unavailable. Therefore, before saving a block/page you should make sure that snippet works correctly.

Solution:

  • Create a file in your site root (for example, test.php)
  • Insert code of php-snippet and two additional lines before to this file:

    <?php
    include_once ‘./includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    // snippet code
    ?>

  • To check this, enter to your web-browser: http://example.com/test.php (where test.php is name of the file)

Notes:

  1. Your snippet should output some info to browser. Otherwise block with this snippet won’t be shown on a page.
  2. Do not forget to remove this file after verification.

2 Comments »

  • Joe Andrieu says:

    Actually, it looks like you need to define DRUPAL_ROOT if you are using Drupal 7.

    It should looks something like this:

  • Joe Andrieu says:

    Wow. That totally failed.

    <?php
    define(‘DRUPAL_ROOT’, ‘/home/ubuntu/repository/web’);

    include_once ‘./includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    // snippet code

    echo “hello”;

    ?>

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.