Common Framework Features

Theme frameworks offer a host of features to make your life easier when it comes to building a Web site. Individual frameworks offer many unique features, but also share a common set of features. These common features generally allow for faster and easier development of your WordPress Web site.

Theme functions

Most themes include a functions.php file that contains functions for the theme, but some theme frameworks take this to the next level. They offer customization options using these functions that rival many plugins.

In the Genesis theme, a custom function allows users to create new widget areas. The genesis_register_sidebar() function, which takes care of the heavy lifting for widgetizing a new area, gives you some options to easily customize it. Below is an example of how you might use this function in your theme's functions.php file:

genesis_register_sidebar(array(
   'name'=>'My New Widget',
   'description' => 'This widget is new.',
   'before_title'=>'<h4 class="mywidget">',
   'after_title'=>'</h4>'
));

This function allows you to enter a few customizations into the function, such as a name for your widget, a description, and any HTML that you want to appear before and after your widget.

Many standard themes also provide functions that are used in the theme, but theme frameworks offer many additional custom functions that the theme doesn't. The custom functions help you make the theme do exactly what you need for a specific site.

Theme functions can vary greatly, so most theme authors have ample documentation through their site or forums where you can get more information about available functions.

Hooks

Many theme frameworks provide hooks to allow you to access and modify features of the theme. Hooks can seem a little advanced to many users, but with a little practice, hooks are quite efficient at modifying a theme. Theme frameworks provide hooks to allow you to latch in to functions of the theme and call or modify them at a specific time.

The two types of hooks are

  • Action: Events during the loading of the theme when you can latch in a specific function. For example, if you want one of your functions to execute at the same time a file in the theme is loaded, you can use an action to hook the function to that file's load.
  • Filter: Allows you to modify data while it passes to the theme or to the browser screen. Some theme frameworks allow you to filter the classes the theme applies to elements.

An example of modifying your theme with hooks can be found in iThemes Builder. For example, consider the hook to add meta data: builder_add_meta_data. This can be useful for SEO in your theme.

To add custom meta output, the default function can be replaced with a custom one. To do that, remove the existing action and add your own, like this:

<?php
remove_action('builder_add_meta_data','builder_seo_options'),
add_action('builder_add_meta_data','my_custom_builder_seo_options'), ?>

The default SEO options were removed with remove_action and replaced with a new function called my_custom_builder_seo_options. Now, you need to define what my_custom_builder_seo_options will do.

<?php
function my_custom_builder_seo_options() {
   /*Add custom seo options here.*/
}
?>

This creates a basic PHP function where you can define what custom SEO options you want in the theme.

Because many frameworks have 100 or more hooks, most of them provide documentation (through their Web sites or forums) of what hooks are available, what each hook does, and what parameters are available to modify how the hook works.

Child themes

Some frameworks choose to allow you to modify the theme by using child themes (find out more about the parent/child theme relationship in Chapter 5 of this minibook). Child themes can be as simple as a stylesheet, but derive their power from the parent theme's template and function files.

Like a regular theme, a huge advantage of using a child theme is to protect any customizations you make from being overwritten if a newer version of the theme comes out. For frameworks, this is especially important because changes to the core theme may be more frequent than regular themes due to the need to add more hooks, functions, or options over time.

From the list of frameworks above, Theme Hybrid, Thematic, Genesis, and iThemes Builder all extend their frameworks through child themes. Many frameworks provide child themes free; others build child themes to sell.

Layout options

The ability to change the layout of a framework is important for many users. Different frameworks use different methods of achieving this. Some use template files to allow the reorganization of the layout; others provide an interface to create layouts from scratch.

Headway, for example, provides a unique layout editor, as shown in Figure 7-7. The layout of the theme is created through a drag-and-drop interface that allows you to organize, size, and style the layout in one location.

Styling

Many theme frameworks incorporate methods that let you customize the style of the Web site without needing to know CSS. (See the section on CSS and stylesheets in Chapter 4 of this minibook.) Frameworks that use a what-you-see-is-what-you-get (or WYSIWYG) style editor, such as Headway, allow you to easily match your theme's colors and design to your branding. Additionally, many editors include color pickers so you don't have to use hexadecimal values to choose colors.

Other common elements that can be styled are borders, fonts, and headers.

Figure 7-7: Headway's layout editor.

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.174.95