Printing of meta data on Drupal home page

The module Nodewords facilitates easy management of meta data on Drupal websites.

To set-up meta data for the home page note it's done via the URL path of admin/nodewords/meta-tags/frontpage and not by editing the fields within the content (node) that has been used as the home page.

Using the Drupal menu navigate as follows:

Administer -> Meta tags -> Default and specific meta tags -> Front Page

Execute shell command in PHP

The example below shows how to execute a shell command from within php script.

The command pwd executes the current working directory.

<?php
$output = shell_exec('pwd');
echo "<pre>$output</pre>";
?>

Drupal notes

  • If placed within a drupal node it will always display the base location of the drupal installation.
  • If you require to call a program which resides above the drupal directory the following may be used.

    <?
    include("../../legacy/program.php");
    ?>

Get current URL excluding parameters in php

Firstly, to get the current url in php use the following:

<?
$current_url = $_SERVER['REQUEST_URI'];
echo $current_url;
?>

For URLs with trailing parameters the following will place the first part of the current URL (i.e. the part before ?) within the variable $current_url[0] and then print it out.

<?
$current_url = explode("?", $_SERVER['REQUEST_URI']);
echo $current_url[0] ;
?>

For example with the URL: