Planet Drupal
LevelTen Interactive: Twitter Chooses Drupal Again, This Time for Gasp, Their Blog
I've been telling people for years that if you just want a blog WordPress is a great option, but Twitter's decision to use Drupal as a blog makes me wonder a bit. Why would a company with their development and technical expertise choose Drupal vs WordPress if they're just building a blog?
Here are just a few reasons why I think the decision was a no-brainer:... Read more
Propeople Blog: Drupal 7 Menus - Troubles and Solutions
At a first glance configuring and managing menus in Drupal 7 looks pretty straightforward. When requirements get a bit more subtle and demanding, often a situation arises where the core Drupal menu functionality is not enough to handle the task at hand. We have identified some frequently encountered troublesome situations and in this post I will share the standard solutions we use to solve them. We all know how powerful Drupal is thanks to the community behind, the contributed modules and the hooks system. The rest of this article is just a proof of that statement.
Menu positionIn almost every case where the project is something beyond a simple brochure site, there is a requirement that nodes of certain content types should appear in specific positions in the menu system. The simplest solution, which is adding all of that content individually under the specified menu items works well for small number of nodes. But imagine hundreds or thousands of blog posts added as menu items under the Blog item in the Main Menu. You will have both performance and usability issues. We need some other way to manipulate the active trail. To our rescue comes the menu_position module which gives us the possibility to create rules that will dynamically add the current page into the menu system at the requested spots. Those rules could affect the main and secondary links of the theme, the breadcrumb trail, menu blocks provided by core's Menu module and also menu blocks provided by the Menu Block module.
Before going into details about the Menu Block, I want to mention something noted at the Menu position's module page:
Currently, the Menu position module provides "content type", "pages", "taxonomy", "vocabulary" and "language" plug-ins that allows conditions to be added to rules. Additionally, this module also provides a simple API for "rule conditions" plug-ins so module developers can develop their own logic for adding dynamic menu positioning.
As with most Drupal things, there is also another way to achieve all of the above, and that is to use the Context module conditions and reactions. It is a bit more complex to set things up but it has the added benefit that your settings will be exportable in Features, which is always a good thing for larger projects.
Menu blockWe all know how to use the Main and Secondary menu links feature in our themes. But most probably at some point you have wondered “how do I display any menu items deeper than that?" As the maintainer puts it, he was shocked of the fact that the Menu block module didn’t exist before he wrote it. What this module does is providing configurable blocks of menu trees starting with any level of any menu, and displaying the child menu items to a configurable depth. It is harder to explain what exactly the module does than actually trying it out so I encourage you to go ahead and enable it. We use it in almost any site where the navigation was planned to be truthfully user friendly from the beginning. After installing the module you can go to your blocks administration page and create a new Menu block. Use the Main menu for the source and configure it to show levels 2+. Create some menu items and place the block in one of the sidebars. Go ahead and play with the settings, it will become very natural in a few minutes. This module is simple, yet powerful tool!
Menu path autocompleteThis module answers the search of our clients and site editors for a simplified ways to create menu items with correct links. Let’s face it - we are developers and most of us like to work with strings like node/42, but most of our users are not very happy with this paths.
The Menu path autocomplete (drush dl mpac) changes the text input field for menu path to an autocomplete field while you are adding a menu item. While entering characters into this field you will get a list of all matching node titles (and - if path is enabled - all matching URL aliases). Selecting one item will translate it to the correct internal link. Simple solution, bringing lots of value along.
Menu attributesYet another simple but empowering tool helping us bend Drupal menus to our will (and the needs of the front end department). Usually with complex designs and user interface functionalities there are requirements for certain menu items to have a specific id, some class or another, or any other html attributes. The Menu attributes allows us to add and change the following attributes for each individual menu item:
- id
- name
- target
- rel
- class
- style
- accesskey
The next two situations I want to mention are those where access to menu items is concerned. It turns out that sometimes when we want to hide certain menu items or show others to our visitors, the Drupal roles and permissions system can’t handle the task easily.
From the Menu item visibility module page: This module exposes configurable and extendable visibility settings for menu links. For example, if you want to create a 'My account' link that points to /user, both anonymous and registered users have access to the /user path, so both will see the link, even if anonymous users do not technically have an account. Using this module will allow you to only have your 'My account' link visible to registered users, and hide it from anonymous users. You can see a screenshot of the settings page - the module uses the same User Interface which is used for block visibility settings - familiarity and ease of use for our editors.
Finally, some code for dessertSometimes we want to link a PDF or another file directly in one of our menu items. You can try to upload a file in your files directory, usually sites/default/files and try saving a menu item linking to that file. Validation will fail and you’ll get something similar to the following message from Drupal:
The path 'sites/default/files/HelloDrupal.pdf' is either invalid or you do not have access to it.
Why does this happen? Because Drupal’s menu system is made in a way that it checks hook_menu implementations in the system to see if there exists such an internal path and if you have access to it. The solution is a simple module implementing the hook_menu() in the following way:
<!--?php /** * Implementation of hook_menu(). */ function my_module_menu() { // Define a router item for the files directory. $items[ file_directory_path() ] = array( 'page callback' =-->'drupal_not_found', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); return $items; }
Note that this doesn't break anything - if you request a non-existing file you’ll still get a 404 page.
Have you encountered the problems I described above? Do you have better solutions, or maybe some other menu troubles you want to share? Please let us know what you think in the comments section.
Tags: DrupalDevelopmentService category: TechnologyCheck this option to include this post in Planet Drupal aggregator: planetTimOnWeb.com: Find Out Form ID Easily with Get Form ID Module for Drupal 7
"How to find form id in Drupal" is one of the most popular questions, especially for the beginners.
More experienced developers know that to find form id you need to either look into the DOM source code or to create your own hook_form_alter() function like this:
function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
dpm($form_id);
}
comm-press | Drupal in Hamburg: Steps to reproduce really do help in issue summaries
I was working with new contributors tonight. They had worked on 2-4 issues before. They wanted to test a patch in dealing with a Drupal 8 multilingual issue. Sure, testing d8mi issues is a bit more tricky than regular core issues. Because a module usually needs to be enabled first, like Language or Content translation. But I think the lessons learned from this experience apply to any core issue.
Steps to reproduce in a comment are nice. Putting them in the issue summary is even better.This issue had Steps to reproduce in comment 3 out of 25, which is really great. Some issues do not have any steps to reproduce. Even though this issue had Steps to reproduce, I saw these two contributors spend 15 minutes wondering how to get to the settings page that needed testing. And then they wondered how to get the translation bits to show there. Once I pointed out the comment that had the steps, they were on their way. One did the testing... and the other updated the issue summary and put the Steps to reproduce right there in the issue summary. They wanted to make sure that the next person to come across the issue had an easier time testing than they did.
Web Omelette: 7 modules to help with your Drupal responsive design
In this article, I want to show you 7 modules that can play a role in making your Drupal 7 website responsive, or at least more mobile friendly. With more and more people using handheld devices that vary considerably in size, it is important to pay attention to their needs.
Web Wash: How To Setup A Local Solr Server For Search API
Running Search API and Apache Solr just got easier thanks to the latest release of the Search API Solr search module. This module allows you to use Solr as a server backend for Search API indexes. In the latest release (7.x-1.0-rc4) the module no longer has a dependency on the SolrPhpClient library.
In this tutorial I'll show you how to setup a local development Solr server on Mac OS X 10.8.3.
Please note that this tutorial should only be used to setup a development server where you're not worried about locking down Solr. If you want to setup Solr for a production site, then make sure you lock down the server so users can not get access to Solr.
Earl Miles: Be careful of what you get on Planet
While Drupal Planet can be a fantastic resource, it can also be a megaphone used when someone has an axe to grind. It's particularly unfortunate when one of those people don't open up comments. Theoretically useful code that comes with an axe to grind should always be suspect to begin with. When the first thing that the author says about the module the code is for is derogatory, it's a pretty good hint to distrust everything that follows.
BlogDrupalJosh Waihi: Drupal 7: Programatically updating Panel panes on node template variants.
Programatically working with Panels in Drupal is a bit of a nightmare. Trying to figure out how to obtain the right panel display and discover the right load and save tasks can be an utter disaster as you try trace code through ctools, page manager and panels itself while trying to understand what a ctools task or handler is or how to load them.
Tags: Drupal PlanetDrupalDrupal Association News: Welcome New DA Staff
I’m very excited to welcome two new members to the DA staff. These new staff members will have an immediate and direct impact on supporting and growing the Drupal community through DrupalCons, global training events and effective communication to the community and beyond. Please help me welcome them!
Personal blog tags: Drupal AssociationcommunityFour Kitchens: Magic: Frontend Performance for all themes
Howdy perfers!
This week’s Webperf Wednesday is short and sweet, just like your page loads when you install this new module that enhances any Drupal theme. Magic is a set of frontend performance and development workflow tools for themers. Previously many themes had their own advanced settings — many of which did the same things as other themes, but they all did it a little differently — no more with Magic.
Built by Web Chef Ian Carrico and Sam Richard (of Aurora) with contributions from Sebastian Siemssen (of Omega), Magic was built by the desire to work together to make all themes better, instead of siloing improvements within specific themes.
What’s inside? Performance features:- Enhancements to CSS Aggregation
- Exclude CSS files from being included
- Option to move JavaScript to the footer
- Backport of Drupal 8 JavaScript handling
- Exclude JS files from being included
- Rebuild Theme Registry on Page Reload
- Display a Viewport Width indicator
- Display an indicator with classes applied to the HTML. Useful when used in conjunction with Modernizr
- Export theme settings
That last one is super important, as it makes Drupal themes a little more DRY. With Magic, you can take your settings from one theme to another — or to another site completely — because they’re fully exportable. Have two different projects, and want similar asset output despite one being Omega and one being Zen? No problem, just export!
Note: the full import process has yet to land, but it’s coming very soon.
If you have an awesome trick that you always rely on during theming, open an issue and propose it to Magic. They’d love to hear from you.
Give it a shot today! Go to drupal.org/project/magic
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/continuing-ubercart-event-registrations-tutorial-9">Improving Drupal 7 Ubercart Event Registrations - Ubercart Series #2 Tutorial #9</a></h4>
In this Drupal video tutorial, we cover A LOT of ground as we continue building our event registration system which relies on the Pay Per Node module, making it more user friendly for our customers and administrators.
We cover the following:
1:10 - Using Views and the References module, we create a node reference on the customer's registration page which links to our existing events for the user to select.
3:30 - Using the Auto Node Titles module, we create an automatic node title for registrations so we can hide the field from our customers.
5:00 - We create a custom module to limit the events listed on a registration page to just those a customer has purchased (As an aside, you may want to update this code so that it only lists upcoming events -- you could do this in Views with the Date module).
16:00 - We alter the menu for Pay Per Node to make our menu tabs a little nicer for users.
18:00 - We add a list of registrations on the actual event product for administrators to see who has registered for their event. We also use the Views Send module to allow administrators to email those customers.
25:25 Lastly, with the Calendar module, we create a Calendar to show all of our upcoming events.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/drupal-ubercart-event-registrations-tutorial-8">How to Create An Event Registration System with Ubercart - Ubercart Series #2 Tutorial #8</a></h4>
In this drupal video tutorial, I show you how to create an event registration system. To do so, we rely on a few modules, most importantly, the Pay Per Node module. Essentially, Pay Per Node allows us to set up a product feature so that when a user purchases a specific product, they are given permission to create a node once the order is complete.
In this tutorial, we set up a new product class, an Event, and using the Date module, associate the event with a specific date. Users can see the event as a product and add it to their cart like any other product. Once their purchase is complete, they are able to log in and fill out a registration form that we created as a separate content type.
This tutorial will walk you through how to set up Drupal and Ubercart to get the basic functionality going. In the next tutorial, I show you how to make the system a little more user friendly to customers and administrators.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/drupal-7-template-preprocess-functions-and-tpl-files-ubercart-series-2-tutori">Drupal 7 Template Preprocess Functions and TPL Files - Ubercart Series ...
In this sixth drupal video tutorial of this ten part series, we continue with Drupal 7 theming and I show you how to use the template.php and node--product.tpl.php file to create a custom layout for our product pages. This allows us to pass single variables into our Ubercart product pages and render them in a specific order. As a result, we end up with a 3 column layout of information.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/how-configure-omega-delta-and-context-ubercart-series-2-tutorial-5">How to Configure Omega, Delta and Context - Ubercart Series #2 Tutorial #5</a></h4>
In this Drupal Video Tutorial, we continuing theming our site and I show you how to configure the Omega Theme, Delta Module and Context Module. In doing so, we walk through the settings for Omega and create a custom Delta configuration for our product page. We then use the Context module to invoke the Delta that we created.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/how-create-omega-submtheme-ubercart-series-2-tutorial-4">How to Create an Omega Submtheme - Ubercart Series #2 Tutorial #4</a></h4>
In the fourth Drupal video tutorial of this 10 part follow up series on Drupal 7 and Ubercart, we switch gears to start looking at theming. Specifically, we download the Omega theme to create a subtheme theme of our own.
In doing so, we download a few different modules to help out, specifically Omega Tools. The tutorial covers three different methods to create an Omega subtheme for your site; using using Omega Tools, manually creating a subtheme and uploading it and finally, using Omega Tools and Drush via the command line.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/how-create-ubercart-coupons-and-automatic-discounts-ubercart-series-2-tutoria">How to Create Ubercart Coupons and Automatic Discounts - Ubercart...
In this Drupal video tutorial, we install the Ubercart Discount Coupon Module and I show you how to configure it to create general coupons users can use at the checkout, create coupons that are automatically emailed to a user after they purchase a specific product and lastly, to create coupons that are automatically applied to an order based on the number of products in the cart.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/how-bulk-upload-products-uc-feeds-module-ubercart-series-2-tutorial-2">How to Bulk Upload Products with the UC Feeds Module- Ubercart Series #2...
In this Drupal video tutorial, I show you how to bulk import products into Ubercart using the Drupal 7 Feeds Module and UC_Feeds Module.
To do so, we first need to download and install the modules along with Job Scheduler. Then we walk through how to create an Importer and set up an excel spreadsheet, saving it as a CSV file. There are a couple sticking points in the tutorial that I make sure to point out - specifically, how to make sure you images are uploaded properly and how to configure weights in your spreadsheet.
Toronto Website Developer: <h4><a href="http://www.torontowebsitedeveloper.com/drupal-video-tutorials/continuing-your-e-commerce-site-drupal-7-ubercart-1-how-update-drupal">Continuing Your E-Commerce Site with Drupal 7 & Ubercart: 1 - How to Update...
To begin this Drupal video tutorial series on continuing to build your e-commerce site using Drupal and Ubercart, I show you how to update your Drupal site - something I should have covered off before we went live in the first series.
In this tutorial, we begin by putting the site in maintenance mode and then I walk you through three different update methods: updating your site via the website itself using the Update Manager module, manually updating the site by uploading a new version of Drupal core and finally we take a look at Drush and how it can be used to update your Drupal site. Although I mention it a few times in the tutorial, I can't stress enough that you should back up your database and all site files before beginning an update.
The Module Off: New Docs Challenge and Our Last Winner
I was inspired by discussions of Drupal's online documentation on this week's Drupal Easy podcast. The importance of our docs cannot be understated! Thus, our brand new Module Off challenge is centered on Drupal's code docs. Here's the challenge:
Fixing up or adjusting parts of Drupal's code docs is a great way to dip your toe into the wonderfully warm pool of core development. In fact, my first ever core patch was a docs update! It's a great way to learn how to create/submit patches without a deep understanding of the complexities of Drupal's innards. This Module Off challenge asks you to submit a recent commit that you made to help Drupal's core code docs. If you want to make a screencast talking about the process, or showing the code before and after, more power too you! At a bare minimum, to take home this challenge, we'll need a link to the issue, and a brief description of what you did.
Make doc commits all the time? Now's your time to show off! Never worked on core before? Here's your chance to get started. Go to it!
We hope to see some really great submissions! There's an awesomely-free 6-month BuildAModule subscription for the winner!
Previous ChallengeOur last challenge asked you to demonstrate the use of the batch API. Alexander Ross submitted an awesome example of the API's use. If you've never used the Batch API before, the example is amazingly clear, so check it out!
Tags: Drupal PlanetUrban Insight: Los Angeles County Museum of Art Offers 20,000 High Resolution Images
This image, called "Shiva as the Lord of Dance", is one of the more popular images on the Los Angeles County Museum of Art's new Collections website. This image of Shiva is one of 20,000 high-quality images of artwork that the museum has made freely available to download and use as you see fit.