Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011

1,858 views
1,800 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,858
On SlideShare
0
From Embeds
0
Number of Embeds
586
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011

  1. 1. Create theme From logic to representation Controller View Model
  2. 2. Gold Sponsor of DrupalCamp Kyiv 2011
  3. 3. Silver Sponsors of DrupalCamp Kyiv 2011
  4. 4. Theme place themes/ sites/all/themes/my_theme/ sites/ {sitename}/themes/my_theme/
  5. 5. Theme
  6. 6. my_theme.info name = My Theme description = My first theme. Try it. screenshot = images/screenshot.png core = 6.x version = "6.x-1.0" engine = phptemplate stylesheets[all][] = css/style.css ; stylesheets[all][] = css/admin.css scripts[] = js/script.js features[] = logo regions[left] = Left
  7. 7. page.tpl.php <head> <title> <?php print $head_title; ?> </title> <?php print $head; ?> <?php print $styles; ?> <?php print $scripts; ?> </head> <body class="<?php print $body_classes; ...
  8. 8. node.tpl.php <div id="node-<?php print $node->nid;?>" class="node-<?php print $node->type;?>"> <h2 class="node-title"> <?php print $title; ?> </h2> <div class="content"> <?php print $content; ?> </div> </div>
  9. 9. <div id="block-<?php print $block-> module .'-'. $block->delta; ?>" <div class="block-content"> <?php print $block->content ;?> </div> </div> block.tpl.php
  10. 10. Templates suggestion page-[path].tpl.php page-node-[nid].tpl.php page-node.tpl.php page.tpl.php
  11. 11. Regions Content Header Leftsidebar Rightsidebar Footer my_theme.info page.tpl.php ... regions[header] = Header regions[content] = Content <body> <div id="top"> <?php print $header;?> </div> <div id="left"></div> <div id="center"> <?php print $content;?> </div>
  12. 12. HTML Result node.tpl.php Search NavigationLogin Image block.tpl.php page.tpl.php
  13. 13. template.php /** * Implementation function hook_prerpocess_page(). */ function my_theme_prerpocess_page(&$vars){ $vars [‘footer_slogan’] = t(‘Hello’) ; // this $vars will be able in page.tpl.php } /** * Implementation function my_theme_prerpocess_node(). */ function my_theme_prerpocess_node(&$vars){ // this $vars will be able in node.tpl.php }
  14. 14. function t(); $output = t('There are currently %members ', array('%members' => $user) !variable — inserted without change @variable — filtered HTML check_plain(). %variable — filtered theme('placeholder'). //bad $message = 'An error occurred.'; drupal_set_message(t($message), 'error'); $output .= t($message); //good $message = t('An error occurred.'); drupal_set_message($message, 'error'); $output .= $message;
  15. 15. l($text, $path, $options = array()) // bad print '<a href="/'. url .'">'; // good print l(t('Some link'), $url); $options = array('attributes' => ('class' => 'some')) array('query' => drupal_get_destionation()); array('fragment' => 'top' ); array('absolute' => true ); l('<b>name</b>', $path, array('html' => true)); function l();
  16. 16. Final theme
  17. 17. Questions ? Full name: Alexander Ilivanov Skype: user_ytko Email: jurenites@gmail.com

×