Category Archives: Drupal

Drupal Learning Journal 17. Learning OG

Fear is a bad advisor. I have been afraid of starting to work with Organic Groups (OG), because I’ve heard that it is so complex. Before I go further let me share OG’s official description : “[It is a Drupal module that enables] users to create and manage their own ‘groups’. Each group can have subscribers, and maintains a group home page where subscribers communicate amongst themselves.”

My schedule, including my learning schedule was so full the last few weeks that I was afraid of jumping into learning OG, before I knew I could do it with full attention. I was also afraid of OG, because my first encounter with it was at a site where when  my colleagues attempted to install and enable it it messed up the site in some major ways. And you know how first impressions have resulting effects. I hope I can overcome them though.

Finally earlier this week I started the process of learning OG with watching a number of tutorial and informational videos. I did that first because in the past I found that I can learn quite well Drupal related techniques from videos. In hindsight I realize that it was not the best approach in this case. I should have started with how I am doing with less complex modules and projects:

  1. Read the manual/instructions, then
  2. Start playing with it and gain hands on experience.

There are two reasons why I think the “videos first” approach was not ideal for this process:

  1. I didn’t find the ideal video for me that would have shown how to set up OG 7 from beginning to end. Most of them what I found was about the Drupal 6 version and I learned only rather later in the process of watching them that Drupal 7 version is significantly different from Drupal 6.
  2. OG 7’s ReadMe file is so  clear and short that having read that first, the videos would have seen less daunting.

Nevertheless here are the list of videos I watched, with my comments. Only the first two is about/for Drupal 7.

  1. I started with one that our Drupal guru, who fixed what went wrong with out OG installation, recommended. The problem was that I had no idea what I was watching. The title sounded promising: “Organic groups for Drupal 7“, so did  the description of the video, “From the session in Drupalcon Copenhagen, 2010 given by Amitai (Amitaibu) Burstein.” As I learned later Amitaibu is the maintainer of OG, so he is the authority on it. This video is a really funny 19 minutes introduction into the possibilities of what you would be able to do with OG for D7. At the time the presentation was given OG for D7 was not ready yet, so Amitaibu could not demo it. Instead he used his knowledge of world politics and lots of humor about fictional scenarios for groups and assured the audience that for all of the OG will be able to satisfy all of those imagined user requirements. It was good to learn about all those possibilities, but not the ideal introduction for an OG beginner like me.
  2. The “Organic Groups 7” video, that you can watch or download from here, is 44 minutes long and is a presentation by Amitai Burstein. (I recommend downloading he QuickTime version as that has the highest resolution.) With a little digging I found out that it is from February 5 this year. Amitaibu demoed OG7, explained some of the thinking behind the rewrite and compared it to OG6. I will need to rewatch it a few more times, once i started playing with OG, because he gives a lot of examples on how to do things. Excellent resource, even if in the QA part I often didn’t hear the questions from the audience.
  3. This 4 minutes long video, titled “Creating an organic group“, from March 2010 steps you through the process of creating a new group. It is for for OG for D6. It is a fine video with three and a half caveats: 1, it assumes OG is already installed. 2, the resolution of the video is too low and cannot be viewed at a higher one to really see what’s going on, 3 the volume is a bit low (and the half: the presenter’s dialect is occasionally hard for me to understand, but fortunately he spoke slowly enough.)
  4. The title of this 5 minutes long video is quite precise: “How to add a new Organic Group in a standard OG implementation in Drupal” I liked it more than the previous one, because I could watch t in high resolution seemed to go more into the details and because they used a theme for the Drupal installation the site they made the video on was visually more pleasing.
  5. The title of this 8 minute video, “How to use Organic Groups,” should have been appended that it only applies for The Australian Greens. It is a guide from March 2010 for the members (not the developers) of one particular website on how to use the groups they have access to there. To the credit of the person who made the video the title is clear on the video itself, even if not in the text of the YouTube video itself. I wish he would have put a few words of description under the video though.
  6. This 15 minutes long video is from MustardSeed Media, who have a great series of Drupal video podcasts. The good parts: it is free, the presenter covers a lot of territory and the video contains lots of hands on tips. The not so good parts: it  is from July 2009, the presenter talks really fast, he is using Panels in combination with OG and I am not familiar with that yet, he is using lots of theming and retheming in order to accomplish things (i.e. not vie the GUI), they skip basic steps in order to cover only the more challenging aspects of OG6.
  7. Drupal Dojo‘s 18 minutes long screencast shows how the groups.drupal.org was set up with OG and panels. Good show of what could be done in OG5 for a large scale site. Meanwhile it’s good to note that the Dojo site has dozens of god screencasts on all sorts of Drupal topics. even if it hasn’t seen any new one for a while.
  8. DevelopmentSeed‘s blog entry and 13 minutes long video from March 2009 explains how to use in combination with each other three Drupal modules: “Context, Spaces, and Organic Groups“.

The official OG page at Drupal.org links two more videos, but the page they provide a link to moved and I didn’t find on the new site the videos (that based on an assumption of what URL’s “free-videos” section meant) I should have been able to access for free. And I am not ready to sign up for Drupalize.me’s fee based service yet. There are probably more videos out there about OG, but I didn’t find more for free.

Drupal Learning Journal 16. Interests field in profiles

I was asked to make the “interests” field of the user profiles in a Drupal 7 sites pivoting, i.e. a way to enable users to find other users with the same interests. Sounds simple doesn’t it? It wasn’t so.

1. First of all the existing “interests” field contained long sentences that the users filled in. Not exactly easy to “pivot.” OK, we made the decision with the client to have add a new field to the profiles, which would have the list of keywords (interests) that are possible to pivot around.

2. Next decision how to add the new field for these terms? There are two options both had its cons and pros, neither of them are perfect.

A, Add a new field to the account, under “Configuration » Account Settings »Manage fields.” The advantage of this solution is that it allows the new field to be of a “Term reference” type. That means that I can assign a specific Taxonomy to it, e.g. an “Interests” vocabulary to it. This solution would allow free tagging and auto fill, so users could easily add new terms to the list. This also means that each term on the user profile and on the user list page can easily made clickable. Ideal, right? Nope. The problems with this solution are:

  • The location of the new field on the registration page is not standard. On the registration page it would be way under or way above compared to the rest of the fields and even compared to the “Create new account” button. It proably can be moved to the right place, but only by changing the appropriate tpl.php file, not by using the web based UI
  • Same applies to the user profile page. The field created this way would be way below the save button and not under the same tab (in our case “Personal Information”) as the rest of the fields.
  • I don’t exactly recall(, because I went with the other solution), but I think its display was also problematic on the userlist page.

B, Add a new field to the Profile at “Configuration » People » Profiles“. The advantages are clear:

  • Earlier this week I was told by a Drupal guru that the proper way to add fields to the user’s profile is here. He told me this in the context of use trying to make profile fields truly required, i.e. no way for a user to access the site without filling them out. Putting these fields into the other area didn’t make them fully required.
  • The field(s) in the Profile puts them to the standard location and integration with the rest of the profile.There is one major problem with this solution: it doesn’t allow connecting a taxonomy to the new field. My (relevant) options for what kind of filed it can be are checkbox, list selection, free form list. Using  the checkbox option would require me to create a checkbox for every single possible interest: not viable. The list option would allow users to select only one interest: not enough. This left me with the Freeform list. That is fine as long as we regularly synchronize the list and making sure that close variants of the same thing are combined.

3. The next issue is are how to display and link the contents of this new “interests” field on the userlist page. When I started working on this issue the site had a mostly standard Userlist page. It had a few issues on its own:

  • Custom theming was difficult to override/change when developing the list
  • The list was sorted by chronological order of access, putting the user who last signed on to top
  • It was displaying the username. We asked our users to use their full name as username,s but not everybody did, so the list was not as informative as we hoped for.

So I decided the build a new user directory using the “Views” module. The results were mixed.

  • I still have issues with theming in this new directort, but only when I try to display the users’ profile images.
  • The list is sorted alphabetically by name, which makes more sense. I also have more granular access to sorting and paging. E.g. when the bugs in the Views module will be sorted out it will be possible for users to change the default sorting, e.g. sort by countries. Right now there aren’t a lot of users so I left the number of users displayed on a screen unlimited. But when we’ll have much more users I can set that number to anything we want to, e.g. 50 or 100. (and users will be able to page through the userlist by looking at 50/100 at a time and using pagination links to move on.)
  • I can set whatever field I want to be shown on the userlist. (This applies to both kind of userlists, but the lack of theming works better on the new one.)
  • There is a “Members” link in the breadcrumb to go back to the full list when looking at the sublists (e.g. members from a certain country.)

4. The last issue, closely related to the previous one, is how to display and link the content of this new “interests” field on the individual profile pages. Right now, in both directories clicking on the a country or an interest takes you to a page which lists the appropriate users in the old style, standard directory. This is obviously not ideal for the new Views based directory, but I ran out of time on trying to figure out how to create a userlist page just for a people from a  certain country or people interested in certain topics. I strongly believe that the Views based directory is better, but without fixing this last detail (and the theming) we may not be able to make it work.

As I ran out of steam and ideas I called in my colleague to help and curious how he will solve the above.

Drupal Learning Journal 15. Panels

Last week a client asked me to split vertically the first, sticky entry on a Drupal site for logged in users and put replace the right side with a nature image. My immediate reply was that I don’t know how to do that. (So, instead of creating a new block for the image I just placed the image straight into the right side of the existing entry. The effect is almost the same: an image appeared where the client wanted it.)

Meanwhile at the back of my mind I was aware that this is exactly what the minds of Drupal contributors created “Panels” for. Here is the current official description of what this module can do for you,

The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

On the same day I also reached chapter 15   in my “Beginning Drupal 7” book, the one that is dedicated to Panels. Theoretically I should be able to do Panels, now, because based on the book’s description it seems logical and as simple as possible. However I know that it is complex enough that for my first try should not happen on a live client site. Furthermore, I have this unchecked assumption that doing panels for the front page and noly for one set of users (logged in) is not the simplest Panels setup. I cannot even check the validity of the assumption, before I learn more about Panels. Maybe I should do something simpler first. I have something in my mind, just need to find the time to play with it. So for now I am just putting this post up as a reminder to learn Panels. Here are some resources to do that:

BTW. Panels is in alpha for Drupal 7 and right now has 22 active bug reports

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.