Click here to hide this ad.

drupal

geerlingguy

One requirement of the Archdiocese of St. Louis' website is that group administrators are able to publish and unpublish the content inside their groups, and they should also be able to schedule posts for automated publishing and unpublishing at a later time.

To do this, I used the following modules:

After enabling these modules, I spent a while in the Permissions page, and also created a new user role, "administer nodes." Ironically, I didn't assign the 'administer nodes' permission to this role, because doing so causes a huge mess ('administer nodes' gives waaay too much power to anyone except the site admin—it's best to leave that beast unchecked in most cases).

Scheduling and Publishing options inside a group

For the 'administer nodes' role, I checked the box next to 'schedule (un)publishing of nodes', which allows users with this role to schedule the publish/unpublish time of a given node. I also checked boxes next to 'publish <content type>' and 'unpublish <content type>' for each of the content types I wanted users to be able to publish or unpublish (these permissions are under the "publishcontent module" permissions section).

Then I went into the OG User Roles module's configuration page (at admin/og/og_user_roles), and checked the box to allow the 'administer nodes' role to be set per group, and also set that as the default role to be added to any user in a group that is made an admin of that group.

The OG User Roles module basically assigns all the permissions you assign to a given role within a user's group only. So you can give some permissions that you'd be very cautious giving out otherwise, because those permissions only affect the user's group, rather than all sections of the website. (However, there are still some permissions that can wreak havoc on your access control, like 'administer nodes'—always test!).

Now, users can schedule content to be posted whenever they'd like, and they can publish or unpublish any content inside their own group(s)!

geerlingguy

New Comment form - Drupal - More user-friendly

Put this in one of your theme's stylesheets - it'll change a clunky, large, and unweildy comment form into a more compact and user-friendly form:

Continue reading...
geerlingguy

I have been hitting my head against a wall for a few weeks now, trying to get a few different Views-created pages to appear as if they were normal pages inside an Organic Group (meaning they would appear inside og-menu-enabled menus for that particular group, and group blocks would also appear on the pages.

After reading up on the thread "Organic Groups and Views 2", I found that I could use an argument to help solve my dilemma. Here's how I set up an argument for a particular view:

On the page display (I could've also done this as a default), I added an argument ("Organic groups: Groups") with the following properties:

  • Title: <none>
  • Breadcrumb: <none>
  • Action to take if argument is not present: Provide default argument
    • Default argument type: Fixed entry
      • Default Argument: 6116 (this is the node ID for the organic group under which this view is posted)
    • Validator options
      • Validator: Group nodes
        • Argument type: Node ID
        • Validate current user: <unchecked>
      • Action to take if argument is not present: Hide view / Page not found (404)
  • Allow multiple terms per argument: <unchecked>
  • Exclude the argument: <unchecked>

Doing this allows Organic Groups to treat the Views page display as if it is actually a page within that particular group. Another problem solved! (I'm really beginning to fall in love with Views... and, apparently, Views 3 is going to be even more full of win!

Another Option - Embed in Page

You can also embed a view directly in a page, using the context of that page in your view to grab the items for the group into which the view is embedded.

To do so, create a new page/story/whatever node, with 'PHP Code' as the input format. Inside the node, put in

<?php
print views_embed_view('group_newsletters');
?>
and save your node.

In the view you wish to embed (name it view_name as you used in the code above), add an argument like the following (with type Organic Groups: Groups):

  • Title: <none>
  • Breadcrumb: <none>
  • Action to take if argument is not present: Provide default argument
    • Default argument type: PHP Code
      • PHP Argument Code:
      • <?php
        if ($node = og_get_group_context()) {
        $args[0] = $node->nid;
        return
        $args[0];
        }
        else {
          return
        NULL;
        }
        ?>
    • Validator options
      • Validator: Group nodes
        • Argument type: Node ID
        • Validate current user: <unchecked>
      • Action to take if argument is not present: Hide view / Page not found (404)
  • Allow multiple terms per argument: <unchecked>
  • Exclude the argument: <unchecked>
geerlingguy

As explained on Drupal.org today, Drupal 7.0 Alpha 1 has been released, and it incorporates (among other things) a revamped user interface, custom fields (CCK) in core, image handling in core, an update manager, and a ton of 'under the hood' improvements.

This is going to be the best Drupal release to date, for two reasons:

  1. Drupal has reached critical mass: WhiteHouse.gov, Intel, The Grammy Awards, and heck, even Monty Python are running on Drupal. So is your cousin's Internet startup. Drupal's seen a couple years of great press, and it still hasn't hit the ceiling in potential or mindshare!
  2. Theming has gotten a whole lot easier: Disregarding the poor english in that description, it will be easier for themers (like me) to crack into designing for Drupal, which means more small businesses and individuals will use Drupal as an out-of-the-box website building solution. Expect a few people who've outgrown WordPress or Joomla to cross the pond... (link is to a placeholder page for now).

Besides these two points, the administration side of Drupal is much improved, and a lot of ridiculous bugs and weird elements from years past have finally been fixed. A few things will have to wait 'till Drupal 8, but for the next few years, I predict Drupal 7 is going to get a lot of traction, especially with the D7CX pledge. (I'm going to have to update my Drupal 6 theme, Airy Blue... ugh).

Why don't you go download Drupal 7 now, and kick the tires a little. It'll be a nice experience, minus the few critical bugs remaining. Once you're finished testing, dive into the issue queue and help change Drupal 7 from alpha to beta, and soon to release!

I'm going to be writing up a post on Building a Theme for Drupal 7 once I get a little time... it'll be on my other site, lifeisaprayer.com.

geerlingguy

A project I'm working on required a user's signature be displayed on the user's blog posts (only on the page—not in blog teaser listings), and after much wrangling, I figured out how to put the 'Biography' (one of the user profile fields) into the nodes when they were viewed individually.

Here's the snippet (to be placed into node.tpl.php or node-blog.tpl.php):

<?php if (!$teaser): ?>
  <?php $account = user_load(array('uid' => $node->uid)); if (!empty($account->profile_bio)) { ?>
    <div class="blogger-bio"><?php print check_plain($account->profile_bio); ?></div>
  <?php } ?>
<?php endif; ?>

The code basically checks if the user's account has a bio filled out, and if so, it will place it at the end of the node if the node is viewed by itself (if it's not showing the teaser).

See comments below this post for some important security considerations and alternate options.

geerlingguy

Drupal CVS <ugh> Druplicon FrownFrom time to time, I've had to update my airyblue project in CVS (Airy Blue is a light, airy, Zen subtheme listed on Drupal.org's Themes section). It's always a bother, and I always end up spending about 20 minutes figuring out how to check out the module to my local computer (I use three of them, so even if I have it set up on one, I need to get it going on another sometimes), then another 20 figuring out how to commit my changes, tag a release, etc.

So, this post might be titled "How to Maintain a Theme on Drupal.org if You're Confounded by the CVS Guide for Theme Maintainers, and you are on a computer on which you haven't checked out your module yet."

Logging in, Setting up CVSROOT

  1. Open up Terminal (on a Mac) and navigate (cd) to your CVS folder.
  2. Enter export CVSROOT=:pserver:&lt;username&gt;@cvs.drupal.org:/cvs/drupal-contrib
    (This will set your CVS 'root' to the right directory. Enter your username where it says <username>).
  3. Enter cvs login to login, and type in your CVS password when prompted.
  4. Type in cvs checkout -l contributions/themes
  5. Type in cvs checkout -d contributions/themes/&lt;themename&gt; contributions/themes/&lt;themename&gt;

After you do this, you should have the latest version of your module checked out into your local folder. Now, edit the files however you'd like, and test them locally to be sure your changes are correct. Next you have to commit your changes (don't do this yet if you've added or removed any files or folders*):

  1. In the same Terminal window, type in cvs commit -m &quot;Explanation of changes.&quot;
  2. Finally, you have to tag your release before you can go to the project page on drupal.org and create a new release of your theme. Type in cvs tag DRUPAL-6--1-1 (or whatever tag you need - in my case, it was DRUPAL-6--1-5 for 6.x-1.5).

Now, go back to your project page on drupal.org, and click the 'Add new release' link under the Download section. In the release notes, you should reference all the issues you addressed in this release cycle, by typing them in as follows: [#552912] (the number should be replaced by issue's number as seen on drupal.org).

*If you added or removed any files, you will need to tell the CVS server what you did:

  1. For a new directory, type in cvs add &lt;directory&gt;
  2. And to get all the files inside that directory added, type in cvs add &lt;directory&gt;/*
  3. To remove a file or directory, type in cvs remove &lt;filename&gt; or cvs remove &lt;directory&gt;
geerlingguy

It would seem Google has rolled out a new indexing/display feature that finds breadcrumbs and displays them instead of URLs for certain search results. Drupal's already game, it seems, judging by numerous searches I've taken a glance at today:

Drupal's Breadcrumb-enabled Search Results

I guess since Drupal's built towards this kind of data heirarchy, Google quickly and easily indexes the breadcrumbs... any other sites/CMSs already in the index in this manner?

Also, I wonder what this will do in terms of eye tracking and such - the first time I noticed it, my eye went to the URL immediately - of course, that could just be due to the novelty of the thing.

geerlingguy

Packt publishing just announced earlier this morning that Drupal has won the 2009 Open Source PHP CMS award!

Packt Publishing is pleased to announce that Drupal has won the Best Open Source PHP CMS Category in the 2009 Open Source CMS Award. This category featured a very close contest between the top three, Drupal, WordPress, and Joomla! in which Drupal ended up as the overall choice for the judges and the public.

Joomla was the second place winner (kudos to them as well!); read the original release here.

With Drupal being used on Whitehouse.gov, AT&T's mobile apps website, and countless other corporate sites and subsites, it's a good time to be in the Open Source arena!

More award categories will be announced soon!

  • Most Promising Open Source CMS: winner to be announced on November 11, 2009
  • Hall of Fame: winner to be announced on November 12, 2009
  • Best Overall Open Source CMS: winner to be announced on November 13, 2009

 

geerlingguy

I've begun working a lot more with Drupal multisites, as doing so saves a lot of time in certain situations (usually, when you have a large group of sites that use the same kinds of Drupal modules, but need to have separate databases and front-end information.

One problem I've finally overcome is the use of actual domain host names for development (i.e. typing in dev.example.com instead of localhost to get to a site). This is important when doing multisite work, as it lets you use Drupal's built-in multisite capabilities without having to hack your way around using the http://localhost/ url.

Here's what I did to use dev.example.com to access a dev.example.com multisite in a Drupal installation using MAMP (the dev.example.com folder is located within Drupal's /sites/ folder):

  1. Edit MAMP/Apache's httpd.conf file - it's located at /Applications/MAMP/conf/apache/httpd.conf
    1. Put in the following at the end of the file:
      <virtualhost>
        DocumentRoot /Applications/MAMP/htdocs
        ServerName dev.example.com
      </virtualhost>
  2. Restart Apache (in MAMP, click stop servers, then start servers).
  3. Open up Terminal (in Applications > Utilities), and type in $ sudo nano /private/etc/hosts
    1. Type in your password if requested
  4. In the hosts file, add a new line after the line that reads 127.0.0.1         localhost:
    • 127.0.0.1         dev.example.com
  5. Save the file by pressing Control+O (this writes the file) and then Return when it says 'File Name to Write:', then press Control+X to exit nano.
  6. Now, flush Mac OS X's DNS cache by typing:
    • sudo dscacheutil -flushcache

Now, if you are behind a proxy server (i.e. if you have the Network settings in System Preferences set to use a proxy server for Web traffic), you will need to also add your dev.example.com entry to the 'Bypass proxies for these domains' field (localhost/127.0.0.1 should already be present here).

Next time you visit http://dev.example.com/ in your web browser, Drupal should point you to the appropriate multisite folder on your local Mac!

geerlingguy

I noticed a post from the excellent folks over at Development Seed in the drupal.org Planet feed on a new Drupal installation profile they've been working on called Managing News. Having tried (and loved) their Drupal-based installation of Open Atrium (a great package for quick Intranets), I had pretty high expectations.

Those expectations were pretty much blown out of the water; this install profile basically sets up a Drupal site (with all the Drupal bells and whistles) that is focused on one thing, and does it well: news aggregation via feeds (Atom, RSS).

Catholic News Live.com - Catholic News Aggregator

I decided to quickly build out an aggregation site, Catholic News Live. The site took about 4 hours to set up, and it's already relatively customized to my needs. One thing I still don't know about is whether Drupal's cron will be able to handle the site after a few months and a few hundred more feeds... but we'll see!

Continue reading...