Category Archives: Drupal

Why kittens are professional….

Standard

As a disclaimer, you might want to bounce this piece of advice off a more experienced colleague before letting it out into the wild.

Yes, this is another FITYMI post.  If you are getting into Drupal, you’ve probably needed to create test accounts, test images, test posts, etc.  Usually, of course, the Devel module will be your best friend for these testing purposes.  Devel can create (and delete, thank goodness) tons of test info and provide the information that lets you know what’s doing what in your database.*

But what if you just need one or two ongoing users, posts, pictures, etc, and don’t want to go through the hassle of using Devel?  Or, what if you’re on a staging site, and opening the Devel can of whoopass is just. too. much. ?  That’s where placekitten comes in!

Yes, kittens are now professional.  Well, professionalish.   Basically, you shouldn’t usually use your own name and likeness in a test site, and no one is going to mistake a kitten picture for actual site content (unless the site is about pets, and then I can’t help you).  No one (almost) will mistake the name Cat Kittenstein for an actual user.  Instead, I’ve found that clients were pretty pleased to see that testing was happening, and tickled that cute kittens suddenly became part of their not-so-voluntary website committee work.

So have at it!  PlaceKitten has pictures of kittens in all sizes, shapes, and even b/w.  One thing PlaceKitten can’t help you with, though, is fake names.  So I’ve created a starter list here:

  • Cat Katze
  • Mia Meow
  • Gatito McKitten
  • Felina Mao
  • Kitty Chaton

 

In all seriousness, though, do run the use of any fake names, accounts, posts, etc, by the responsible party.  And then proceed with caution (and fun!).

*I realize that description is kinda vague.  But there are other great posts (y incluso un video en español, yay!) on the subject, not to mention the actual Devel project page.

A couple of modules that will make you look like a badass

Standard

Working with seasoned developers means I learn a lot, and it means I feel like a complete noob pretty often.  Buuut, there are those times when I’m able to whip something out that makes even a seasoned pro a little impressed.  While I definitely advocate trying to use core as much as possible, here are two modules that have recently helped me FITYMI (fake it till you make it):

  1. Double Field – Yes, this module is really simple.  It does just what it says.  It literally just combines two fields into one.  The choices about which fields you can combine are pretty limited, but they are pretty powerful.  I have used it for phone number extensions (though there’s probably a better way to do this), and Q&A type use cases.  In some ways, it’s a module I’m never sure when I’ll need or how often I’ll need, but I when it’s there, it’s bound to come to the rescue at least once.
  2. Conditional Fields – This module is also pretty obvious. Still, it’s an excellent thing to have in your toolkit.  It’s perfect for use cases like “Other” options, etc.  I can’t count the number of times I’ve used this one now.  No matter what project you’re working on, there’s always a “But what if I don’t wanna…?” waiting to happen.

I won’t go into just how knowing about these fields made me look like a badass.  Suffice to say, I’m lucky I work with people who are willing to go, “Oh, right! Duh!”  And I think that’s pretty common in the Drupal community. 🙂

Did you already know about these two modules?  If so, tell me about your top two FITYMI modules!

D7: Map blog feeds to Organic Groups (OG)

Standard

In a previous post, I proposed the idea that asking questions on stackexchange and stackoverflow is a good idea for Faking It Till You Make It (FITYMI).  The flip side of that is, of course, answering questions.  Since I recently answered a Drupal 7 question on  Stack Overflow, I thought I’d share it here.

FITYMI tip: Answer questions on stackoverflow and stackexchange

 

Question:

(I’m paraphrasing here) How do you map Feeds to Organic Groups? Say you have Organic Groups (OG) on your Drupal 7 site, and you want to give each of them their own blog(s).  Feeds is great, but it doesn’t allow you to map a reference group (patch time!).

Answer:

What you do, essentially, is assign all incoming feeds a default value, and then match that value to the one you put in your content type.  Having the same field and field value shared among the feed, the content type, and the OG links them together, and makes it possible for you to relate them in Views, etc.  I’ll admit this method is a little bit scrappy (as in, not exactly a hack, but not super elegant), but it definitely works!**

The Details:

1. Install both Feeds and Feeds Tamper.
2. Create a content type to receive the feed entries.
*I’ll call this new content type “Blog post”
3. Add a text field to BOTH the new content type AND to your OG form.
*I’ll call this field “Feed nickname”
4. Fill in the field with the appropriate feed nickname on your OG form.
*I suggest making this a one-word nickname
5. Under Structure>Feeds Importers>Edit>Node processor settings, select “Blog post” as the chosen bundle to receive the feed. Click save.
6. Under Structure>Feeds Importers>Edit>Node processor mapping, add a new mapping with “Blank source” as the source and “Feed nickname” as the target. Click save.
7. Under Structure>Feeds Importers>Tamper, scroll to the section “Blank source-> Feed nickname” and click “add plugin.”
8. Choose the plugin called “Set default value” and set the default value to your chosen feed nickname. Click save and make sure the plugin is enabled. Click save at the bottom of the tamper form.
9. Add the feed importer as usual, under yoursite.org/import

Whew, that was long-winded.  Buuut, I hope it helps someone!  It took me hours (multiple of them! and many cups of coffee!).  Hopefully it will only take you 1 (or less! yay!).

**Notes: I’m assuming you’re working with a Drupal 7 site.  I’m assuming you do know how to use Feeds, but that the OG component is what’s confusing you.  (For basic instructions on installing and using Feeds, try LevelUpTuts. They have a good series of videos on Feeds of all kinds.) I’m assuming that you don’t want to do any coding.  I’m assuming that you’re importing an RSS feed (though it should play well with other types of feeds, too).  Also, I haven’t tried it, but I’m assuming this process would work for assigning blogs to individual users, too.  You’d just put the Feed nickname field on the user form.  Let me know if you try it!

No, I will not date you! Add only the time to a calendar view in Drupal.

Standard

Note: This is for a Drupal 7 install.

This is a wholly random post, and will (probably) not be followed up by anything useful. Basically, I’m posting this both so I don’t forget how I did it, and so it might help someone else.

Context:  I was making an event calendar in views, to be used as a block elsewhere on my site.  I chose two fields to show on the event calendar – Title and Date.  The Title field was all good.  The Date field, however contains two parts – the event’s date, and the event’s time.  The time I obviously needed.  The date, however, was already implied, since, ya know, this is a calendar.

Question:  How do I force my date field to show just the time?

Answer:  Create a new date format!

It’s a pretty easy, totally point n’ click, and no coding needed!

1)  Make a new date format.

2)  Make a new date type.

  • Navigate back to the Date  and time page (www.yoursitename.com/admin/config/regional/date-time) and click Add date type.
  • Give it a name – preferably a self-explanatory name.
  • Then, under the Date Format dropdown menu, choose the date format you just created above.
  • Click the Add date type button beneath.  This will take you back (yet again!) to the Date and time page.
  • Click Save configuration.

3)  Give that views thing another shot.

  • Head back over to your view, refresh (save first if you need to!).
  • Try modifying the date field again.  This time, the dropdown menu, Formatter, will have your new format.

4)  Click save.

5) Rejoice.  And maybe get some sleep.