mkdir ~/code/vagrant-redmine/cookbooks/
cp -R ~/code/chef/ew/cookbooks/{apache2,php,mysql} ~/code/vagrant-redmine/cookbooks/
mkdir ~/code/vagrant-redmine/site-cookbooks
cp -R ~/code/chef/ew/site-cookbooks/ewapache2 ~/code/vagrant-redmine/site-cookbooks
# stick the redmine custom cookbook into git, since I'll be hacking at it
This tutorial guides you through creating your first Vagrant project.
We start with a generic Ubuntu VM, and use the Chef provisioning tool to:
- install packages for vim, git
- create user accounts, as specified in included JSON config files
- install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository
Afterwards, we'll see how easy it is to package our newly provisioned VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hook_block_view($delta = '') { | |
$block = array(); | |
switch ($delta) { | |
case 'ad': | |
$block['subject'] = t('This is an Ad'); | |
$block['content'] = t('Buy My Module!'), | |
break; | |
return $block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_block_info() | |
* | |
* Adds a custom block | |
*/ | |
function mymodule_block_info() { | |
$blocks['ad'] = array( | |
'info' => t('Advertisement'), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (user_access('manage my module settings')) { | |
//Display my module settings to user | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'#theme' => 'node_article', | |
'#article_title' => $node->title, | |
'#article_body' => $node->body, | |
'#attached' => array( //special property to attach a CSS or JS file to a template | |
'css' => array( | |
'/sites/all/modules/ew' . '/ew.css', //use drupal_get_path() instead | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// menu callback that returns NULL, used for web services | |
function article_callback_json($node) { | |
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); | |
print json_encode($arr); // {"a":1,"b":2,"c":3,"d":4,"e":5} | |
return NULL; | |
} | |
//menu callback that returns a string for Drupal to wrap in the page layout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file: node-article.tpl.php | |
<div class="article"> | |
<h2 class="article-title"> | |
<?php print $article_title; ?> | |
</h2> | |
<div class="article-body"> | |
<?php print $article_body; ?> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function article_menu_callback($node) { | |
return array( | |
'#theme' => 'node_article', // #theme is a special property to specify node-article.tpl.php | |
'#article_title' => $node->title, // variable accessible via $article_title | |
'#article_body' => $node->body, // variable accessible via $article_body | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function article_theme() { | |
$theme_implementations = array(); | |
$theme_implementations['node_article'] = array( | |
'template' => 'node-article', //node-article.tpl.php | |
'variables' => array( | |
'title' => NULL, | |
'body' => NULL, | |
), |