Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating a Theme From Scratch in Drupal

Similar presentations


Presentation on theme: "Creating a Theme From Scratch in Drupal"— Presentation transcript:

1 Creating a Theme From Scratch in Drupal
Theming 101

2 Drupal Theme Structure

3 Modules, Themes, and Core

4 Why to theme… Themes allow you to change the interface of your system without affecting the business logic or code that is providing the system functionality. Think of PAC and MVC design, the theme is the view or presentation layer of a web application.

5 Step 1 – Create a Design Create a working design in HTML and CSS

6 Step 2 - Create a Theme Folder
Create a theme folder and place it in your drupal site’s theme folder E.g. default/themes/example_theme

7 Step 3a – Create a .info file
Create a a .info file for your theme and save it into the theme folder you created. E.g. example_theme.info

8 Step 3b – Fill in .info required information
Add the following information to the .info file:

9 Step 5 Create a page.tpl.php file & dump your html code into the page and save it into the theme folder you created.

10 Step 6 Create a style.css file and place all of your CSS code into that file and save it into the theme folder you created.

11 Step 7 Remove all of your CSS code from the page.tpl.php file and remove all the information / text between the <head>….</head> tags.

12 Step 8 Place this code between the <head> </head> tags, this will print out all of your styles, java script, page titles, etc…

13 Step 9 At this point, you will need to place the following code, where your main content display area is in your design. This will print out page content and local menus that appear as tabs. <div id=“content”> </div>

14 Step 10 In your theme, you should have an area for primary and secondary links defined. Replace the HTML code that you are using for these with this:

15 Step 11a You will need to define “Regions” that will display “Blocks” of content. By default you have the following regions: regions[left] = Left sidebar regions[right] = Right sidebar regions[content] = Content regions[header] = Header regions[footer] = Footer

16 11b – Add regions to .info

17 11c – Print the content of the region in you page. tpl
11c – Print the content of the region in you page.tpl.php file, locate it where you want the content to be placed.

18 Congratulations! You just made a theme!

19 template.php Functions included in this file can be called in your theme. To override a function in Drupal such as the theme(…) function, you can copy the code for the theme function from and then paste it into your template.php file. You will need to append the name of your theme to the function and then modify it’s code to suit your purposes.

20 node.tpl.php Default node theme

21 node-story.tpl.php Custom template theme for a specific content type.

22 block.tpl.php You can create custom themes for each block

23 page-front.tpl.php Custom Front Page

24 Overrides


Download ppt "Creating a Theme From Scratch in Drupal"

Similar presentations


Ads by Google