|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
| 4 | + <title>Installing-vim</title> |
| 5 | + </head> |
| 6 | +<body> |
| 7 | +<h1> Vim snippets for Drupal 7</h1> |
| 8 | +<ul> |
| 9 | +<li><u>REQUIRED:</u> snipMate for vim: <a href="http://www.vim.org/scripts/script.php?script_id=2540">http://www.vim.org/scripts/script.php?script_id=2540</a></li> |
| 10 | +<li><u>Included:</u> All 330+ Drupal 7 hooks</li> |
| 11 | +<li><u>Missing:</u> Other functions</li> |
| 12 | +<br /> |
| 13 | +<li>Replace the php.snippets file in the ~/.vim/snippets directory with the one included.</li> |
| 14 | +<li>Type hook_HOOKNAME<tab> for annotated snippets, and h_HOOKNAME<tab> for the non-annotated versions.</li> |
| 15 | +<li>Most snippets include multiple <tab> placemarks.</li> |
| 16 | +</ul> |
| 17 | +<br /> |
| 18 | +<strong>Example 1:</strong> h_block_view<tab> (file is called test.module) |
| 19 | +<pre> |
| 20 | +/** |
| 21 | + * Implements hook_block_view() |
| 22 | + */ |
| 23 | +function test_block_view($delta = '') { |
| 24 | + $block = array(); |
| 25 | + |
| 26 | + switch ($delta) { |
| 27 | + case '': |
| 28 | + $block['subject'] = t(''); |
| 29 | + $block['content'] = theme('', array('' =>)); |
| 30 | + break; |
| 31 | + |
| 32 | + } |
| 33 | + return $block; |
| 34 | +} |
| 35 | +</pre><br /> |
| 36 | +<strong>Example 2:</strong> hook_block_view<tab> (file is called test.module) |
| 37 | +<pre> |
| 38 | +/** |
| 39 | + * Implements hook_block_view() |
| 40 | + */ |
| 41 | +function test_block_view($delta = '') { |
| 42 | + $block = array(); |
| 43 | + |
| 44 | + switch ($delta) { |
| 45 | + /* |
| 46 | + *case 'syndicate': |
| 47 | + * $block['subject'] = t('Syndicate'); |
| 48 | + * $block['content'] = theme('feed_icon', array('url' => url('rss.xml'), 'title' => t('Syndicate'))); |
| 49 | + * break; |
| 50 | + * |
| 51 | + *case 'recent': |
| 52 | + * if (user_access('access content')) { |
| 53 | + * $block['subject'] = t('Recent content'); |
| 54 | + * if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) { |
| 55 | + * $block['content'] = theme('node_recent_block', array( |
| 56 | + * 'nodes' => $nodes, |
| 57 | + * )); |
| 58 | + * } else { |
| 59 | + * $block['content'] = t('No content available.'); |
| 60 | + * } |
| 61 | + * } |
| 62 | + * break; |
| 63 | + */ |
| 64 | + case '': |
| 65 | + $block['subject'] = t(''); |
| 66 | + $block['content'] = theme('', array('' =>)); |
| 67 | + break; |
| 68 | + |
| 69 | + } |
| 70 | + return $block; |
| 71 | +} |
| 72 | +</pre> |
| 73 | + |
| 74 | +</body> |
| 75 | +</html> |
0 commit comments