Skip to content

Instantly share code, notes, and snippets.

@DC-development
Created June 21, 2014 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DC-development/a689f725dd82988fdbb3 to your computer and use it in GitHub Desktop.
Save DC-development/a689f725dd82988fdbb3 to your computer and use it in GitHub Desktop.
<?php
/* $Id$ */
/**
* @file
* Very simple DRUPAL module
*/
//see all messages for debugging
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
//Because we need the twig-lib for the hello world example
//actually you should add this in index.php
require_once './vendor/autoload.php';
/**
* Implementation of hook_help().
*/
function hello_world_help($section) {
switch ($section) {
case 'admin/help#hello_world':
$output = '<p>Hello world help...</p>';
return $output;
case 'admin/modules#description':
return 'Hello world module description...';
}
}
/**
* Implementation of hook_menu().
*/
function hello_world_menu() {
$items['hello'] = array(
'title' => 'Hello world page...', // page title
'page callback' => 'hello_world_page', // callback function name
'access callback' => TRUE, // every user can look at generated page
'type' => MENU_CALLBACK // define type of menu item as callback
);
return $items;
}
/**
* Implementation of hook_page().
* Using Twig Engine for output.
*/
function hello_world_page() {
$loader = new Twig_Loader_Filesystem('./twig');
$twig = new Twig_Environment($loader, array(
'cache' => './twig/_temp',
'debug' => 'true'
));
$ret = "";
$ret .= $twig->render('test.html.twig', array(
'name' => 'Fabien',
'otherValue' => 'wild you !'
));
return $ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment