ppti.info Lifestyle Drupal 7 Theming Cookbook Pdf

DRUPAL 7 THEMING COOKBOOK PDF

Monday, June 3, 2019


Drupal 7 Theming Cookbook. Drupal. Free Books Download PDF / Free Books Online / Free eBook Download PDF / Free eBook Download PDF. Drupal 7 Views Cookbook Over 50 recipes to master the creation of views using the Drupal Views 3 module J. Ayen Green. Drupal 7 Theming Cookbook. Cover image for this book. Authors: Karthik Kumar. Publisher: Packt Publishing. Publication date: Page count:


Drupal 7 Theming Cookbook Pdf

Author:STANLEY BRUMMER
Language:English, Spanish, German
Country:Nauru
Genre:Business & Career
Pages:607
Published (Last):01.04.2015
ISBN:272-2-63901-822-1
ePub File Size:19.44 MB
PDF File Size:8.25 MB
Distribution:Free* [*Regsitration Required]
Downloads:30835
Uploaded by: LUELLA

ppti.info Drupal 7 Theming Cookbook Over 95 recipes that cover all eBook versions of every book published, with PDF and ePub files available?. DRUPAL 7 THEMING COOKBOOK PDF - In this site isn`t the same as a solution manual you buy in a book store or download off the web. Our. Over Thank you for reading drupal 7 theming cookbook. As you may know, people have look hundreds times for their chosen novels like this drupal 7 theming.

Several negative effecb are examined here, including the erosion of public space, of locally controlled business, and of traditional cultures, as well as the perceived artificiality of thematic environments and simulations, 'The final chapter 7 discusses tvhat ttlerning is doing to the United States. A brief review al the acadelnic field of cultural studies is needed in order to make observations that go beyond the level of superficial description, We may like or dislike theming, hut here I have tried to supersede matters of opinion with a focus on the deeper meanings and effects of theming on our society, An analysis of the range of themes proves the limited imagination-the virtual impoverishment, if you will-of our pogular culture, And an analysis of the use of theming proves just how much consumerism and profit making dominate this activity.

Summary of Main Ideas 1.

Free Pdf Books

Themes and symbols are increasingly used to sell consumer goods today. Signs are vehicles for the eqression of meaning, When a symbol is used for a particular effect, we call it a sign vehicle. We know this from the historical record and artihcts left by early image makers such as the cave artists of Lascaux. Traditional societies wrapped a symbolic context, like a blanket, around all their daily activities.

These spirits w r e acknodedged as presences that intervene in the agdirs of people m d w r e mrshiped for their independent power to intervene, Tke natural world, then, was possessed by the thousand named apparitions that inhabited its many farms Schama, Human imputation of meaning to the natural world involved three distinct but interrelated activities.

The wearing al material objects, such as toternic masks, feathers or fur, or tattoo markings, abjectified the relation between humans and their natural spirits. People assumed the names of their t o t a s , such as the copte, fox, or bear-for example, "Running Fox'br ""Little Rear.

The s t a y of death and rebirth, for example, is common to many societies. Many of these same cultures also have elaborate festivals marking the winter or sl-,ring solstice-the period of decline and renewl in nature e. Symbols such as the phwnix and the egg figure in myths of life cycles. Also mmmon ts most cultures arc legends involving a hero who is godlike and omnipotent.

Ohen the mythical hero rises from humble birth to a triumfi through the slaying of some monster, but then succumbs ta the hiling a5 pride or liubris and rneets a lieroic death. Ancient Greeks believed that the gods not only ruled natural objects like the sun and the moon but also governed humm attributes and activities, Apollo, the Greek sun god, was also the god of music, poetry, eloquence, medicine, and the fine arts; Artcmis, known by the Romans as Diana, was goddess of the moon but also of the hunt and of maidenhood.

Atbena was one of several divinities that ruled solely over people. She was the goddess of wisdom, the industrial arts, and war. In these examples, we can observe a transirion Emm the spirit-naming of the natural environment by primitive societies to tfie more sophisticated naming of both the natural and the humanlinteractive environment in the sacred beliefs of ancient civilizations, This shift involwd the development of cosmologies into organized religions based on the pantheon of gods, complete with spcciaiized niches in the social division of labor for priests, priestesses, oracles, temple virgins, shmans, seers, and assorted "holy men.

Zeus was well known for his sexual trysts with young w m e n , such as Danae and Lida, As time w n t on, the role of gods in human interilction increased m d their reign over nature became less important.

When the Romans adopted Greek nlyrbology as their official religion, they added to the Greek panlheon several gods e. Eventually the Roman emperors themselves were proclaimed to be gods.

No similar redefinition of human ruler to divinity toak place among the Greeks, even t't7ougli the latter believed the gods sired earthly creatures like Hercules. In these and other examples, the activities of the gods over time shifted from the domain of nature alone to intervention in the behavior and social agairs of people.

This shift away from the natural and toward the social world occurred at an early period in recorded history. Accompanying this development of religion from early animism to organized social systems was the same articuiation of belief, the same discourse and object-making typical of early forms. This discourse regulated daily life. The Judeo-Christian bible, which also influellced the Koran, becarne the central focus for the organized religions of Judaism, Christianity, and Islam, and thus, the basis far the religious beliefs of over half the world's poputatian, The bible, as a codified text reproduced from generation to generation, was not the only discursive component of organized religion.

With Judaism, for example, discussion of the core text produced immense reams of commentaries, s w h as the BabyIonian Talmud, as well as firrther elaborations that passed from oral to written culture. Around the core text-as happened for Christianity and Islam as well-arose a host of ancillary beliefs and practices, each with its own themes and material objectificarions, The societies organized by institutionalized religions were rtloroughly regulated by these belief systems.

Every object, every action, ewry moment, ewry person possessed a symbolic connotation. L u c h a n n calls life under rht ""sacred canopy"" Over time this pr"ctice produced etahorate discourses or myths that made living itself symbolic and the world that was inhabited a redm of signs, People handed down these empowering stories through the generations, and the stories eventually hrmed the core of organized refigisus systems, ElTuman activity is naturally a signiEying activity, That is, humans crave and therefore create meaning for their actions and their environment, S p b o l production was as basic to everyday life as was the search for hod, clothing, and shelter.

In what Follows, however, we shall see that the production, qualil i and social context of themed environments have changed since ancient tirnes, as has their purpose in daily life, Despite the historical shifts, both the production and enjoyment of a connotative milieu that is ""lemed" has always been basic to human existence and everyday life.

Later in this chapkr 1 discuss the sfai. The remainder of this b a d discusses the revival of the desire for themed milieus that seems to characterize our society toda i and the reasans for the present shifi. The Contrast Bemeen Ancient and Modernist Cities Reiiance on themed milieus in the built environmm began to increase in ttx s.

All ancient cities were o. All ancient civilizations constructed settlement spaces that were overend w e d with meaning and material symbols. Even now, many traditianal societies assign great importance to signs and overarehing themes in the construction of their settlement spaces, Ancient societies most commonly built places uslng a cosmoIogical ideology; Buildings were situated according to particular directions that promised luck or paid homage to the gods, The present-day Chinese yractice of feug situi embodies these ancient cssmological practices of siting.

Those who practice felzp shui believe that goad or ill fortune depends, in y spaces are shuatect. Perhaps the hest example of the city as a syntlbolic construction is classical Athens, in Greece. The early Greeks conceived of the w r l d as a circular orbit with a sacred center, Consequently, Athens was planned using the circle as its principal figure.

At its center was the sacred ptlblic hearth, or the hestia knine. The Greeks of the sixth century B.

An elevated mesa, called the acropolis; dominated the entire city. Like all sacred buildings in Athens, the Parthenan was scaled aaording to the golden mean-a set of propoflions dictating widlh, height, and lengh, whictn. Before that time, people built cities with clearly defined symbolic referents in mind.

By the time knodedge of the Holy Land had circuillted hack to Europe, people occasionally designed cities according to the crusader maps of Jerusalem, This plan consisted of one long mrridor running lengthvcrise through the cit- i,after the Roman cardo in Jenxsalem, and a second thoroughfare that bisected the main street, so that the entire configuradon was in the sign of the cross.

With the coming of capitalism at the end of the European Middle Ages here is no definitive date , religion and local signiQing practices were aside in favor of the firnctional need of accumulating wealth. According to b l a n d Barthes , the classic city of early capitalism grew around a center that contained buildings corresponding with the most powerful forces of social organization. The facades of most buildings in the capitalist dwntowns w r e retativeZy devoid of crbvious thematic connotations, being k n w n instead for their functions.

O f course, the city as a d o l e did and still does symbolize domination by capital and private wealth, By the late nineteenth century in the West, urban living had already become probiematic and many social leaders were appalled at the poor living and working arrangements of people in the industrial city.

The filth and congestion of fdctories, frequent public health crises, and the 6ist spmad of epidemics, poverty homelessness, and child abandonment were obvious urban piagues of nineteenth-centufy capitalism, In response to this social crisis of the functronal city, which tbcused on profit xnking rather than the nurturing of a more humane or symbolic environment, urban reformers began to dream of alternate spatial models-models that also served as critiques of current city living, 'The new planning models addressed the ills of urban Xik through utopian planning and simultaneously infused the built environment with a richer symbolism.

ElToward proposed, instead, a plan for all new city building that strove h r a balance betweell the urban and the rural. Cities wouId be limited in size, and surrounded completely by a circular p e n belt of vegetation; traffic would be restricted to distinct corridors; and residential structures would he airy, with easy acess to gard,ens and green areas, The vision developed by Wright at the turn of the century was very similar 16 Eloward".

Society" ills at this time were wideliy blamed on the big, sprawling industrial city, As the poet Ernerssn preached, only a return to nature could cure people of the evils of capitalist industrializadon. The community also added an accessibility gate for core issues in Drupal 8. Drupal isolates core files from contributed modules and themes. This increases flexibility and security and allows administrators to cleanly upgrade to new releases without overwriting their site's customizations.

Content types include, but are not limited to, events, invitations, reviews, articles, and products. Basic views functionality has been added to core in Drupal 8.

Rules: conditionally executed actions based on recurring events. Features: enables the capture and management of features entities, views, fields, configuration, etc. Context: allows definition of sections of site where Drupal features can be conditionally activated Media: makes photo uploading and media management easier Services: provides an API for Drupal.

Themes adapt or replace a Drupal site's default look and feel. Drupal themes use standardized formats that may be generated by common third-party theme design engines. Drupal 8 will integrate the Twig templating engine. A popular Drupal contributed module called 'Devel' provides GUI information to developers and themers about the page build. Community-contributed themes [76] at the Drupal website are released under a free GPL license, [77] and the most installed Drupal themes are listed on this page.

Today, however, a distribution defines a packaged version of Drupal that upon installation, provides a website or application built for a specific purpose.

Either modifying this setting or including a logo. Drupal allows for easy manageability by supporting chaining with subthemes. Chaining Subthemes can be chained, if necessary. For example, our mytheme could now become the base theme for another theme named mynewtheme which would inherit all the modifications made by mytheme to Garland. See also The next recipe, Overriding base theme elements in a subtheme, explain how to override template files belonging to the base theme from within a subtheme.

It is also worthwhile exploring two recipes from the next chapter, namely, Creating a theme from scratch and Creating myzen, a Zen-based theme.

Overriding base theme elements in a subtheme This recipe details the steps involved in overriding a template file registered by a base theme with an equivalent file in the subtheme. As an example, we will be restructuring the layout of a Drupal node by modifying the node.

Getting ready We will be using the mytheme subtheme that was created in the previous recipe. As we are dealing with a subtheme here, it is by default relying on the template files of its base theme. To override the base file used to theme the layout of a node, copy the node. Opening the new file in an editor should bring up something similar to the following: To elaborate, we are going to move the node's submission information from a position at the top, right to the bottom of the node display.

This can be done by simply moving the relevant block of code to an appropriate location further down in the template file, as highlighted in the following code: As we have made changes to the template system, we will need to rebuild the theme registry, or as is recommended throughout this book, simply clear the entire Drupal cache.

For performance purposes, Drupal maintains a registry of all the stylesheets that have been included, the template files that are available, the theme functions that have been declared, and so on. As our theme initially had no node.

However, once we added one to the mytheme folder, we needed to rebuild this registry so that Drupal became aware of our changes. Once this was done, Drupal used the updated node. The following screenshots provide a before and after comparison of an example node: In the following screenshot, we can see our modified template file in action as the position of the submission information DIV has moved from the top to the bottom of the node: The non-invasive technique of extending base themes using subthemes allows for smooth upgrades.

Clean upgrades If we had modified the node. By using a subtheme, we can now upgrade Drupal without any fear of losing any changes we have made. Another positive is that if bugs have been fixed in Garland, they will seamlessly propagate downriver to our subtheme. See also The first recipe in Chapter 3, Custom Themes and Zen details how to go about Clearing the theme registry, an oft-repeated procedure throughout the theme development cycle.

Changing the screenshot image of a theme This recipe details the steps involved in changing the screenshot image associated with a theme. This image provides the user with a preview of what the site will look like when the theme is enabled. This is normally only required when we are working with a subtheme or a custom theme.

Getting ready Once the theme is just about ready to go, visit the front page of the site to take the screenshot. As we are providing a snapshot of the theme, temporarily swap the name of the site with the name of the theme. It might also be useful to prepare some example content for display on the front page to obtain an accurate representation of the style and layout of our theme.

Adding a screenshot for our theme can be done through the following steps: Open up a graphics editor and paste the screenshot within. Make a wide selection of the theme incorporating different elements such as the position of the logo, breadcrumb, fonts and node styles, and so on. Crop and resize to x pixels which is the rather odd standard for theme screenshots.

Save the image as a PNG file named screenshot. Finally, copy the file to the theme's folder. Drupal automatically looks for a file named screenshot. Each theme's. This includes nominating the screenshot file to be used. Using the. In this case, we will be adding a CSS file to the mytheme subtheme that we created earlier in this chapter. Getting ready We will be including a CSS file in this theme.

Open the file in an editor and add the following example rule to it: Adding a CSS file to a theme is best accomplished through its. Add the following line to this file to include our CSS file: The folder name is arbitrary and is not necessarily restricted to CSS.

Once done, save the file and exit the editor. As we have modified the. Therefore, clear the Drupal cache and view the site to confirm that our new stylesheet has been included correctly. If it has, then the theme should now display all text in brown as shown in the following screenshot: Drupal checks the. The syntax of this variable is similar to that of an array in PHP. The all index in the syntax represents the media type as used in CSS declarations.

The next screenshot displays a section of the source code of a page that confirms the inclusion of the new stylesheet, mytheme. We can also see that our subtheme is also including the stylesheets declared by its base theme, Garland, as well as its own stylesheets: In the preceding screenshot, we can see that Drupal references each stylesheet along with a query string. For example, mytheme. This quirky suffix is a trick used by Drupal to ensure that browsers do not use stale copies of a cached CSS file while rendering our site.

We can test this by clearing the Drupal cache and viewing the source code once again. Now, our stylesheets should have a different suffix, perhaps something like mytheme. One of the advantages of using a subtheme is that we can easily override elements of the base theme. This includes stylesheets as well. Overriding the base theme's stylesheet If the base theme includes a stylesheet named layout.

In other words, Drupal will include the subtheme's stylesheet instead of that of the base theme. The first recipe in Chapter 3, Custom Themes and Zen details how to go about clearing the theme registry, an oft-repeated procedure throughout the theme development cycle. In other words, multiple related CSS files are grouped together into a single file and then compressed to produce a much smaller file. This optimization provides a significant boost to performance both on the server as well as for the user.

This recipe demonstrates how to enable this feature in Drupal and explains how it works. Getting ready CSS optimization is a requirement only when a site is ready to go live. Until such time, it is recommended that it be left switched off as otherwise, CSS changes during development will not take effect unless the Drupal cache is cleared. This performance configuration page should have a section titled Bandwidth optimization which contains options for CSS and JavaScript optimization.

Look for the setting named Aggregate and compress CSS files. Once done, click on the Save configuration button at the bottom of the page to save our changes.

Aggregation involves the collating and joining of multiple CSS files into a single stylesheet, while compression reduces the resulting file to a smaller size by trimming out unnecessary elements such as whitespace. The former helps in reducing the number of files that the server has to load and serve, while the latter saves on bandwidth and time. Each of these files has to be downloaded separately by the user's browser which creates a lag as the web server has to serve each of them separately as well.

Furthermore, the multitude of import calls result in each file being downloaded and parsed in sequence rather than in parallel which increases the wait time for the user even further. All in all, there are eleven files that need to be processed. If this is extrapolated to sites of greater complexity, the number of files and, consequently, the server and bandwidth load begin to take on significant proportions and can seriously impact performance.

The following screenshot is the same page as before with one difference, CSS optimization is now turned on. The number of CSS files has now been reduced to only five, four for all media types and the other being the print media type.

These stylesheets are stored in the Drupal filesystem and are cached copies. As a result, each page load now only involves the web server serving five files instead of the previous eleven. While this drastically reduced the number of files required to be loaded, the fact that different Drupal pages had different combinations of stylesheets meant that the same files were being optimized repeatedly to account for minor changes in the combination.

In Drupal 7, this issue has been solved by introducing a grouping variable which allows for the optimization of related stylesheets such as system and theme stylesheets separately. While this increases the number of aggregated stylesheets, to five in this recipe, the overall performance increases as the server does not need to reaggregate as often.

CSS optimization and other performance improvements should be used with care. Enabling them prematurely during the development stage can slow down development or lead to bugs and anomalies going unnoticed as we would then be working with cached versions of the code.

However, there are exceptions where this is not the case. Internet Explorer and the number 31 It is generally considered that CSS optimization is only necessary to improve performance on production sites and that enabling it beforehand will only hinder development. However, optimization can sometimes be handy during theme development on Internet Explorer. This browser has a hard limit of 31 stylesheets, that is, only the first 31 CSS files are considered and the rest are ignored.

While 31 stylesheets might initially appear ample, sites routinely incorporate enough modules to easily exhaust this limitation. By enabling CSS optimization, we can work around this problem by drastically reducing the number of stylesheets that need to be loaded. Other optimizations Other optimization settings can also be configured on the performance page.

These include page caching, block caching, and JavaScript optimization. While page and block caching endeavor to reduce the number of database calls that Drupal has to make to load and render content, JavaScript optimization offers benefits similar to those gained with CSS optimization. It is also worthwhile browsing through the Caching and Performance modules that are available as contributed modules through http: While a lot of theme-specific cases can be stored in template files, certain tweaks which are theme-agnostic require that we store them in a module to ensure that they are available to all themes.

This recipe covers the creation of a module to hold our tweaks and other bits and pieces. These modules and themes are automatically made available to all sites using this Drupal installation. The following list details the procedure involved in creating a module named mysite to hold our theme-agnostic customizations and other odds and ends: Within this folder, create a file named mysite. Edit this file and add the following code inside: Create another file named mysite.

This is the file that will hold our odds and ends.

Save and exit the editor. Just as with themes, modules require a.

Planning and Managing Drupal Projects by Dani Nordin

Once Drupal ascertains that the module is compatible with the version installed, it loads the. We can test if the module is working by adding a snippet such as the following: This is confirmed in the following screenshot: The Drupal community routinely comes up with modules to ease the pain of development.

Module builder There's a module available named Module Builder which can be used to generate a skeleton of a general module. This can subsequently be populated as per our requirements.

It is available at http: This could be useful, for example, to style features added by the module, or to style content added by some other module.

When compared with including stylesheets through a theme's. This recipe demonstrates how to add CSS files using the mysite module. Getting ready We will be using the mysite module created in the previous recipe. Within its folder, create a subfolder named css and subsequently, within it create two CSS files named mysite.

Add the following code to the file mysite. Visiting the site and viewing its sources should confirm that two new CSS files are now being included for every page. Its syntax is as follows: In the first call, we include a file from the css folder: The first passes the path to the mysite-special. The second, however, passes an array containing two additional directives which explicitly instruct Drupal not to aggregate this file and furthermore, also ensure that this file is included ahead of other similarly configured CSS files by virtue of its lower weight.

Looking at the source code of a typical page on the site when CSS optimization is enabled, we should see the stylesheets included similar to the following transcription: By enabling CSS optimization, we should find that only the mysite. This documentation is parsed directly from the comments included in the Drupal code.

Consequently, the same information can also be retrieved by sifting through the Drupal source code, preferably with a capable editor. We can do this by passing a string containing our CSS and instructing Drupal that it is to be included inline by way of the second parameter.

Drupal Books

In this case, we have prefixed the special. This makes it easier while grouping and overriding stylesheets and reduces ambiguity and confusion. Enabling CSS optimization, seen earlier in this chapter, is also relevant. As an example, we will be adding the code that allows the rotation of themes based on the day of the week. Getting ready As we have seen in other recipes in this chapter, a number of sites use an "odds and ends" module to handle tweaks and customizations particular to the site. We will be using the mysite.

It is assumed that the module is available and already enabled. Open the mysite. Due to the nature of this feature, it might be necessary to fiddle with the computer's date settings to simulate different days of the week during testing. Drupal changes the theme being used based on the value returned by this function.

As we are looking to change the theme based on the day of the week, we are going to take advantage of a feature of PHP's date function that returns the day of the week as a number between zero and six with the former representing Sunday and the latter denoting Saturday. Finally, returning the associated theme overrides the default theme with the theme for the current day of the week. The PHP code used in this recipe can be easily modified to display a random theme on every page load.

Creating a fresh look using the Color module The Color module allows the administrator to easily change the color scheme of themes that support it.

This facilitates a fresh look for the site without having to create a new theme or subtheme. Among Drupal's core themes, Garland and Bartik both support the Color module.

In this recipe, we will be covering the steps required to change the color scheme of Garland to something different and possibly unique. As we are going to change the color scheme of the Garland theme, ensure that it is enabled and set as the current theme. Colorizing the Garland theme can be accomplished by following these steps: Look for the Garland theme and click on its associated settings link. In the ensuing page, look for the section titled Color scheme. In this section, the Color set drop-down lists a host of available preset color schemes.

Choosing any of the presets will change the color scheme of the Preview section further below: Once satisfied, click on the Save configuration button at the bottom of the page to save our changes. The Color module works by generating stylesheets using the new color scheme which effectively replace the existing stylesheet at runtime. The generated CSS file is stored in the site's filesystem in a folder named color.

In addition to the stylesheets, the Color module, can also dynamically blend the theme's image assets to suit the new color scheme. As it is a copy, fixes and updates to the original file are automatically propagated to it. Therefore, whenever changes are made to the original file, it is recommended that the stylesheet be regenerated by simply saving the customized color settings once again.

We are not restricted to the inbuilt presets provided by the Color module and can also create our own. Custom presets If the provided presets are unsatisfactory, clicking on the text fields below the drop down will allow further customization. Once a text field has focus, the color wheel on the right can also be clicked and used to select different palettes at will.

These new settings are saved as the Custom preset as demonstrated in the following screenshot: The locks in the previous screenshot can be activated or deactivated. When activated, adjusting one value will adjust any linked fields by a relative amount.

When deactivated, each field can be adjusted individually. Custom themes are the solution for websites that demand a fresh look, use complex layouts, or require such intricate fine tuning that it would be prudent to start with a clean slate.

This includes setting up the theme using. But over time, developers have identified a list of common tasks, characteristic layouts, and file and folder hierarchies that are logical, efficient, and promote reuse. This has evolved into what have been dubbed starter themes—themes upon which custom themes are built, usually as subthemes. The most popular starter theme for Drupal is Zen. As advertised on its project page, the idea behind the Zen theme is to have a flexible standards-compliant and semantically correct XHTML theme that can be highly modified through CSS and an enhanced version of Drupal's template system.

It is designed in modular fashion thereby making it straightforward to change layouts, override templates and theme functions, and to add or remove features. Additionally, the Zen theme comes with extensive documentation within each file which make things all the more convenient. For example, layout rules are contained within a dedicated layout. This makes it convenient when it comes to managing and tracking code changes. In addition to the standard files that we have encountered while customizing themes in the earlier chapters, a Zen-based theme contains the following file and folder structure: A file where settings particular to a theme can be placed.

These settings php are customarily exposed on the theme's configuration page. Some of the more popular ones include: Clearing the theme registry Before we begin, we need to familiarize ourselves with a seemingly trivial yet crucial task that needs to be performed on a routine basis during theme development—clearing the theme registry.

The theme registry is essentially a table that Drupal uses to list and track the files and features of a theme as well as the theme functions which are being exposed by modules and the theme itself. While it is a recommended practice to turn on Drupal's cache feature only for production sites, the theme registry is built and cached regardless of other caching options.

As a result, any changes that affect the structure of the theme will necessitate the clearing of the theme registry. Getting ready Rebuilding the registry is an intensive operation which is required only when changes have been made to the theme files. There are a number of ways of clearing the registry. However, during development or debugging, we will want to clear the registry with great regularity. Instead of having to do so manually, it is often handy to be able to instruct Drupal to perform this operation automatically on every page load.

Some themes, including the Zen- based theme, which we will be familiarizing ourselves with later in this chapter, offer an option on their configuration pages to rebuild the registry on every page load. While this is certainly convenient, the recommended method of managing this and other development-oriented operations is through the use of the Devel module.

As the name suggests, the Devel module is one that is tailor-made for use during development. It can be downloaded from http: Drupal maintains a cache of all. This registry is a part of the cache table in the Drupal database. When we click on the Clear cache data button in the Performance settings page, all Drupal is doing is clearing this entry in the cache table, which automatically forces a rebuild of the registry.

The Devel module does the same thing when the Rebuild the theme registry on every page load setting is enabled, except that it does this automatically on every page view. It's important to keep in mind that rebuilding the registry, or for that matter clearing any of the caches, is an expensive operation that adversely affects the performance of the site. Therefore, it is recommended that this setting only be enabled during development and not in production sites.

Clearing the registry is an important factor to keep in mind during development and especially during debugging. More information on development and debugging tools including the Devel module is available in Chapter 5, Development and Debugging Tools. The Devel module also provides a block with handy shortcuts to oft-used areas of the site. As it is a menu, the block will be made available only if the Menu module is enabled. Once enabled, the block lists a number of links to perform operations such as emptying the Drupal cache, rebuilding the menu cache, and even reinstalling modules as shown in the following screenshot.

Emptying the cache will also force a rebuild of the theme registry. Once the theme is reasonably stable, it might be more efficient to manually clear the cache through this block instead of rebuilding the registry during each page view: See also Chapter 5, Development and Debugging Tools elaborates further on the uses of the Devel module during theme development.

Creating a theme from scratch While we have earlier looked at installing contributed themes and extending base themes using subthemes, this recipe will outline the steps required to create a custom theme from scratch. Some administrators prefer to go a step further and place custom and contributed themes in their own folders.

Creating a brand new custom theme is not unlike what we did in Chapter 2, Beyond the Basics, in creating a subtheme for a core theme. The primary difference is that there is no base theme in this case and that files such as page. In this example, we are going to call our theme mytheme.

Within this folder, create a file named mytheme. Add details about the theme as follows: Enable the theme and activate it by clicking its Enable and set default link. Seeing mytheme. When the new theme is enabled, what we will see is largely unstyled content not unlike the following screenshot. The problem here is that we have not specified any CSS stylesheets to lay out the page. The only styles being loaded are those that are module-specific as opposed to theme-specific: The styles being used in the preceding screenshot are as follows: Furthermore, during the process of building the page, Drupal has noticed that we do not have any template files in our theme, most notably, page.

Similarly it is using the node. In other words, we have a lot of work ahead of us in getting things up and running especially if our eventual requirements are going to be complicated. As we will see in the next recipe, this is one of the reasons why most themers prefer to use a starter theme and hit the ground running. See also The next recipe, Creating myzen—a Zen-based theme, implements a custom theme based on a starter theme named Zen.

Creating myzen—a Zen-based theme While building a custom theme from scratch is great, most themers prefer to use starter themes as the base for their designs. Starter themes save time and effort as themers do not have to perform tedious repetitive tasks, and can rely on a tried and tested structure to use as a foundation for their custom themes.

In this recipe, we will be looking at creating a theme based on the most popular of all starter themes available on Drupal.

Getting ready Download the theme from http: The default Zen theme does not need to be enabled for our custom theme to work. The Zen theme provides a starter kit that can be used to kick-start our theme: Rename the folder to the name of our new theme which, in this recipe, is myzen: Open the.

Update the name field to the name of the theme which in this case is myzen. Update the description field to My custom Zen sub-theme. Save and exit this file. Open template. Repeat the find and replace operation for the file theme-settings. It should now display our new theme. Screenshots, favicons, and other niceties can be configured just like for any other theme.

Once we have made a copy of this folder and renamed its. While the Zen theme needs to be available, it does not need to be enabled for myzen to function. Once enabled, the front page of the site will look something like the following screenshot.

It is worthwhile comparing the screenshots in this recipe with those from the Creating a theme from scratch recipe earlier in this chapter. The essential difference is that we have a fleshed-out skeleton to work with when we use Zen with a lot of the right pieces already in the right place: The Zen theme comes with a plethora of settings and documentation, which can at times be a little overwhelming.

But the rewards of familiarizing ourselves with them are worth the time. Subtheme of Zen We can confirm that this is a subtheme of Zen through its.

It is a good idea to always read through these files beforehand rather than diving in head first. Rebuild theme registry on every page The Zen theme contains a setting that rebuilds the theme registry automatically on every page load.

This setting is exposed in the. By default it is enabled. Zen comes with a couple of preset layouts that can be used. If neither of them is suitable, a custom layout can be created. In this recipe, we will be replacing the default fixed-width layout with a liquid layout which we discussed in Chapter 1, Drupal Theme Basics.

Getting ready We are going to assume that the myzen theme from earlier in this chapter is enabled and the current default. It is also important to decide on the type of layout required for the site during the design stage. All we are going to do here is replace one of the stylesheets used in myzen with another: Open myzen. Save the file and exit the editor. In what should be second nature by now, clear the theme registry for our changes to take effect.

The default fixed-width layout is, as the name suggests, of a fixed width. The positioning of the content does not vary based on the dimensions of the browser and the resolution of the user's monitor. Consequently, we are assured of a consistent structure regardless of the user's configuration.

By replacing the layout-fixed.

Planning and Managing Drupal Projects by Dani Nordin

Unlike fixed-width layouts, liquid layouts try to occupy as much of the available real estate as possible. In other words, larger monitors and browser windows will be able to view more of the content while smaller ones will have to do with less. Once this layout is enabled and the theme registry cleared, we should be able to see that the layout of the site now occupies the full width of the screen and will flow and reposition itself as we resize the browser window.

Zen and its subthemes take care while displaying content and ensure that the markup is clean and semantically correct. Furthermore, in light of the growing internationalization of the web, it provides Right-To-Left RTL support out of the box.

What is RTL? RTL is an acronym for right-to-left and is used to signify that the stylesheet will be used when RTL mode is enabled, customarily for sites with content in languages such as Hebrew and Arabic. Other types of layouts such as grid layouts are also in vogue. If a custom layout is necessary, all that needs to be done is to add the appropriate rules to a stylesheet such as layout-custom.

See also Later in this chapter, the recipe, Adding a custom region to myzen, explains how to go about adding custom regions to our layout. Overriding Zen template files with myzen Zen subthemes, by default, use the page, node, and other template files directly from the base theme. In other words, we do not need to specify template files in our myzen theme unless we are looking to change the template.

In this recipe, we are going to override the base theme's page. Getting ready We are going to assume that the myzen subtheme is already created and available. The following steps outline the procedure to import a template file from the base theme to the subtheme: Copy the page. Within the subtheme, open this file in an editor. It should be located in a code block not dissimilar to the following code snippet: What we are looking to do is to move the status messages to a more prominent location above the title and the breadcrumb.

After moving the relevant line of code further above, this block should look something like the following code snippet: Save the file and exit. As we have imported a template file, we also need to clear the theme registry. We should now be able to see our changes in effect when a node, for example, is updated.

Once we have copied the template file from Zen to myzen, and subsequently cleared the registry, Drupal was alerted during the theme registry rebuilding process that a new page. Due to the fact that this template file was located in the myzen theme's folder, it took precedence over the version contained within the Zen theme's folder leading to our updates taking effect.

The following screenshots should offer a before-and-after comparison of this recipe in action: In the previous screenshot, we can see that the status message is being displayed below the title of the node. However, with our new template file in action, we can see that the status message is now displayed above the title and the breadcrumb as shown in the following screenshot: Adding a custom region to myzen Regions are essentially containers for Drupal blocks.

The layout of regions in a page effectively dictates the layout of the site. By default the myzen theme contains the following regions: We will be updating the default page. In order to add a custom region to myzen, follow the ensuing steps. First up, we will be updating the regions list in the. Open the myzen. Scroll down to the section dealing with regions. Look for the following declaration: Replace the previous declaration with the following: Now that we have added our new regions, we need to ensure that Drupal uses them by updating the page.

Open myzen's page. Scroll down and look for the following line of code: Replace the preceding line with the following two: Clear the theme registry as per usual. Clicking on the Demonstrate block regions My Zen link at the top of the page should provide a visual representation of the theme regions.

Drupal's theming system loads and caches information from each theme's. This includes information on the regions that each theme wants to declare. These regions are populated by Drupal and its installed modules with content and then presented to the templating engine.We have accomplished this change in this recipe by moving the skip-link DIV from the html.

The following screenshot displays our newly created welcome block as part of the Garland theme: The next chapter, Development and debugging tools, covers further aspects of the Devel module and other tools in greater detail. It gets a little complicated with our myzen recipe as it is actually a Zen subtheme. Boreth, beginning theming download download free drupal 7 views cookbook pdf cookbook software jdk 1. The Theme developer module, besides providing information on theme functions and template files, also links to their documentation pages.

The non-invasive technique of extending base themes using subthemes allows for smooth upgrades. At its center was the sacred ptlblic hearth, or the hestia knine.

Another important distinction concerns the way T use the concepts af ""production" and ""consumption.

TEMEKA from Washington
Please check my other posts. I have a variety of hobbies, like pigeon racing. I relish reading books rigidly .