Theme development varies depending on your Web site. Google.com rates as a large custom site worth building a new theme by hand. Smaller sites, such as facebook.com, do not warrant that much work because nobody looks at the theme. That site you built for your grandma to sell quilts is worth more work than facebook.com because you want exactly the right style. You do not want to screw up the theme for the only woman in your life who bakes real cakes.
The google.com search page is one page with enough use to warrant custom code from the ground up. Everything else can be built quicker and easier in Drupal when you take into account the full lifecycle of work. Drupal gives you a huge choice of themes and how to develop them. Mistakes are as easy as choosing the wrong gelato when in a cafe with 60 different flavours. With 60 choices, how are you to know their Tiramisu is too bland. With 1025 choices, Drupal is even harder.
On top of everything else, Drupal lets you use any theme as a base theme for another theme, with the other theme called a subtheme. Drupal gives you so much choice you may miss some of the important decisions to set your development on the right track. Here are some wrong decisions to avoid.
- Create your first theme from scratch
- Choose the wrong starting point
- Start with the wrong version
- Throw in something unrelated
- Choosing an unsupported theme without a reason
- Ignore watchdog
- Switch off PHP errors
Create your first theme from scratch
Drupal lets you create a theme based on another theme so you can benefit from all the work in the original theme plus make any changes you like gradually without breaking your starting point.
There are rare occasions where you need to build a new theme from the ground up. Do not build your first theme from the ground up. Find the theme closest to what you want then work on just the minimum changes to get what you want. Study the way the existing theme does things. You learn and you get a finished theme in the shortest time.
The next time you build a theme, start with a lighter weight theme and add more of your own work. You will quickly reach a point where the extra effort does nothing for you and you will go back to a more complete theme as a starting point.
Choose the wrong starting point
Drupal lets you use an existing theme as a
base theme then add your modifications on as a separate
subtheme. You get the ultimate flexibility without significant work.
The most popular base themes for Drupal 7 are listed next. Zen is the one everyone knows and can be complex but there is a mass of documentation. Adaptive Theme has less documentation and it has some very popular subthemes you can use as a start point.
Most of the big base themes have options you can set to vary the theme without programming. For instance, Zen lets you choose a fluid or a fixed layout.
Some of the themes have two versions to cover the old XHTML and the new HTML5. Zen has version 3.x for XHTML and version 5.x for HTML5.
Start with the top theme based on usage then work down the list until you find what will work for you with the minimum of change.
Start with the wrong version
As an example, Zen is available in version 3.x and 5.x. If you are starting a new project, choose the latest version. People will often choose the previous version for stability but not allocate time or money to upgrading later. For most sites, the upgrade does not happen until management outsources the whole project and you lose your job.
Starting with a brand new development version can also be a problem if your development timeframe is very short. Development versions can chop and change way beyond your time allocated for maintenance. Generally a release candidate it a safe bet for Web sites due out in three months and beta versions for Web sites due out in six months.
Throw in something unrelated
Your theme produces a slightly different result on one web browser, just a pixel different here or there. Someone complains because they are used to print where everything is pixel perfect (but only if they use the most expensive print process).
Your mate sends you an unknown CSS file download from some mystery Web site and you install it bang in the middle of your theme. The unknown file fixes the reported problem. everyone says
magic. You have effectively done the equivalent of install a virus.
Those mystery files, often called a
reset, simple set some defaults usually set in drupal and your base theme. You replaced all the defaults with different defaults and you will spend many hours tracking down weird errors caused by the reset, with most resets costing far more than what they contribute.
If you do have a problem and it is solved by a reset, track down the exact change fixing the problem then remove the reset and add the individual change to your subtheme then contribute the change as a suggestion to the developers of your base theme. They will [ick up some of the suggestions and incorporate them in a future release, removing the need for your modification to your subtheme and hopefully eradicating another reset. Fixing a problem in a base theme is far more useful than covering the sore spot with endless reset bandaids.
Choosing an unsupported theme without a reason
There are lots of impressive themes with support for what they already do but will never have support for the enhancements you request and the themes may never survive the upgrade from Drupal 7 to drupal 8. Choosing one of those themes with little use and little active development is a mistake that will bite you in a few months. you will have to throw it away and start again.
Does that mean you never look at those themes? No, you create several parallel test sites using the Drupal multisite feature then you place your base theme on one of the sites and the weird other theme on another site. You then experiment with a merge of features from the specialised theme to your subtheme. In most cases the result is better than the weird little theme and in the long term, easier to maintain.
Some of the weird little themes are being redeveloped as subthemes of big base themes because the developers of the weird little themes cannot afford the big conversion to HTML5 and all the other good things already in the big base themes.
Watchdog is Drupal's way of telling you something should be looked at. Visit your Web site, log in as administrator, then visit
Administration &rquo; Reports &rquo; Recent log messages (
/admin/reports/dblog). Check every type of message and fix everything marked as an error or warning.
When you develop a theme, you will be talked into changing a template file, a
.tpl.php file. The some of the data for the template pages will be missing on some pages. Look for the watchdog errors telling to to expand your template code to check for the existence of the data before your code tries to use the data.
Switch off PHP errors
PHP error messages are there for a reason. The right thing to do is to fix the code so there are no error messages. Instead developers switch off the error messages. This mistake is equivalent to closing your eyes while driving a car.
Not all developers are to blame for this disaster. Some stupid teachers teach students to switch off error messages. Some stupid hosting companies switch off errors. There are endless people switching off error messages because they just do not care, it is not their Web site. Missing data is just a new opportunity to charge more money to diagnose and fix the problem.
All error reporting should be on at every state of development, testing, and quality assurance. You might temporarily turn off the on screen display of errors on your production site but make sure everything is logged somewhere and check the logs on a regular scheduled frequency.