<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.waycoolwebdesign.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Content Management</title>
 <link>http://www.waycoolwebdesign.com/Blog/Content-Management</link>
 <description>The taxonomy view with a depth of 0.</description>
 <language>en</language>
<item>
 <title>Theming Drupal 5.x, or, How To Thumb-Wrestle Drupal 5 Into Submission and Lay It Low At Your Mighty Feet, Part 2</title>
 <link>http://www.waycoolwebdesign.com/Blog/2009/03/13/Theming-Drupal-5-Part-2</link>
 <description>&lt;p&gt;In &lt;a href=&quot;/Blog/2009/03/13/Theming-Drupal-5-Part-1&quot;&gt;Theming Drupal, Part 1&lt;/a&gt; we talked about some of the basics of the Drupal theme, getting started with your design, code, and the initial steps to creating the theme. Now, as Young MC might say, its time to bust a move.&lt;/p&gt;&lt;p&gt;Your first ally in real theming is the template.php file. This is the place where you override (theme) Drupal&#039;s core while maintaining the virgin-freshness of the core itself. If your theme doesn&#039;t have a template.php file, add one now. If you&#039;re adding one, just add an empty file.&lt;/p&gt;
&lt;h2&gt;Theming Drupal Regions: Ad, Delete, Mix and Match - More Fun Than Garanimals!&lt;br /&gt; &lt;/h2&gt;&lt;p&gt;The first thing to notice inside template.php is the regions function: &amp;quot;function themename_regions()&amp;quot;. If you don&#039;t have this function because you&#039;re starting with an empty file, add it now (Garland doesn&#039;t have it). It looks something like this:&lt;/p&gt;
&lt;div class=&quot;google_ad1&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-2938344934790216&quot;;
/* 200x200 for Blog, created 3/11/09 */
google_ad_slot = &quot;6360764911&quot;;
google_ad_width = 200;
google_ad_height = 200;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;p&gt;function mythemename_regions()&lt;br /&gt;{&lt;br /&gt;    return array(&lt;br /&gt;        &amp;quot;sidebar_left&amp;quot;=&amp;gt;t(&amp;quot;left sidebar&amp;quot;),&lt;br /&gt;        &amp;quot;sidebar_right&amp;quot;=&amp;gt;t(&amp;quot;right sidebar&amp;quot;),&lt;br /&gt;        &amp;quot;content&amp;quot;=&amp;gt;t(&amp;quot;content area&amp;quot;),&lt;br /&gt;        &amp;quot;header&amp;quot;=&amp;gt;t(&amp;quot;site header&amp;quot;),&lt;br /&gt;        &amp;quot;footer_message&amp;quot;=&amp;gt;t(&amp;quot;site footer&amp;quot;)&lt;br /&gt;    );&lt;br /&gt;} &lt;/p&gt;
&lt;p&gt;The regions function allows you to add regions to your design. Be sure each theme&#039;s region function is named appropriately. For example in our example from Part 1 the theme is called &quot;my_theme&quot; so the function name will be &amp;quot;function my_theme_regions()&amp;quot;.&lt;/p&gt;
&lt;p&gt;An example of adding a new region to your theme is, say on the home page you wanted to have a rotating promo. Create a new variable name such as $promo then insert this variable into your page.tpl file like you do any other Drupal snippet such as $content or $sidebar_left. Then in your region function add a new line so we can make the region appear in your blocks for that theme:&lt;br /&gt; &amp;quot;promo&amp;quot;=&amp;gt;t(&amp;quot;home page rotating promo&amp;quot;)&lt;/p&gt;
&lt;h2&gt;Creating a Drupal Content Type&lt;/h2&gt;
&lt;p&gt;Now you&#039;ll need to create a new &amp;quot;content type&amp;quot; in Drupal for your home page called &amp;quot;Promo&amp;quot;. To do this go to &quot;administer &amp;gt; content management &amp;gt; content types&quot; and choose &quot;add content type&quot;. This will be where we store our promos from which we will randomly draw one for display on the home page. Once you create the content type, create a couple dummy promos so you can see this in action when we&#039;re done.&lt;/p&gt;
&lt;div class=&quot;google_ad1&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-2938344934790216&quot;;
/* 200x200 for Blog, created 3/11/09 */
google_ad_slot = &quot;6360764911&quot;;
google_ad_width = 200;
google_ad_height = 200;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;p&gt;Next go to Views and add a Block List View of 1 called &amp;quot;promo_view&amp;quot; with the field of Node:Body, a filter of Published:Yes &amp;amp; Node:Type-&amp;gt;&amp;quot;promo&amp;quot;, and Sort Criteria: Random. Next visit Blocks where we tell our theme we want the &amp;quot;promo_view&amp;quot; to be placed inside our &amp;quot;promo&amp;quot; region. Shazzam! You have rotating promos. Ain&#039;t life grand?&lt;/p&gt;
&lt;p&gt;Now I will touch on more customization that I half-promised back in Part 1. It&#039;s more template.php magic. That&#039;s not magic as in Merlin, it&#039;s magic as in Penn &amp; Teller in that I&#039;m gonna show you how it&#039;s done. Sort of...&lt;/p&gt;
&lt;h2&gt;Getting Control of the Drupal Navigation&lt;/h2&gt;
&lt;p&gt;The default Drupal nav was pretty uninspiring to me at first, back when the only way I knew how to accomplish tasks was hacking core. Naughty, naughty. Now I&#039;ve learned a few things and I&#039;d like to share them because it is frustrating to a lot of people. That is namely dealing with some navigation customization. Things like adding a selected state to a list item instead of the anchor, adding a span INSIDE the anchor, and enabling a way to allow for using images in the navigation.&lt;/p&gt;
&lt;p&gt;I&#039;m not really an intensely learned PHP guy. I can understand most of what&#039;s going on and can usually edit existing PHP to achieve a desired outcome, though it may not be the most efficient way, so your mileage may vary, but here is the function I use to spice up my Drupal menus:&lt;/p&gt;
&lt;p&gt;function phptemplate_menu_item($mid, $children = &#039;&#039;, $leaf = TRUE, $extraclass = &#039;&#039;) {&lt;br /&gt;    if (menu_get_active_nontask_item() == $mid) {&lt;br /&gt;    $class_active = &#039; selected&#039;;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if ((menu_in_active_trail($mid)==1)) {&lt;br /&gt;    $active_section = &#039; selectedSection&#039;;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if($mid)    {$mid_id=&#039;item&#039;.$mid;}&lt;br /&gt;    if($children)    {$hasChild=&#039; hasChild&#039;;}&lt;br /&gt;    else    {$hasChild=&#039;&#039;;}&lt;br /&gt;    &lt;br /&gt;    return $thing.&#039;&amp;lt;li class=&amp;quot;&#039;. $mid_id . $active_section . $class_active . $hasChild . ($leaf ? &#039;&#039; : ($children ? &#039; expanded&#039; : &#039; collapsed&#039;)) . ($extraclass ? &#039; &#039; . $extraclass : &#039;&#039;) . &#039;&amp;quot;&amp;gt;&#039;. menu_item_link($mid, TRUE, $extraclass) . $children . &amp;quot;&amp;lt;/li&amp;gt;\n&amp;quot;;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;The above makes a list item (not its anchor) have a &quot;selected&quot; class when active, and its parent will have addionally a &quot;selectedSection&quot; class. This is helpful when you want to control what sections are open/closed using CSS in a menu.&lt;/p&gt;
&lt;p&gt;The above also adds an &quot;item#&quot; class such as &quot;item69&quot; to a nav item. People often use an id for this instead of a class but I often have to generate menu items or parts of the menu several times on a page, and muliiple ID usage is improper HTML, so use a class. This is useful if you want to use images for your nav items because you can target specific list items.&lt;/p&gt;
&lt;p&gt;The above also adds a &quot;hasChild&quot; class so you can do things such as using an arrow bullet in your nav to indicate which sections have children. You can see this in use on this site by rolling over &quot;Projects&quot; in the main nav to see an arrow indicating that &quot;Industries&quot; has child nodes.&lt;/p&gt;
&lt;p&gt;In Part 3 of this series I will continue discussing some template.php magic. Be sure to tune in next time, same Bat Time, same Bat Channel...&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;/Blog/2009/03/13/Theming-Drupal-5-Part-1&quot;&gt;Theming Drupal 5, Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Theming Drupal 5, Part 2&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/Blog/2009/06/01/Theming-Drupal-5-Part-3&quot;&gt;Theming Drupal 5, Part 3&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description>
 <comments>http://www.waycoolwebdesign.com/Blog/2009/03/13/Theming-Drupal-5-Part-2#comments</comments>
 <category domain="http://www.waycoolwebdesign.com/Blog/CMS">CMS</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Content-Management">Content Management</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Drupal">Drupal</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/HTML-CSS">HTML &amp;amp; CSS</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Web-Site-Design">Web Site Design</category>
 <pubDate>Sat, 14 Mar 2009 01:35:10 -0400</pubDate>
 <dc:creator>John</dc:creator>
 <guid isPermaLink="false">202 at http://www.waycoolwebdesign.com</guid>
</item>
<item>
 <title>Theming Drupal 5.x, or, How To Thumb-Wrestle Drupal 5 Into Submission and Lay It Low At Your Mighty Feet, Part 1</title>
 <link>http://www.waycoolwebdesign.com/Blog/2009/03/13/Theming-Drupal-5-Part-1</link>
 <description>&lt;p&gt;This will be as short and sweet as I can make it while covering the entire theme development from concept to launch, with occasional pitstops for my bad humour... Whew, what an undertaking!&lt;/p&gt;&lt;h2&gt;Web Design, The First Step to Theming Drupal &lt;/h2&gt;
&lt;a href=&quot;/files/pet-fiesta-guides1.jpg&quot; target=&quot;_blank&quot; alt=&quot;Opens a new window&quot;&gt;&lt;img class=&quot;type1&quot; src=&quot;/files/pet-fiesta-guides2.jpg&quot; alt=&quot;Example of using Photoshop guides in a design&quot; /&gt;&lt;/a&gt;
&lt;p&gt;Start with a design in Photoshop. Stop using Illustrator to design web sites. Stop using Fireworks or ImageReady to cut them. For goodness&#039;s sake, if you&#039;re a designer, then be one for real. Use Photoshop. Use vector shapes and guides to cleanly define areas using a grid to setup the design. It doesn&#039;t have to be perfect but if you&#039;re making your own design then it should at least be good, otherwise you may as well go grab a free theme somewhere and save yourself some time.&lt;/p&gt;&lt;p&gt;Do not use images for navigation unless you are prepared to constantly edit them yourself, meaning if this job is for a client, get off your designer&#039;s high horse and use text for navigation. Its irresponsible to use images for nav when YOU won&#039;t have to maintain it, just because you think it looks pretty. Keep the client in mind. Use text.&lt;/p&gt;
&lt;h2&gt;Coding Your Drupal Theme &lt;/h2&gt;
&lt;div class=&quot;google_ad1&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-2938344934790216&quot;;
/* 200x200 for Blog, created 3/11/09 */
google_ad_slot = &quot;6360764911&quot;;
google_ad_width = 200;
google_ad_height = 200;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;p&gt;Code a HTML/CSS tableless template by hand. Do not use an app to export it. Just look at the darn design and visualize the rows and columns you&#039;ll need. A header is usually one row (div set), the nav might be another, the body content another, and then a footer, generally speaking. Within the rows are columns, each column is another div set. For example often the body content area has columns, in the case of this site there are 3; the left column for navigation/quotes, the center for body content, and the right column for callouts. You will define a width for these columns, then float them all left and then clear the floats afterward. If all this is mundane to you and you want a new challenge try coding so that your &lt;a href=&quot;/Blog/2009/03/11/Improve-Search-Engine-Optimization-SEO-Coding-Page-Content-Top-Your-HTML&quot;&gt;page content is at the top of your HTML&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&#039;ve really plowed through the design and code portion of creating a theme because the main topic of this post is the Drupal aspect, theming Drupal, and not really the creation of a design/HTML template. If you need more in depth info on those aspects I may have other articles later, or again, save yourself some trouble and pick up a free theme somewhere.&lt;/p&gt;
&lt;p&gt;Once you have the HTML template code complete (with some dummy content in place) or have purchased a plain HTML theme elsewhere, and have tested it in FireFox, IE6 (hopefully dead soon), IE7 and Safari, you&#039;ll need to create your own theme folder. To start it may be easier to just duplicate the garland theme, then rename the folder whatever you want (hint: if you plan to have spaces in the name it is best to use underscores instead). For now let&#039;s assume your folder has been renamed &quot;my_theme&quot;. Inside /themes/my_theme/page.tpl.php is where most of the work goes into creating a theme. If you don&#039;t know what the page.tpl.php file is, again, check into an existing Drupal theme such as Garland to see an example of the file.&lt;/p&gt;
&lt;h2&gt;The Drupal Guts Switcheroo &lt;/h2&gt;&lt;p&gt;Next is swapping out your pieces of code for Drupal&#039;s guts. When I am creating a new theme I usually paste the entire new HTML code ahead of the old code of an existing page.tpl.php file. This makes the copying/pasting of the Drupal guts easier... Be careful to copy/paste all the region variables you&#039;ll need to ensure a smooth transition. If you see PHP in the old theme&#039;s code, it probably belongs in the new theme but you will have to learn over time exactly what you can add/keep/discard.&lt;/p&gt;
&lt;div class=&quot;google_ad1&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-2938344934790216&quot;;
/* 200x200 for Blog, created 3/11/09 */
google_ad_slot = &quot;6360764911&quot;;
google_ad_width = 200;
google_ad_height = 200;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;p&gt;I&#039;m not going through the whole list of region swaps you&#039;ll need to make but an example would be, cutting out the body content area of your HTML code and adding Drupal&#039;s &amp;lt;?php print $content ?&amp;gt; snippet. Another example is, deleting the code for what should be the left column content of your HTML template then inserting Drupal&#039;s &amp;lt;?php if($sidebar_left) {print $sidebar_left;} ?&amp;gt; region snippet.&lt;/p&gt;&lt;p&gt;When working on this part of the process, you&#039;ll have to consider your client&#039;s needs. Generally for my projects, clients don&#039;t need every bell and whistle. For example how often will a client change their logo? Nearly never is the answer in my case, so I don&#039;t usually use Drupal&#039;s $logo variable. Same with the mission statement ($mission variable) since most of the time designs incorporate the mission statement as a part of the logo. But you be the judge of what works best for you.&lt;/p&gt;
&lt;h2&gt;More In-Depth Drupal Theming Tips&lt;/h2&gt;&lt;p&gt;We&#039;ve covered the basics. Now it&#039;s time for the nitty-gritty...&lt;/p&gt;&lt;p&gt;Your theme should be well inside the ballpark now, with Drupal trying to generate its Drupally system bits in the right places, however now the devil is in the details. At this point Drupal will be inserting content in the right place in your theme, the $content variable, and even though it may be trying to insert left-column stuff in the $sidebar_left region variable, you may not have told Drupal what it is exactly that you want in that area. This is where blocks come into play.&lt;/p&gt;
&lt;p&gt;In &quot;administer &amp;gt; site building &amp;gt; blocks&quot; you will see any themes that are registering with Drupal, such as garland and minelli. As long as your new theme has been enabled in &quot;administer &amp;gt; site building &amp;gt; themes&quot; you should see it in the blocks area. Clicking the name of your theme will allow you to instruct Drupal what content should appear in which region (the variables you just added to your new theme) Now you can control what shows in the various regions of your page, the header, left and right columns, and footer. For example if you need a copyright statement in the footer, as long as you have swapped the $footer_message into your new theme, all you need to do is add a new block called, say, &quot;my copyright&quot;, add the copyright statement into this new block, then in the &quot;my_theme&quot; theme tell this new block to reside in the footer by choosing &quot;footer&quot; from the dropdown.&lt;/p&gt;
&lt;p&gt;This ia a pretty simple way to get a quick site created in Drupal. The thing is... people always want to customize. They want this and that coded exactly this and that way. This leads to the need for more control over what Drupal is exporting and where it is exporting it.&lt;/p&gt;
&lt;p&gt;For example, what if we need our main navigation to render a bit differently, say with a span tag inside the anchor, or a div surrounding each ul for special effects? What if we are creating a site for ourselves and we DO want to use images in the navigation because we know we can update the images ourselves if needed? What if we want a view to sometimes render items as a list that DOES use a proper list format (unordered or ordered) and in other cases we want a list of items that are NOT inside a list structure?&lt;/p&gt;&lt;p&gt;All these questions and more might be answered in Part 2, or possibly Part 3, or the way I&#039;m rambling it could be in Part 12, after this commercial break! &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Theming Drupal 5, Part 1&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/Blog/2009/03/13/Theming-Drupal-5-Part-2&quot;&gt;Theming Drupal 5, Part 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/Blog/2009/06/01/Theming-Drupal-5-Part-3&quot;&gt;Theming Drupal 5, Part 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
 <comments>http://www.waycoolwebdesign.com/Blog/2009/03/13/Theming-Drupal-5-Part-1#comments</comments>
 <category domain="http://www.waycoolwebdesign.com/Blog/CMS">CMS</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Content-Management">Content Management</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Drupal">Drupal</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/HTML-CSS">HTML &amp;amp; CSS</category>
 <category domain="http://www.waycoolwebdesign.com/Blog/Web-Site-Design">Web Site Design</category>
 <pubDate>Fri, 13 Mar 2009 20:19:01 -0400</pubDate>
 <dc:creator>John</dc:creator>
 <guid isPermaLink="false">201 at http://www.waycoolwebdesign.com</guid>
</item>
</channel>
</rss>

