Drupal Planet

Aten Design Group: Project Review Wednesday: Content Reminder

There are currently 98 new Drupal contributors awaiting review of their first project. This is a great place to contribute to the community and learn about interesting upcoming projects, for example...

Module: Content Reminder What does it do?

Publishing content feels great. There's a sense of accomplishment and it's there for the world to see. However, that content oftentimes needs to be checked on and updated. Instead of letting a page languish, alone and forgotten, you can use the Content Reminder module to set up reminders to check on it.

Content Reminder adds a notification tab to each node, allowing a user to create a notification to be sent to a site's user with a customizable message and date upon which it should be sent. Now you can ensure that your site's content is fresh and relevant, not forgotten.

Zoom Look Useful? Review it!

If you would like to see this module readily available on Drupal.org, you should review it and help make that happen.

Review It

Pro Tip: If you've never reviewed a project application before, you can find instructions for reviewers on Drupal.org and the Code Review group is happy to help more people get involved.

Pronovix: Drupal for the European Commission: BoFSession at DrupalCon Portland 2013

This is a guest post by Mathew Lowry from Intrasoft International. We suggested him to write this post as a preparation for a BoF session his colleague will be organizing at DrupalCon Portland. If you are working on a Drupal platform for government or for a bigger organization that wants to standardize on Drupal as a communication platform for a series of its departments, and if you are attending Drupalcon Portland, come and join us to discuss best practices and lessons learned.

Microserve: Drupal.org - Contributing a Module & The Review Process

I recently went through the process of contributing my first Drupal 7 module, and while the process isn't too hard there were many things that would have been helpful to know at the start rather than finding out half way through the process. As a result of my experiences I've decided to put together this blog which covers many of the common pitfalls people run into and provides a collection of useful links to various bits of documentation on Drupal.org.

How It Works

When you first register at drupal.org you will only be able to create sandbox projects, once you've created your first sandbox project you will be able to apply for full project access. Applying for full project access means your sandbox project will have to go through a review by the community, once that's approved you will gain full project access and wont have to get any future projects reviewed.

Getting Started

The first thing you'll need is an idea of what the module you want to create will do, once you've come up with the idea check that there aren't existing modules that do the same thing and make sure what you are trying to do should be in its own module and not just part of another existing module. If your module is too similar to an existing module then your project application will be declined, and any hard work you've put into the module will have gone to waste. For more information on duplicate modules see collaboration rather than competition.

Creating a Sandbox Project

Creating a Sandbox project is fairly straight forwards, but be sure to check out tips for a great project page or for even more project page tips How to make your module description useful. Your project application may be delayed if the description of your project isn't sufficiently detailed.

When setting up Git for your new sandbox project if you follow the instructions provided you will end up with a master branch, unfortunately this isn't actually correct, Drupal requires that you work out of a major version branch (7.x-1.x for example) instead of master. You will need to change this before your project goes for review, read through Moving from a master to a major version branch to find out how to do this.

Coding Your Project

Getting your code to meet the standards expected by Drupal is quite easy, it does however involve reading through a lot of documentation, these are the bits I found most useful:

Once you've read through the above and written some code there are some handy tools available to check that your code complies with Drupal's standards:

  • The Coder module which checks your module code on your local Drupal installation.
  • ventral.org which can be used to test your code once it has been pushed to the repository on drupal.org.

If either of the above tools pick up any errors they will be brought up in your project application, and you will be expected to fix them however trivial they may seem.

 

Applying for Full Project Access

Before you apply make sure you check that the sandbox module you are going to apply with meets all of the requirements listed in the Project application checklist, also note you can only apply for full project access with one sandbox module.

When you're ready to apply for full project access read Apply for permission to create full projects for guidance. Once you've done this you will need to obtain a review bonus. Although the documentation suggests obtaining a review bonus is optional in practice, it truly isn't if you want your module to be reviewed in any sensible amount of time.

To get the review bonus you will need to review three other modules, see Review bonus for guidance on how to do this. Make sure that your review of the other modules is sufficiently detailed as your review will not be counted if it's just a copy of the results from ventral.org.

Once you have your review bonus add the tag and you should find your module being reviewed shortly after. Note though if any major issues are found you will not only have to fix them but will have to re-earn your review bonus so it's well worth reading the standards documentation etc... beforehand as it will probably save you time in the long run.

 

Good luck with your module!

LevelTen Interactive: Using Drupal 7 Entity Reference to help Create User Dashboards

Over the years, I have noticed a significant increase in the need for businesses to create user dashboards from which their customers are provided account details, up-to-date reports, downloadable documents and other important information. As more clients ask for user-driven websites that provide user-specific information, the need to relate or reference various types of content/data together is becoming commonplace.... Read more

Amazee Labs: How Drupal "Views Auto-Refresh" really works

Views is a great module and as you'll probably know it is the most downloaded module in Drupal's history. The possibilities which Views provides you with are almost endless but there is one limitation. The generated output of a view is by default static. What if you want to have a dynamic activity stream as you know it from Twitter or Facebook?

Allow Drupal's unofficial slogan to answer that question: There is a module for that! The module in question is "Views Hacks" and contains another module called "Views Auto-Refresh". There is a blog post about how to implement this module in order to get it to work as you want to, but it seems like this post doesn't cover all of the aspects that are implemented in the "dev"-version. A follow up blog post offers a little more insight, but still not everything I needed.

On a side note: In this tutorial we will use the "dev"-version of "Views Hacks", because the alpha was buggy at the time, and the implementation of the JavaScript part is not in the Drupal way anymore.

Preparation

Let's get started with the implementation. I assume that you have downloaded, installed and activated Views, Views UI, Views Hacks and Views Auto-Refresh. Further I assume that you have created a view for which you want to use the auto-refresh feature.

I will demonstrate the implementation of Views Auto-Refresh by showing screenshots of the actual project.

Implementation

Make the following configurations:

  • First of all, you need to duplicate your actual view as a view page. Give it a semantic name like "autorefresh".
  • Give the page a unique path as displayed in the screenshot above.
  • Also give an easy-to-remember machine name.
  • Make sure that the view is using AJAX.
  • Add the Content: Post date (with operator) or any other timestamp as a contextual filter (we used the "Content: Updated date"). Views Auto-Refresh will provide the timestamp needed.

Now head over to your view and add a "Global: Text area" with the text format "PHP Code" and add following code:

<?php print theme('views_autorefresh', array('interval' => '30000', 'incremental'=> array( 'view_base_path' => 'frontpage/autorefresh', 'view_display_id' => 'autorefresh', 'view_name' => 'articles', 'sourceSelector' => '.view-content', 'targetSelector' => '.view-content', 'firstClass' => 'views-row-first', 'lastClass' => 'views-row-last', 'oddClass' => 'views-row-odd', 'evenClass' => 'views-row-even', ))); ?>   As you can see, there is a base path and a display ID.
The base path equals your defined page path, and the display ID equals the Machine name of the auto-refresh View. "interval" defines how often the auto-refresh View is being called while "view_name" is the machine name of the actual view.

The additional settings are the selectors and classes which will be addressed by the JavaScript of Views Auto-Refresh. I don't want to dig too deep since they should be self describing.

Now you might think that everything is done. But no, wait, we have to add the same code to the header of your original view. So do the same thing there as I have described it above. Please make sure that this view also uses AJAX, else it wouldn't work.

Further possibilities

In our project we use the jQuery library Isotope which sorts all the posts dynamically on loading or resizing. But you have to trigger the re-layout of the page if the Views Auto-Refresh has delivered some new posts. This is really simple and straight forward. You just have to add a Drupal behavior in your JavaScript like this:

/** * Add functionality to trigger reloadItems after an autorefresh */ Drupal.behaviors.triggerIsotopeAfterAutorefresh = { attach: function(context, settings){ $('.view-id-articles').bind('autorefresh.incremental', function() { //getting the content/context $isotope = $('.view-id-articles .view-content'); //reload all items by original order $isotope.isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' }); }); } }

As you can see, you can just bind the event 'autorefresh.incremental' to execute your own code. 'autorefresh.incremental' is fired every time the Views Auto-Refresh module loads the designated view.

Conclusion

After a few trial and error attempts, I finally figured out how Views Auto-Refresh really worked. There is a lot more to this module that isn't documented. So it is much more powerful than I can describe in only one blog post. So go on and give it a go.

Update 9.5.2013: As pointed out by Phil Dodd in his comment the Views Auto Refresh module has been moved to its own home at http://drupal.org/project/views_autorefresh.

 

Modules Unraveled: 061 The Walkthrough.it Project with Kristof Van Tomme - Modules Unraveled Podcast

Walkthrough.it
  • What is walkthrough.it?
  • I heard that this works with Selenium in the background
    • What is Selenium?
    • How does Selenium make this awesome?
  • How is this related to the Tour module in Drupal 8 core?
  • How do you record walkthroughs?
  • How do you play walkthroughs?
  • You recently finished a crowdfunding campaign on IndieGoGo, can you tell a bit more about
    that?
  • What things did you promised as part of the campaign?
    • WalkHub: walkthrough server distribution,
    • Walkthrough module for Drupal
    • really awesome t-shirts
    • WalkHub.net: GitHub for interactive tutorials
    • An iPad application with introductory tutorials for Drupal distributions
App
  • What is this iPad app for?
Drupal Module
  • Can you tell me a bit more about the Drupal module?
  • Will there be versions for both Drupal 7 and Drupal 8?
Grand prize: documentation of a distribution
  • You promised that you would document 1 distribution with walkthroughs if your IndieGoGo
    campaign would be a success. Do you already know which one will win?

Doug Vann: Top Ten Things To Bring With You To DrupalCon Portland

Going to Portland for DrupalCon 2013? This will be my 6th year at DrupalCon. You're about to enjoy 3,000 PLUS ppl getting their Drupal on!
I've devised this TOP TEN list of THINGS TO BRING, from the experiences I have had. Let me know if this comes in handy! I'll be happy to add to this list if you have something to contribute! ;-)
 

[1] COMFORTABLE SHOES
Seriously!
You're going to be doing a LOT of walking wether it's in the convention center OR in town.
If you buy new shoes BREAK THEM IN BEFORE you leave.
Also, consider some comfortable inserts for your shoes. 


[2] MOBILE POWER PACK

Don't find yourself stuck with a dead mobile phone. I use the Motorola Universal Dual-Charging Portable Power Pack [pictured right] Don't count on having access to a power outlet at the event to keep your devices charged. I leave the power pack plugged into my phone either in my pocket or in my bag. I'll typically do this after lunch so that I have plenty of power for the evenings.


[3] BUSINESS CARDS
And PLENTY of them!
Maybe you don't own a business or run a big freelance operation, but either way, you need something to give some one to remember you by. You're going to meet a lot of people and some of them you will want to keep in touch with. Do yourself a favor and get in the habit of giving out a card when you meet someone. Just get your name, number, web-address, email address, what your skills are, your twitter handle, LinkedIn url, etc. Make it easy for people to stay connected to you! 


[4]GOALS
Make a written [or typed] list of what exactly it is you want ot accomplish while at DrupalCon. Do you want to learn some very specific skills? Do you want to understand the mobile web better? Do you want to exchange cards with representatives of higher-ed organizations? Maybe you want to spend time at the booths of each Drupal shop and checkout employment opportunities?
Whatever it is you want to do, MAKE A LIST and check it each and every day of the event. 

[5] YOUR HIT LIST!
Who do you want to shake hands with while you're there? A famous podcaster or module maintainer? Dries? Earl? Eaton? Crell? CHX? Webchick? Or maybe even lil' old me? :-)

Make a list of some of the people you want to THANK for their tireless work to make Drupal awesome. Don't hesitate to walk up to the people you admire and appreciate and say hello. There are no ROCK STARS in Drupal! [OK. I guess there really ARE!] But, regardless, you should feel very comfortable reaching out to any one. If you need to, ask someone you know to introduce you. I'd be happy to do that for anyone! ;-)

[6] PEN & PAPER
Don't underestimate the power of the written word.
You're going to have times where you want to write something down without booting up a mobile app or your laptop.
You're also going to want to write something down on your business card before you hand it out OR write something on someone's business card when they hand it to you. 

[7] YOUR STORY
Every one has a story. Be prepared to share some of yours. You will certainly be asked some or all of the following questions:
What do you do with Drupal?
When/How did you discover Drupal?
How long have you been doing Drupal?
How have you contributed?
What brought you to attend DrupalCon?
 

[8] CURIOSITY
I don't recommend bringing a multi-million dollar Mars research robot with you, but you should bring some good ol' fashion CURIOSITY to DrupalCon
You're going to be surrounded by immense talent and knowledge covering more topics and areas than you can digest in the short period of the event.
I encourage you to wander off into uncharted territory and expand your horizons! 

[9] WARDROBE
This may sound like a no-brainer, but here are some tips.

Bring more than you think you need. You may discover that you want to change between the day events and the evening events.
Pack some options. You may discover a group that wants to hit the beach, or go hiking, or go swimming, or go dancing.
Seriously... I can't tell you how many events I've been to where amazing opportunities pop up to have some fun! Don't let your wardrobe hold you back! 

[10] ROOM FOR SWAG
OK. I know I already have you packing upwards of 200+ pounds of stuff for DrupalCon but there's just one more thing to consider.
You're going to get a LOT of free T-Shirts AND there will also be opportunities to buy some stuff as well. So PLZ PLZ PLZ plan on a cary on or extra room in your bags for SWAG!

There you have it! I hope this helps you out. 
I look forward to your feedback! :-) 

Drupal Planet

Jeff Linwood: Drupal and Mobile Video – Dallas Drupal Camp 2013 – iPhone App and Presentation

Earlier this month, I spoke at the Dallas Drupal Camp about Drupal and mobile video. I’ve worked on a couple of projects for clients this year and last year that involved uploading and displaying videos from a mobile app on iOS and Android. Some of them have used Drupal for the server, others haven’t used Drupal at all. Mobile video can only be done through a native app (or PhoneGap), as HTML5 hasn’t provided support for uploading video through input types yet.

One of the obstacles to using Drupal as a video platform is getting everything set up – even though there are plenty of video modules, it can be tough to set up the Video module with Zencoder as a transcoding solution and Amazon S3 for storage and content distribution. Making this a lot easier if you are either starting from scratch or building out a proof of concept/minimum viable product is Octopus Video (http://octopusvideo.org/), a Drupal 7 distribution developed by Heidi Software and Symphony Themes. In effect, it’s a private YouTube distribution, which you can then extend using normal Drupal 7 modules and views to become a corporate training video archive, the back-end for a consumer-facing mobile app for cat videos, or whatever you want.

I gave a lightning talk about Octopus Video to the Austin Drupal User’s Group, and everyone there seemed pretty enthusiastic about the topic, so I decided to take it a step further and give a talk on it at the Dallas Drupal Camp this year.

In addition to sharing a lot of tips and tricks I learned from using Octopus Video as the server for a video-based mobile app prototype, I also created an open source iPhone app (Apache-style license) to show off some of the things you can easily do – upload video, display a list of videos from a Drupal video, and then play back videos stored on Amazon S3.

The GitHub repository for the open source iPhone app is here:

https://github.com/jefflinwood/DrupalMobileVideoAppIOS

This was a quick demonstration project for the Dallas Drupal camp, not extracted from a commercial project, so it’s missing a lot of the extras that would make it a polished app. I’ve added a few of them as issues to the GitHub project, and if I can find some more free time, I’d like to keep moving forward with it.

Drupal Commerce: Drupal Commerce sites can now use Google Store Locator

Working in eCommerce all the time can make it easy to forget that a vast majority of consumer spending is still done in brick-and-mortar shops. Discovering a dearth of ‘easy to install and configure’ store locator modules on drupal.org prompted us at Commerce Guys to create one. Our choice of which direction to move in was made easier because Google had recently announced the release of a store locator utility library, that makes working with their Maps API relatively painless.

To integrate the library with Drupal we knew we’d need an admin config UI, a method for creating locations, a way to convert those locations to machine readable data (i.e. latitude and longitude), and the JavaScript necessary to talk with GMaps API. As usual Drupal rushed to the rescue. We used content types to create locations. This resulted in an unforeseen benefit that administrators can use the nodes created for locations as individual showrooms (to post galleries, additional information, etc.). The geocoder module along with Views and Views GeoJSON took care of converting and handing the address data off to our JavaScript. Finally the library helped ease our JavaScript burden, and before you know it, we gave birth to the Google Store Locator!

To see the module live, check out the locators on the American Bank of Texas and American Association of Birth Centers websites. Read on for answers to some common questions folks have regarding Google Store Locator.

Open Source Training: How to Use Drupal's Search Module

A lot of things are simple in Drupal ... once you know how.

The Search module is a perfect example of something that is initially confusing to set up, but simple once you know how do it correctly.

This week we had several questions from our members about the Search module, so we wrote this tutorial to help them out.

There are several confusing elements to the Search module. Let's address them one-by-one:

Blair Wadman: How to invoke a new hook in a Drupal module (and add yourself to a round of beer)

So, you want to allow other modules to hook into your own module. You may have implemented hooks that other modules provide, but does invoking your own hook for a module seem like a dark art? It is as simple as calling one function in your module. All will be revealed shortly, but first, lets look at why you would want to invoke your own hook.

What is invoking a hook?

When you invoke a hook, you are registering a new hook with Drupal that allows other modules to implement and therefore interact with your module. You are providing hook in points in your module which say to other modules “here is a point where you can inject your own data or extend my module”.

Why invoke hooks?

The hook system is at the heart of what makes Drupal powerful. All modules will use hooks to interact with the rest of the Drupal system. By invoking your own hook, you are making your module more powerful and useful because you are allowing other modules to extend it or change its data in some way. If no module invoked hooks, there would be no hooks for you to implement! If it still does not make sense, don’t worry, as the best way to understand it is with an example.

Beer round example

Let’s take a really simple example. Imagine you have a module with some code which returns a list of people included in a round of beer. And then you want to invoke your own hook so that other modules can add to the list of names that are part of the beer round.

Let’s set the module up before invoking the hook. The module is called beer_round. In beer_round.module you firstly need to implement hook_menu() to define the path where we can see the list of names for the beer round.

/** * Implements hook_menu. */ function beer_round_menu() { $items = array();   $items['beer'] = array( 'title' => 'Beer round', 'page callback' => 'beer_round_callback', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, );   return $items; }

This snippet simply means, when the user goes to the path beer, call the callback function called beer_round_callback(). Anyone who has the access content permission has the necessary permissions to view this page.

Next you need to define the callback function.

/** * List of people included in a round of beer. */ function beer_round_callback() { $round = array('Dave', 'Paolo', 'Andrew', 'Mat', 'Paula', 'Mihhail', 'Pete', 'Dima', 'Bhavna', 'Laura', 'Steve', 'San', 'Nick'); $output = theme('item_list', array('items' => $round));   return $output; }

This contains an array of names of people who are part of the beer round. You then pass that array into the theme() function, which will convert it into an unordered list. If you now hit the path beer, you will see the list of names.

Now it is time to invoke a new hook. To invoke a new hook, all you need to do is call module_invoke_all() and pass in the name of the hook. We will call the hook beer_round. So you will call module_invoke_all(‘beer_round’) and add the result to the array of people in the round.

/** * List of people included in a round of beer. */ function beer_round_callback() { $round = array('Dave', 'Paolo', 'Andrew', 'Mat', 'Paula', 'Mihhail', 'Pete', 'Dima', 'Bhavna', 'Laura', 'Steve', 'San', 'Nick'); $round_more = module_invoke_all('beer_round'); $round_all = array_merge($round, $round_more); $output = theme('item_list', array('items' => $round_all));   return $output; }

Drupal will check every module to see if hook_beer_round has been implemented. If it has, the data the modules provide will be added to $round_more, which will be an array. If two modules implement hook_beer_round(), the array will contain two elements. So now we have two arrays, the original array of people in the beer round, and the additional people added via the hook. So merge the two together with array_merge(), and you have the full round.

To see this in action, implement hook_beer_round() in another module. I have a module called ‘blair’ where I will add myself to the beer round.

My implementation of hook_beer_round is:

/**  * Implements hook_beer_round();  */ function blair_beer_round() {  return 'Blair'; }

Now if you reload the beer page, you will see that my name has been added.

That is all there is to invoking a hook! This is a very simple example to get you started. I will go into a more advanced example in a future post.

Note: real names are used in the example, but nobody was harmed in the production of this tutorial.


Overview of invoking a hook

Tags: Drupal Module DevelopmentPlanet Drupal

Cafuego: Add images to Drupal from your mobile device

You can add images to Drupal, but mobile devices don't allow you to upload any photos to image fields. This is something that sort of irked me from time to time in the past, but recently came up for a website project, so I thought it would be good to see if it could be worked around.

HTML5 allows for this, but sadly that's mostly a no go with Drupal 7 at the moment. However, it turns out the fix is nice and easy via the HTML Media Capture method. Add the following snippet of jQuery, so it runs when pages load:

$('div.image-widget-data input[type="file"]').each(function(idx, item) { $(item).attr('accept', 'image/*;capture=camera'); });

That will look for <input type="file"> items inside image widgets and add the "accept" attribute This then tells mobile devices they can upload image data and are allowed to grab that from their on-board camera.

To make that a spot simpler on Drupal, you can grab the Image Mobile Camera module from its sandbox on Drupal.org.

Now hit your blog via your tablet or phone (using a browser that supports this - Chrome is fine) and start uploading photos :-)

Tags: drupalimagemobilehtml5

Károly Négyesi: Advanced debugging with PHPstorm

It seems relatively easy (ie. zero configuration) to get PHPstorm and Xdebug up and running together, so I will presume you have that going. It often happens that you want a breakpoint in a frequently called function. Just putting one will make the system stop there every time. After a right click, Edit you can add conditions to it which help. Even better, you can add a breakpoint to somewhere else, remove the suspend checkbox from it and make the first breakpoint disabled until the second is hit. This allowed me for example to break in drupal_flush_all_caches only when fired from WebTestBase::resetAll.

Another useful tip from dawehner (I had no idea!): PHP CLI works with xdebug just fine, you just need to run export XDEBUG_CONFIG="idekey=PHPSTORM" first.

Pages