Archive for January 31, 2011

Drupal Learning Journal 14. Nice Menus

A few weeks ago I was involved in moving a Drupal 7 site from a host where D7 was available for users when while it was still in beta to another commercial host, which was one of the first one to offer it, when D7 came out of beta. Unfortunately, lots of features and aspects of the sites got broken with the move. Some of these went down because when the files were copied to the new server their permissions got lost. Others because the tech support of the new host didn’t have enough clues how to migrate a D7 site.

Yet other issues came to surface because the original host had a funky way of handling a few features, e.g. the theming/CSS customization was handy, but not standard. I think the fact that our expandable menus were no longer expanding at the new host was due to a combination of permission and overcustomized CSS issues. I am not sure, because I never managed to figure out the real reason, we eventually asked a Drupal guru to fix it for us.

Before calling in the big gun I tried to fix the menu and realized that it was a custom CSS/javascript code. I was surprised to see that, because I knew of the Nice Menus Drupal module, which is dedicated to do exactly this. Looking into its history I see that its first beta for D7 came out on October 26. I don’t know whether the first version of the site in question was built before or after that date, so maybe it was not available yet back then yet.

I attempted to fix the custom coded version, but my limited knowledge of CSS and Javascript, prevented me from finishing it. So I installed the Nice Menus module and attempted to recreate the menu. I had mixed success. The menu worked, but a, it didn’t exactly follow the look and feel of the original, b, when expanding (down) it pushed down the content of the rest of the page. I tried to use z-index and overflow, but couldn’t overcome the problem. Hence the help of the drupal guru was required.

Meanwhile I started to create my own first D7 site, where I also wanted to use expanding menus. The installation and configuration went without a hitch, so the menus worked out of the box. The only problem was that it was using the default CSS that came with the module and not my theme’s. I am using the MAYO (“MAke Your Own”) theme with one of the preset color themes and header image. It works great and I will do some customization, when I am ready to market the site. Right now I am still building it.

To cut the description of the troubleshooting process short this is what I had to do to make the Nice Menus using the MAYO’s CSS:

  • Use the “Nice Menu 1″ block,
  • set the “Menu Parent” option  for “Main menu”
  • under the region settings set the “MAYO (default theme)” option for “Menu bar”

BTW: I found the name for the animation feature of nice menus funny: Superfish. It can be set under Home » Administration » Configuration » User interface » Nice menus

Byron….: Using Drupal (2008)

I never reviewed a technology book before that I studied from. All the books I wrote about have been either fiction or non-fiction that I read or studied for my school. But I didn’t have any formal schooling related technology, at least not on the coding level. (We did some basic HTML and XML when I studied for my MLIS, but by the time I got there I knew all that.) So when I sat down to write a “review” about Using Drupal* I realized that I have to use different criteria than usual for my reflections.

When judging a tech textbook first and foremost I should assess what I have managed to learn from it. The answer in this case is a tremendous amount. Right now though, I don’t know how lasting my learning will be. That will depend on how much work I will be doing in Drupal and how much I retained in the first round of studying. As it was a library book, i.e. I have to give it back tomorrow, I tried to take as much note as I could. Nowadays I try to put every informational on the web, except confidential pieces, so you can find my notes on my blog here: chapter 2, 3, 4, 5, 6, 7, 8, 9, 10, and 11.

I think that studying the book was very useful for me. I wasn’t a total novice in using Drupal 6, so I can’t say I learned everything I know from it. But I can say that my knowledge feels much more grounded now. And there was plenty of new information, tips, trick, modules for me in there. I enjoyed the clear style of the writing, the detailed explanations, the description of the processes and the screenshot that helped me along the way. My only regret was that halfway through the book the site accompanying the book went down and I still cannot reach it. I hope usingdrupal.com will come back, so I could reuse the code snippets from the book, without having to type them in.

The book had a lot of authors, most of them are members of the team at Lullabot. Let me spell out all of their names, that I  couldn’t do in the title of this post (hence the ellipsis there): Angela Byron, Addison Berry, Nathan Haug, Jeff Eaton, James Walker, Jeff Robbins. Thanks to all them making for putting together an excellent resource. Too bad that by the time I was done with the book, that covers Drupal 6 , Drupal 7 came out and now I can start the process (almost) all over again.

Here is the official descrption of what Drupal is: “a free software package that allows anyone to easily publish, manage and organize a wide variety of content on a website.”

The book @ Amazon

Drupal Learning Journal 13. “Using Drupal” – Chapter 11 – Theming

Chapter 11 of Using Drupal, is ab out theming which assumes working knowledge of PHP and CSS. I have the former, but not the latter (yet). This the time, when I wish I could keep this library book longer. But somebody has it on reserve, so I had to relinquish it in 3 days. As I didn’t have time to play with what I learned form this chapter and because this is the chapter that contained the most newish information I am afraid I may forget. Nevertheless here are the notes that may or may not trigger my memory later when needed.

  • List of variable available for templates is at: http://drupal.org/phptemplate (Page 397)
  • The Devel module has a “Theme Developer” segment. (Page 398) (D7 versions exists.
  • The code example on page 399 shows where the breadcrumb is in the page.tpl.php file and how to move it.
  • The code example on page 401 explains where the the “submitted by” and “taxonomy” info is and how to move it on the node.tpl.php or node-story.tpl.php files.
  • To understand how to override variables and functions in the theme’s template.php file read this page. (page 405)
  • All variable go through the preprocess function. One can crate a mytheme_preprocess_page function. Here is the info on how to override them. (page 406/7)
  • “Snippets” are bits and pieces of Drupal code that people have found useful and wish to share with the community. They are available here. (page 411)
  • Theme snippets are here and mini modules for D6 are here.

Drupal Learning Journal 12. “Using Drupal” – Chapter 10 – Online Store

I finally reached Chapter 10 of Using Drupal, where I can learn some of the secrets of how to set up an e-commerce site/online store, with the help Ubercart. I started to work on a site a few months ago, but had to abandoned. Hopefully after reading this chapter I can go back to it. I will be taking more notes as usual, so I could go back checking it even after I gave back the book to the library.

Ubercart (UC) modules (page 342):

  • Cart – including checkout
  • Conditional actions – for taxes and shipping
  • Order – ordering, invoicing, hooks for fulfillment
  • Product – available items
  • Store – management interface
  • (optional) Core (page 344)
    - Attribute – product variation
    - Catalog – categorization
    - File Downloads – digital products
    - Notify – email to customers
    - Payment – framework for Test Gateway, Payment Method Pack, recurring Payments, Credit Card
    - Report – sales reports
    - Roles – turning customers to members
    - Shipping – calculating shipping costs, generating labels, creating tracking numbers
    - Shipping Quotes
    - Taxes – rule specific
  • Extra (page 348)
    - Cart Links – to construct URLs that will add certain quantities of specified products – to be use don external sites for “buy now” links.
    - Importer – does export/import of UC data
    - Product Kit – grouping products to be sold together
    - Repeater – Update product info on remote UC stores
    - Stock – tracking and managing stock levels

Mixed tips and reminders

  • Each product class has its own specific properties; they need to inherit the base product field (page 354)
  • Check for “Vocabulary Catalog has been identified as the Ubercart catalog” at Store administration or do it by hand at store admin -> config -> catalog
  • “Continue shopping link URL” can be set (for “catalog”) at Admin -> Store admin -> Config -> Cart setting
  • Shopping Cart block (e.g. for top left)  can be set up at …blocks

Payment/encryption (page 369)

  1. Add the test gateway payment method at Admin -> Store admin -> Config -> Payment setting -> Payment methods
  2. Create “keys” directory for encrpted CC datae that is not web accessible, e.g. /home/username/keys
  3. Make it temporarily writable (a+w)
  4. Expand the “credit card settings” fieldsate and enter the path for “Credit number encryption key filepath”
  5. In the checkout workflow” section ensure that “Attempt to process cc payments at checkout” is checked
  6. Enter additional info at “Check settings”
  7. reset keys permission to a-w

Permissions (page 375):

  • “view cc details”: OK for editor
  • “view cc numbers” (last four): only for admins
  • “delete any order”: for admin only: it can remove already completed  orders

The Secure Pages module will “redirect the required pages to a SSL version of the page.” (Page 377) Drupal 7 version is in dev.

Drupal Learning Journal 11. “Using Drupal” – Chapter 9 – Event management

Chapter 9 of Using Drupal is about event management. Instead of using the Event module they authors went for the using CCK with Date and Calendar modules (both under active development for Drupal 7). Here are my learning points from the chapter:

  • The Signup module is designed for tracking event attendance. (Page 313) I found no mention of a possible Drupal 7 version.
  • Process (Page 314-328):
    1. Create a new “Event” content type,
    2. Understand date (timezones, field types, widgets and settings)
    3. Add configured  Date/Time field to the Event content type.
    4. Build an “upcoming events” view
  • The Calendar module provides a new view type (Page 329)
  • Use the Flag module for attendance, by creating a new “attendance” flag. (Page 333)
  • Create an “Attendees” view. (Page 334)
  • Additional useful ideas (Page 336)
    - The Countdown module adds a block that shows the time left until an event. (Drupal 7 version is in alpha.)
    - Create Flag actions (part of the Flag module) to send emails, unpublish/delete nodes.
    - The Location and GMap modules et people use a Google map to select the location for each event. (Both are in dev for Drupal 7)

Drupal Learning Journal 10. “Using Drupal” – Chapter 8 – Multilingual site

Chapter 8 of Using Drupal starts of with a few definition. Internationalization, abbreviated as i18n, “is the underlying structure that allows software to be adapted to different languages.” Localization, abbreviated as l10n, “the process of actually translating the software for use by a specific locale.” (page 269)

  • The Locale module (pat of core) can take care of the translation of most, but not all user interface text. (page 271) The rest will be done with the i18n module. (page 271) It is in alpha for Drupal 7
  • The Content Translation module (part of core) can take care of the translation of most, but not all user-generated content. It supports RTL (right-to-left) languages. (Page 272)
  • You can download .po files, containing strings of texts translated to a particular language from here. (Page 273)
  • Interface translation setup is at: Administer->Site building->Translate interface (Page 273)
  • Language switching requires setting up the language negotiating options and language switcher block (page 274/5)
  • Each translation of a node is a new node, that Drupal connects. (page 277)
  • Installing a translation (page 278):
    1. Download a translation from here.
    2. Uncompress to root
    3. Enable the Locale module
    4. Allow admin to administer languages and translate interface in permissions
    5. Add language in Site configuration->Language
    6. Select the language to add
    7. Files will be imported to Drupal
  • Setting up translatable content: set it under the workflow area of the specific Content type, e.g. Book. (page 284) Set permission for authenticated user too.
  • Translating the interface:
    1. Site building->Translate interface
    2. Search for “multilingual support” in the search tab
    3. Edit, if necessary, what the interface snippets the search found
  • The Localization Client module “helps you fix translations on your site as you see the issues” (page 289) Drupal 7 version is in beta.
  • The Internationalization module gives you Taxonomy translation  Multilingual variables, Multilingual blocks, Language selection (page 294) Drupal 7 version is in alpha.
  • Site-wide variables needs translation too:
    1. Type into sites/default/settings.php
    $conf[i18n_variable'] = array (
    ‘site_name’,
    );
    2. Set its permissions to 444
    3. At Site configuration ->Site information you will see the site name being a “multilingual variable”
    4. Switch to another language, change the site name and save config.
  • Additional useful modules (page 308)
    - The Language icons module provides icons for language links. (7 in alpha)
    - The Translation Overview module provides a table listing the site’s nodes and showing what’s been translated into each language. (7 in dev)
    - The Auto Timezone module automatically updates the time zone setting on users’ accounts. (6 in dev)

Drupal Learning Journal 9. “Using Drupal” – Chapter 7 – Photo Gallery

Chapter 7 of Using Drupal explains the details of building a Photo Gallery. As mentioned in the previous post Drupal 7 has pretty good image handling in the core, so some of the things I learned here are immediately obsolete. (Except that there are a lot of Drupal 6 sites out there.)

  • I used ImageField module in the past, without really knowing that this is the one that allows uploading images to CCK. (page 233) It is part of Drupal 7 core now!
  • The ImageCache module automatically resizes images and cache them for later use. (page 233) It is part of Drupal 7 core now!
  • I liked the idea of using taxonomy’s tags as the main organizing tool for the photo gallery. (page 241)
  • Knowing the
    print imagecache_create_url(‘my_preset’, $path) and the
    print theme_imagecache(‘imagecache’, ‘my_preset’, $path, $alt, $tite, $attribution)
    lines of code will come handy when I will understand how to use them after reading chapter 11. For now I just make a note that this is what I will need to use for displaying an image. (page 251)
  • The Custom Pagers module “allows administrators to define context-sensitive previous/next pagers for any node type.” You need to use the [term] in the title and the [term-id] token in the arguments area of the settings to create the previous/next buttons. (page 265) Version for Drupal 6 is still in beta. There is a discussion about a Drupal 7 version, but currently it is incomplete.
  • Additional, potentially helpful modules are (page 267):
    - The Community tags module allows members of the community to tag content, and tracks who tagged what and when. (Drupal 6 is in beta and there is no Drupal 7 version.)
    - The Tagadelic module allows the creation of tag clouds. (A preliminary Drupal 7 exists.)
    - The Taxonomy Redirect module allows the administrator to change the destination of Taxonomy Term links. (No reply yet for asking about Drupal 7 version.)

As you may have noticed in the last few entries in this series I rarely write down any specific configuration tips. That’s because as I read the book they seem so straightforward. No need to do so as that’s the kind of thing I believe I will be able to follow/figure out as I work through the usage of these modules when I need them.

Drupal Learning Journal 8. Image styles in Drupal 7

My next entry in this series will be about my lessons learned from Using Drupal’s chapter 7, which is about building a photo gallery. Meanwhile my dilemma of whether to focus on Drupal 6 or 7 came to the forefront, because at the same time I just watched a video that shows how much better Drupal 7′s image handling is. The video embedded below is a tutorial from Lynda. The video showed that each image can have several “styles” (including custom defined) depending on where and how to display the images.

E.g. for my book related sites I could upload the covers as big images and display them as such on the individual pages in big size, as small thumbnails on the listing pages and create a gallery with nothing else than the medium sized covers. Besides resizing, the “styles” can also include rotation, desaturation, rescaling and cropping. You can even set the background color for the rotated images. I think these are pretty powerful features to be handled automatically based on one single uploaded image.

Drupal Learning Journal 7. “Using Drupal” – Chapter 6 – Workflow

The authors of Using Drupal explained how Workflows can be managed in Drupal. Just like with the wiki, I don’t see any immediate practical use of this feature, as none of the projects I am workig on (or thinking about doing) requiers it. But it is certainly a legitimate need for many websites that are managed by team to have a publishing workflow in place to nesure that only quality content makes it to the public site. Here is what I learned.

  • The Workflow module allows administrators to define custom publishing states for content, e.g. in review, ready for publication. (page 209) It doesn’t have a Drupal 7 version, although there are some conversations about it. Maestro is a workflow module that exists for Drupal 7, but not very widespread yet.
  • The Views Bulk Operations module allows “bulk operations to be executed on the nodes displayed by a view. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied on the selected nodes.” (page 209) Drupal 7 version is under development. (This will be useful for the e-commerce site I am building, to update products in bulk.)
  • The Flag module allows “you to choose actions that should run when very specific things occur, e.g. a node being flagged more than five times by different users. More flexible and customizable than the Trigger module.” (page 211) Drupal 7 version is in beta. Trigger is part of core.
  • The Rules module is “designed to duplicate the functionality of the Trigger module, with the addition of conditional rules that are checked before any actions fire.” (page 211) Drupal 7 version is in alpha.
  • The Workspace module “gives each user his own personal page that lists the nodes and comments and files he’s posted to the site.” (page 225) No Drupal 7 version and I didn’t find any plans for it either. :-(
  • Additional useful modules are listed on page 230:
    Workflow fields allowing CCK node fields to be made invisible or read-only depending on the current workflow state. (No drupal 7 version.)
    - The functionality of the abandoned Workflow Graph module, mentioned in the book has been  incorporated into Graphviz Filter module, that creates “graphs dynamically from within Drupal nodes.”(No drupal 7 version.)
    - The Nodequeue module “allows users to collect nodes in an arbitrarily ordered list. The order in the list can be used for a any purpose.” (Version for Drupal 7 is in alpha.)

Drupal Learning Journal 6. “Using Drupal” – Chapter 5 – Wiki

Chapter 5 of Using Drupal was about creating a Wiki with Drupal. I don’t foresee right now that I would do that for any of my own sites, but you never know what a client might ask, so it’s good to know about it. The book’s authors’ assessment is that there was not a single complete wiki package at the time of writing, but it is possible to create a functioning wiki in drupal. As I can search the wiki related modules any time at Drupal.org, I will not bother right now assessing whether and how this situation changed by now. Instead, I will focus on other bits of useful information I gathered from this chapter.

  • The Freelinking module implements a filter for the easier creation of HTML links to other pages in the site. (page 184) It doesn’t have a Drupal 7 version.
  • To remove the author information display from wiki pages go to Administer->Site Building-Themese-Configure tab -> “Display post information” section -> Wiki page box. (page 187)
  • I have been using Tokens, because they were required for modules I wanted, but didn’t read up on them so far. Page 195 explains well what a token is. Here is my paraphrasing. Tokens are placeholders, like [yyyy] is for four digit year. The Tokens module creates a central repository of them. Tokens provide functionality to other modules, invisible to users. The basic version of it is now part of Drupal 7, but not all, so it is getting further developed. In beta now.
  • Link rot is that when you remove or change the URL of a page in your site and other sites are still pointing to it (and getting 404s). Two ways to fight rot. 1. creating an alias from the old address to the new, but Google may penalize you for this. 2. Use Path Redirect module, to create a proper redirection with Pathauto. This is the recommended method. (page 196) For Drupal 7 the module has been renamed to Redirect and right now has a beta version.
  • The Diff module “allows pretty viewing of all added/changed/deleted words between revisions” of nodes. (page 201). Drupal 7 version is in beta.
  • Additional useful wiki related modules are listed on page 207:
    - The PEAR Wiki Filter allows several kinds of markup syntaxes, between its version for Drupal 6 is in beta only.
    - The Table of Contents module “generates a list of select header tags in a box. The links point to the anchors so users can quickly access each section of your documents.” They are looking for co-maintainer for Drupal 7.
    - The Talk module “removes comments from the node page and puts them on a separate tab.” Drupal 7 version was pledged but not done yet.
    - The View’s module‘s Backlinks feature gives a list of all the other pages on the site that are referring to the page you are on. Views is in alpha for Drupal 7.