Planet Drupal

Subscribe to Planet Drupal feed - aggregated feeds in category Planet Drupal
Updated: 58 min 51 sec ago

Aten Design Group: How to Easily Create Drupal Views in Code

Wed, 25/03/2015 - 17:32

Just a couple months ago the title of this post would have sounded crazy to me.

For the last several months I've been working on the CINC module as a way to make my work (and yours) with Drupal configuration better: faster, more predictable, more flexible, etc. Views is one of the most complex types of Drupal configuration, and I've been doing a great job of delaying what I saw as a daunting challenge of figuring out how Views should work with CINC. Even a simple Views export makes it clear that as you click around the Views UI, a lot is happening in the code, and it can be difficult to understand what exactly is going on. Here's an example Views export:

$view = new view(); $view->name = 'random_instructor'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'node'; $view->human_name = 'Random Instructor'; $view->core = 7; $view->api_version = '3.0'; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */   /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'none'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'some'; $handler->display->display_options['pager']['options']['items_per_page'] = '1'; $handler->display->display_options['pager']['options']['offset'] = '0'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'node'; /* Sort criterion: Global: Random */ $handler->display->display_options['sorts']['random']['id'] = 'random'; $handler->display->display_options['sorts']['random']['table'] = 'views'; $handler->display->display_options['sorts']['random']['field'] = 'random'; /* Filter criterion: Content: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; $handler->display->display_options['filters']['status']['value'] = 1; $handler->display->display_options['filters']['status']['group'] = 1; /* Filter criterion: Content: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; $handler->display->display_options['filters']['type']['table'] = 'node'; $handler->display->display_options['filters']['type']['field'] = 'type'; $handler->display->display_options['filters']['type']['value'] = array( 'instructor' => 'instructor', );   /* Display: Block */ $handler = $view->new_display('block', 'Block', 'block');

That view shows one random instructor node in a block. And if you read the code for a few minutes, you can probably figure that out. But I don't know anyone who would attempt to write that code from scratch. So the only way to create a view like that is to click around in the Views UI. As impressive as the Views UI is, clicking a dozen times and finding the few options I care about among the dozens I don't is still an incredibly tedious way to say "show one random instructor node in a block." Ideally I would say that with code that looks more like show_one_random_instructor_node_in_a_block(); I should be able to say what I want and move on to thinking about more interesting problems, without slowing down on implementation details for simple needs.

As of the beta 2 release, CINC has Views integration, and it's wonderful. It's not quite as simple as show_one_random_instructor_node_in_a_block(), but here's how I'm currently creating that Views block:

CINC::init('View')->machine_name('random_instructor') ->set('human_name', 'Random Instructor') ->set_row_style('node') ->set_view_mode('teaser') ->add_filter('published') ->add_node_type_filter('instructor') ->limit_items(1) ->add_sort('random') ->add_block_display() ->create();

So far that's only touching a small subset of what Views can do. I'll continue refining CINC Views toward this "say what you want and move on" ideal. But now that it's good enough that I'm personally no longer using Views UI at all, I wanted to invite you to the party.

Writing Views configuration from scratch is no longer daunting, and it will only get easier from here. So try it out and submit your own requests to make it even better.

Categories: Elsewhere

Deeson: My first experience at Drupalcamp

Wed, 25/03/2015 - 16:09

I recently attended my first Drupal camp event.

It was great to experience what I’d always been told about Drupal, that it’s a large and open, but tightly-knit community.

Previously, I have had no contact with the Drupal community. My first observation as I entered was the wide demographic of people using Drupal. I didn't expect to see people of all ages, with a wide range of ability sets and backgrounds from all across the world attending.

Considering I'm fairly new to Drupal, I didn’t feel out of my depth or segregated from the more experienced members of the community. Far from it!

I came out of the event feeling that the community was more than just It felt like a community where everyone is happy to discuss problems and ideas publicly.

This openness is something I feel is unique to Drupal and its events. It was good to feel that there were a broad spectrum of people available to help you and share their wisdom.

I was able to see collective development in practice;  that it’s the community who are the main driver for the CMS.

Unfortunately I was only able to attend on the Saturday, but on that day I wanted to squeeze as much information as I could from those who were more experienced in the CMS.

I made sure I packed my day full of the 45 minute sessions in order to aid my personal development.

Responsive theming and getting started with Foundation 5 - Presenter: Richard Monger

Coming from a primarily back-end development background, I thought it would be useful for me to understand some more of the the front end development tools and responsive theming techniques in Drupal.

Richard explained how having a framework setup would be useful, as it makes it simpler to customise your site.

I had never heard of ‘Foundation 5’ but I have used Bootstrap in previous projects and it had reduced the amount of time and effort required in theming. It appears that they are both fairly similar, however Richard explained that Foundation 5 does have a more lightweight system to Bootstrap.

Richard explained that Grunt can be used to process SASS files and is a way to speed up the work required to develop themes by automating the task of compiling CSS files from SASS files.

I’ve recently been exposed to this in our development team, so it was useful for me to see our practices being used in the wider community.

A colleague of mine at Deeson wrote a blog about how to implement a theme using Grunt, Bootstrap, Compass and SASS with drupal, which can be found here.

He also discussed how to implement responsive theming. You can use @media tags to specify how large you want a screen to be and within that function you insert your styling specifications for that screen size.

How to be a better dev by ignoring the code or consultancy skills 101 - Presenter: Ben Wilding (Cameron and Wilding)

I found this talk very useful as it taught me some interesting consultancy techniques.

It’s easy as a developer to disregard what actually happens before development, so it was certainly a valuable talk for developers like me,to understand how client relationships are initiated and maintained.

Ben showed us a number of valuable consultancy tools, such as questioning a client’s needs by always asking “why?”. He also delved in to to customers’ needs and the importance of identifying the root cause of what needs to be changed.

From a developers point of view, this is a very powerful tool. It helps us to understand a client’s actual needs and avoid questions such as “Can you just…” and “It should do…”. Further, questioning a clients ‘needs’ and ensuring clarity in their requirements is also important.

As a developer or a consultant, you should feel confident to ask them questions and feel confident in your ability to answer theirs.

He also told us that you have to choose the right project to fit the team, and pairing great teams with great clients creates great work. in 2015: What's coming next? - Presenter: Oliver Davies

I attended this talk because I wanted to understand the role of the site in the community, its underlying foundations and also what it had planned for the future.

After some user feedback at Drupalcon Austin, discovered that improvements needed to be made to the site. want to become the home of the Drupal community, to provide learnable, efficient tools and to encourage people to develop themselves, their Drupal proficiency, and careers and to build human connections with the Drupal community.

Oliver described how they plan to meet these objectives. plan to:

  • Make account creation and login much simpler.
  • Improve the user profiles and organisation sites by adding more information about users.
  • Look into a responsive redesign of the mobile website, to make both larger screens and mobile usability simpler.
  • Improve the workflow to improve the level of skill in new contributors.
  • Make improvements to the search functionality, making it possible to gain information more easily and identify if a module is worth using on their site.

These improvements will allow us as developers to speed up development and help to get more involved in the Drupal community by making the site easier to use and improving the tools so that I can get the best out of drupal.

At the end of the presentation, a few people stated that they used Google and Github to search for and download modules and that this shouldn't be the case. They believed should be the hub of Drupal. Oliver agreed and stated that this is one of the issues that they wanted to address.

Save time and use panels - Presenter: Alex Burrows

During this talk, Alex described how ‘Panels’ is implemented in a Drupal site, and gave us a demo to show how it is configured.

I didn’t realise how powerful Panels is and I was surprised at how much you can do with it. Panels is a layout manager similar to Context and Display Suite. All three can be used individually or they can all be used together to create a more complex site layout.

Alex explained how, in Panels, a client can use the in-place editor and move content around to fit their specifications. Variants can be used in order to set up a variation of the same page, and selection rules are used for displaying panels on specific pages.

You can also use Panelizer to set the configurations of panels node by node.

Improving the CMS user experience - Presenter: Paul Rowell

This talk was particularly useful for me because it gave me the opportunity to seek new modules, expanding my knowledge base and helping find a module that will serve a clients needs better in different situations.

Paul talked to us about how the user is the one who is often wrongly forgotten by developers, often left with tools that are too basic to manage their site.

Paul then discussed various modules to aid user experience such as Adminimal and Navbar for navigating around the site, giving a cleaner looking site than the default Drupal setup. He also discussed a few modules to aid content management, such as Workbench for displaying content overviews and Workbench moderation for revisioning.

Paul went on to talk about a few modules to be used for file management such as the Media module which enables users to upload once and then manage the files throughout the site.

Finally, Paul discussed options to aid UX on fields such as term reference tree for select lists, focal point for image cropping and Help text for adding helpful text to users about what text to add into a form.

At the end of this talk, people shared their own experiences with modules that they had found useful for aiding user experience. This gave me further insight into the Drupal community and proved the shared nature of its infrastructure.

My experience at Drupalcamp 2015 gave me a good understanding of the Drupal community and was testament to the fact that it is a highly dedicated community based on sharing both tools and knowledge. I believe that this is one of the most important factors of Drupal that makes it as popular and as exciting as it is, and is certainly one of its largest selling points. Drupal camp was highly beneficial to my development, and I was glad that I took the opportunity to see for myself what the Drupal community offered.

Categories: Elsewhere

Lullabot: DrupalCon 2015: Lullabot Sessions

Wed, 25/03/2015 - 15:54
*/ /*-->*/

This year we have a variety of presentations for you at DrupalCon LA. These all come out of the hard work we're doing all year round on projects such as Tesla, Syfy, SNL, NBC, Bravo (to name a few), and also within the Drupal community.

Categories: Elsewhere

Drupal Association News: 2015 At-Large Board Elections Announced

Wed, 25/03/2015 - 15:00

Everyone on the staff and Board of the Drupal Association would like to congratulate our newest board member:

Addison Berry.

In addition to congratulating Addison, please join me in thanking the 23 other candidates who put themselves out there in service of Drupal and stood for election. 

This was the fourth election we've held for At-Large board seats at the Drupal Association. This year we had two specific goals for the elections:

  • Increase the diversity of the candidates - Although we only had one female candidate, we saw great success by other measures of diversity. 24 candidates came from 14 different countries - including South American and Asian countries. 
  • Increase voter turnout - We fielded 1,432 votes in this election. Our pool of eligible voters was 159,758, so that means our voter tunrout was .89%. This is still low, but a vast improvement over the last election, which saw a .36% turnout. 

Our next steps will be to reach out to the candidates for their evaluation of the elections experience. We also want to hear from you. Please tell us about your experience with the elections process in the comments below so that we can include them in our planning for the 2016 elections.

Flickr photo: Kodak Views

Categories: Elsewhere

KnackForge: PDOException - SQLSTATE[22003] - Numeric value out of range

Wed, 25/03/2015 - 10:20
This blog describes how to solve PDOException - SQLSTATE[22003] - Numeric value out of range: 1264 Out of range. When you try to store large integer value in 'integer' field type, then you will get this error. It is because the maximum value of 'integer' field type is exceeded.  For example, you want to store phone number in a content type. Then you may create new field with 'integer' field type in the content type. When you store 10 digit phone number in this field, "PDOException error" will be shown. MySQL allows you to store values from -2147483648 to 2147483647 in integer field type if signed, so you can't store phone number in 'integer' field type. MySQL allocates 4 bytes for 'integer' field type ie., 4 bytes = 4 x 8 = 32 bits 2^32 => 4294967296 values 2^32 - 1 => 4294967295 (if unsigned, 0 to 4294967295 values) -2^(32 - 1) to (2^(32 - 1) - 1) => -2147483648 to 2147483647 (if signed, -2147483648 to 2147483647 values). If you want to store large integer value, then you need to use field type either 'bigint' or 'text field'. If you choose 'bigint', then there is no need to add custom validation for phone number field. On the other hand, if you choose 'text field' then you need to add custom validation using either hook_form_alter() or hook_form_form_id_alter(). <?php /** * Implement hook_form_alter() */ function kf_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'your_form_id') {
Categories: Elsewhere

KnackForge: Drupal - Updating File name

Wed, 25/03/2015 - 08:45

If you know the file id, it is really simple,

$file = file_load($fid); file_move($file, 'public://new_file_name);

How it works:

We need a source file object to move file to the new location and update the files database entry. Moving a file is performed by copying the file to the new location and then deleting the original. To get source file object, we can use file_load() function.
file_load($fid) - loads a single file object from the database
$fid - file id
return object representing the file, or FALSE if the file was not found.

After that, we can use file_move() function to move the file new location and delete the original file..

file_move($file, 'public://new_file_name)

Parameter1 - Source File Object
Parameter2 - A string containing the destination that $source should be moved to. This must be a stream wrapper URI.
Parameter3 - Replace behaviour (Default value : FILE_EXISTS_RENAME)

For more details, check here.

Categories: Elsewhere

Kristian Polso: My talk on Drupal security in Drupal Days Milan

Wed, 25/03/2015 - 08:06
So I just came back from European Drupal Days in Milan. I had great fun at the event, it was well organized and filled with interesting talks. I'll be sure to attend it next year too!
Categories: Elsewhere

ThinkShout: The How and Why of Nonprofits Contributing to Open Source

Wed, 25/03/2015 - 01:00

Originally published on February 23rd, 2015 on Republished with permission.

For the last 15 years or so, we’ve seen consistent growth in nonprofits’ appreciation for how open source tools can support their goals for online engagement. Rarely do we run across an RFP for a nonprofit website redesign that doesn’t specify either Drupal or WordPress as the preferred CMS platform. The immediate benefits of implementing an open source solution are pretty clear:

  • With open source tools, organizations avoid costly licensing fees.

  • Open source tools are generally easier to customize.

  • Open source tools often have stronger and more diverse vendor/support options.

  • Open source platforms are often better suited for integration with other tools and services.

The list goes on… And without going down a rabbit hole, I’ll simply throw out that the benefits of open source go well beyond content management use cases these days.

But the benefits of nonprofits supporting and contributing to these open source projects and communities are a little less obvious, and sometimes less immediate. While our customers generally appreciate the contributions we make to the larger community in solving their specific problems, we still often get asked the following in the sales cycle:

"So let me get this straight: First you want me to pay you to build my organization a website. Then you want me to pay you to give away everything you built for us to other organizations, many of whom we compete with for eyeballs and donations?"

This is a legitimate question! One of the additional benefits of using an open source solution is that you get a lot of functionality "for free." You can save budget over building entirely custom solutions with open source because they offer so much functionality out of the box. So, presumably, some of that saving could be lost if additional budget is spent on releasing code to the larger community.

There are many other arguments against open sourcing. Some organizations think that exposing the tools that underpin their website is a security risk. Others worry that if they open source their solutions, the larger community will change the direction of projects they support and rely upon. But most of the time, it comes down to that first argument:

"We know our organization benefits from open source, but we’re not in a position to give back financially or in terms of our time."

Again, this is an understandable concern, but one that can be mitigated pretty easily with proper planning, good project management, and sound and sustainable engineering practices.

Debunking the Myths of Contributing to Open Source

Myth #1: "Open sourcing components of our website is a security risk."

Not really true. Presumably the concern here is that if a would-be hacker were to see the code that underlies parts of your website, they could exploit security holes in that code. While yes, that could happen, the chances are that working with a software developer who has a strong reputation for contributing to an open source project is pretty safe. More importantly, most strong open source communities, such as the Drupal community, have dedicated security teams and thousands of developers who actively review and report issues that could compromise the security of these contributions. In our experience, unreviewed code and code developed by engineers working in isolation are much more likely to present security risks. And on the off chance that someone in the community does report a security issue, more often than not, the reporter will work with you, for free, to come up with a security patch that fixes the issue.

Myth #2: "If we give away our code, we are giving away our organization’s competitive advantage."

As a software vendor that’s given away code that powers over 45,000 Drupal websites, we can say with confidence: there is no secret sauce. Trust me, all of our competitors use Drupal modules that we’ve released - and vice versa.

By leveraging open source tools, your organization can take advantage of being part of a larger community of practice. And frankly, if your organization is trying to do something new, something that’s not supported by such a community, giving away tools is a great way to build a community around your ideas.

We’ve seen many examples of this. Four years ago, we helped a local nonprofit implement a robust mobile mapping solution on top of the Leaflet Javascript library. At the time, there wasn’t an integration for this library and Drupal. So, as part of this project we asked the client invest 20 hours or so for us release the barebones scaffolding of their mapping tool as a contributed Drupal module.

At first, this contributed module was simply a developer tool. It didn’t have an interface allowing Drupal site builders to use it. It just provided an easier starting point for custom map development. However, this 20 hour starting point lowered the cost for us to build mapping solutions for other clients, who also pitched in a little extra development time here and there to the open source project. Within a few months, the Leaflet module gained enough momentum that other developers from other shops started giving back. Now the module is leveraged on over 5,700 websites and has been supported by code contributions from 37 Drupal developers.

What did that first nonprofit and the other handful of early adopters get for supporting the initial release? Within less than a year of initially contributing to this Drupal module, they opened the door to many tens of thousands of dollars worth of free enhancements to their website and mapping tools.

Did they lose their competitive advantage or the uniqueness of their implementation of these online maps? I think you know what I’m gonna say: No! In fact, the usefulness of their mapping interfaces improved dramatically as those of us with an interest in these tools collaborated and iterated on each other’s ideas and design patterns.

Myth #3: "Contributing to an open source project will take time and money away from solving our organization’s specific problems."

This perception may or may not be true, depending on some of the specifics of the problems your organization is trying to solve. More importantly, this depends upon the approach you use to contribute to an open source project. We’ve definitely seen organizations get buried in the weeds of trying to do things in an open source way. We’ve seen organizations contribute financially to open source projects on spec (on speculation that the project will succeed). This can present challenges. We’ve also seen vendors try to abstract too much of what they’re building for clients up front, and that can lead to problems as well.

Generally, our preferred approach is generally to solve our clients immediate problems first, and then abstract useful bits that can be reused by the community towards the end of the project. There are situations when the abstraction, or the open source contribution, needs to come first. But for the most part, we encourage our clients to solve their own problems first, and in so doing so provide real-life use cases for the solutions that they open source. Then, abstraction can happen later as a way of future-proofing their investment.

Myth #4: "If we open source our tools, we’ll lose control over the direction of the technologies in which we’ve invested."

Don’t worry, this isn’t true! In fact:

Contributing to an open source project is positively selfish.

By this I mean that by contributing to an open source project, your organization actually gets to have a stronger say in the direction of that project. Most open source communities are guided by those that just get up and do, rather than by committee or council.

Our team loves the fact that so many organizations leverage our Drupal modules to meet their own needs. It’s great showing up at nonprofit technology conferences and having folks come up to us to thank us for our contributions. But what’s even better is knowing that these projects have been guided by the direct business needs of our nonprofit clients.

How to Go About Contributing to Open Source

There are a number of ways that your nonprofit organization can contribute to open source. In most of the examples above, we speak to financial contributions towards the release of open source code. Those are obviously great, but meaningful community contributions can start much smaller:

  • Participate in an open source community event. By engaging with other organizations with similar needs, you can help guide the conversation regarding how a platform like Drupal can support your organization’s needs. Events like Drupal Day at the NTC are a great place to start.

  • Host a code sprint or hackathon. Sometimes developers just need a space to hack on stuff. You’d be surprised at the meaningful that connections and support that can come from just coordinating a local hackathon. One of our clients, Feeding Texas, recently took this idea further and hosted a dedicated sprint on a hunger mapping project called SNAPshot Texas. As part of this sprint, four developers volunteered a weekend to helping Feeding Texas build a data visualization of Food Stamp data across the state. This effort built upon the work of Feeding America volunteers across the country and became a cornerstone of our redesign of Feeding Texas believes so strongly in the benefits they received from this work that they felt comfortable open sourcing their entire website on GitHub.

Of course, if your organization is considering a more direct contribution to an open source project, for example, by releasing a module as part of a website redesign, we have some advice for you as well:

  • First and foremost, solve your organization’s immediate problems first. As mentioned earlier in the article, the failure of many open source projects is that their sponsors have to handle too many use cases all at once. Rest assured that if you solve your organization’s problems, you’re likely to create something that’s useful to others. Not every contribution needs to solve every problem.

  • Know when to start with abstraction vs. when to end with abstraction. We have been involved in client-driven open source projects, such as the release of RedHen Raiser, a peer-to-peer fundraising platform, for which the open source contribution needed to be made first, before addressing our client’s specific requirements. In the case of RedHen Raiser, the Capital Area Food Bank of Washington, DC came to us with a need for a Drupal-based peer-to-peer fundraising solution. Learning that nothing like that existed, they were excited to help us get something started that they could then leverage. In this case, starting with abstraction made the most sense, given the technical complexities of releasing such a tool on Drupal. However, for the most part, the majority of open source contributions come from easy wins that are abstracted after the fact. Of course, there’s no hard and fast rule about this - it’s just something that you need to consider.

  • Celebrate your contributions and the development team! It might sound silly, but many software nerds take great pride in just knowing that the stuff they build is going to be seen by their peers. By offering to open source even just small components of your project, you are more likely to motivate your development partners. They will generally work harder and do better work, which again adds immediate value to your project.

In conclusion, I hope that this article helps you better understand that there’s a lot of value in contributing to open source. It doesn’t have to be that daunting of an effort and it doesn’t have to take you off task.

Categories: Elsewhere Using Dev Desktop with Composer Drush

Wed, 25/03/2015 - 00:55

Before recently settling into the path of using Vagrant + Ansible for site development (speaking of Ansible: I absolutely love it and need to blog about some of my fun with that), I had been using Acquia Dev Desktop. Even now, I'll use it from time to time since it is easy to work with.

planet drupaldrush
Categories: Elsewhere

Web Wash: Define Custom Validation using Field Validation in Drupal 7

Tue, 24/03/2015 - 22:45

Out of the box, Drupal offers only a single type of validation for fields; required or not required. For most use cases this is fine, however, it can be a little difficult to define your own custom validation logic. What if you need to validate a field value and make sure it's unique?

The Field validation module allows you to define custom validation rules using Drupal's administration interface. The module ships with a lot of its own validators: "Plain text", "Specific value(s)" and much more.

If none of the validators meet your requirement, you can write your own by implementing a validator plugin. Because validators are Ctools plugin, they are easy to maintain as each one gets its own file.

In this tutorial, we'll use Field validation to validate a field value and make sure it's unique.

Categories: Elsewhere

Web Wash: Define Custom Validation using Field Validation in Drupal 7

Tue, 24/03/2015 - 22:45

Out of the box, Drupal offers only a single type of validation for fields; required or not required. For most use cases this is fine, however, it can be a little difficult to define your own custom validation logic. What if you need to validate a field value and make sure it's unique?

The Field validation module allows you to define custom validation rules using Drupal's administration interface. The module ships with a lot of its own validators: "Plain text", "Specific value(s)" and much more.

If none of the validators meet your requirement, you can write your own by implementing a validator plugin. Because validators are Ctools plugin, they are easy to maintain as each one gets its own file.

In this tutorial, we'll use Field validation to validate a field value and make sure it's unique.

Categories: Elsewhere

Drupal for Government: Drupal, Tableau, and Media Tableau

Tue, 24/03/2015 - 20:31

Tableau is a helluva tool.  For data visualization it is at the top of its game... we recently had a 3 day seminar at UVa regarding Tableau, and I was stoked to see that they use Drupal heavily for their portal design.  

While I don't have the $$'s to run Tableau Server right now, it's a cool tool and something to consider...  Anyhow - here's a quick look at Tableau + Drupal + media tableau.  The upshot is that by integrating at the database level you can use views to display all of your workbooks... if all you want is to embed some visualizations in your content this isn't necessary as tableau provides iFrames for workbooks too... to use that just install media tableau, integrate with your wysiwyg editor of choice and move on... I wanted to test it all, so here's the kitchen sink :)

Here are the steps I've taken for the complete integration with views etc... if you just want to embed some tableau views in drupal skip down a bit :)

Categories: Elsewhere

Lullabot: Paying It Forward: Drupal 8 Accelerate

Tue, 24/03/2015 - 19:00

Have you heard about the Drupal 8 Accelerate fund? The Drupal Association is collaborating with Drupal 8 branch maintainers to provide grants for those actively working on Drupal 8, with the goal of accelerating its release.

Categories: Elsewhere

Mediacurrent: A Comparison of Drupal 7 Image Caption Methods using WYSIWYG Module with CKEditor

Tue, 24/03/2015 - 18:18

I recently had the opportunity to explore popular methods of adding captions to images inside the WYSIWYG editor using the setup of WYSIWYG module with CKEditor library. Our two main criteria were Media module integration and a styled caption in the WYSIWYG editor. As I discovered, we couldn’t have both without custom coding which the budget didn’t allow for. Media module integration won out and the File Entity with View Modes method was chosen. 

The modules/methods I reviewed were:

Categories: Elsewhere

Daniel Pocock: The easiest way to run your own OpenID?

Tue, 24/03/2015 - 17:57

A few years ago, I was looking for a quick and easy way to run OpenID on a small web server.

A range of solutions were available but some appeared to be slightly more demanding than what I would like. For example, one solution required a servlet container such as Tomcat and another one required some manual configuration of Python with Apache.

I came across the SimpleID project. As the name implies, it is simple. It is written in PHP and works with the Apache/PHP environment on just about any Linux web server. It allows you to write your own plugin for a user/password database or just use flat files to get up and running quickly with no database at all.

This seemed like the level of simplicity I was hoping for so I created the Debian package of SimpleID. SimpleID is also available in Ubuntu.

Help needed

Thanks to a contribution from Jean-Michel Nirgal Vourgère, I've just whipped up a 0.8.1-14 package that should fix Apache 2.4 support in jessie. I also cleaned up a documentation bug and the control file URLs.

Nonetheless, it may be helpful to get feedback from other members of the community about the future of this package:

  • Is it considered secure enough?
  • Have other people found it relatively simple to install or was I just lucky when I tried it?
  • Are there other packages that now offer such a simple way to get OpenID for a vanilla Apache/PHP environment?
  • Would anybody else be interested in helping to maintain this package?
  • Would anybody like to see this packaged in other distributions such as Fedora?
  • Is anybody using it for any online community?
Works with HOTP one-time-passwords and LDAP servers

One reason I chose SimpleID is because of dynalogin, the two-factor authentication framework. I wanted a quick and easy way to use OTP with OpenID so I created the SimpleID plugin for dynalogin, also available as a package.

I also created the LDAP backend for SimpleID, that is available as a package too.

Works with Drupal

I tested SimpleID for login to a Drupal account when the OpenID support is enabled in Drupal, it worked seamlessly. I've also tested it with a few public web sites that support OpenID.

Categories: Elsewhere

Drupal core announcements: Drupal 8 beta 8 TOMORROW on Wednesday, March 25, 2015

Tue, 24/03/2015 - 17:24

The next beta for Drupal 8 will be beta 8! Here is the schedule for the beta release.

Wednesday, March 25, 2015 Drupal 8.0.0-beta8 released. Emergency commits only.
Categories: Elsewhere

Nuvole: A pluggable field-handling system for the Behat Drupal Extension

Tue, 24/03/2015 - 17:15
Write more complete Behat test scenarios for both Drupal 7 and Drupal 8.

On of the main goal of BDD (Behaviour Driven Development) is to be able to describe a system's behavior using a single notation, in order to be directly accessible by product owners and developers and testable using automatic conversion tools.

In the PHP world, Behat is the tool of choice. Behat allows to write test scenarios using Gherkin step definitions and it generates the corresponding PHP code to actually run and test the defined scenarios.

Thanks to the excellent Behat Drupal Extension Drupal developers have been able to enjoy the benefits of Behavioral Driven Development for quite some time.

Essentially the project provides an integration between Drupal and Behat allowing the usage of Drupal-specific Gherkin step definitions. For example, writing a scenario that tests node authorship would look like:

Scenario: Create nodes with specific authorship
  Given users:
  | name     | mail            | status |
  | Joe User | | 1      |
  And "article" content:
  | title          | author   | body             |
  | Article by Joe | Joe User | PLACEHOLDER BODY |
  When I am logged in as a user with the "administrator" role
  And I am on the homepage
  And I follow "Article by Joe"
  Then I should see the link "Joe User" Dealing with complex content types

The Gherkin scenario above is pretty straightforward and it gets the job done for simple cases. In a real-life situation, though, it's very common to have content types with a high number of fields, often of different types and, possibly, referencing other entities.

The following scenario might be a much more common situation for a Drupal developer:

Scenario: Reference site pages from within a "Post" node
  Given "page" content:
    | title      |
    | Page one   |
    | Page two   |
    | Page three |
  When I am viewing a "post" content:
    | title                | Post title         |
    | body                 | PLACEHOLDER BODY   |
    | field_post_reference | Page one, Page two |
  Then I should see "Page one"
  And I should see "Page two"

While it is always possible to implement project specific step-definition, as show on this Gist dealing with field collections and entity references, having to do that for every specific content type might be an unnecessary burden.

Introducing field-handling for the Behat Drupal Extension

Nuvole recently contributed a field-handling system that would allow the scenario above to be ran out of the box, without having to implement any custom step definition, working both in Drupal 7 and Drupal 8. The idea behind it is to allow a Drupal developer to work with fields when writing Behat test scenarios, regardless of the entity type or of any field-specific implementation.

The code is currently available on the master branches of both the Behat Drupal Extension and the Drupal Driver projects, if you want to try it out follow the instructions at "Stand-alone installation" and make sure to grab the right code by specifying the right package versions in your composer.json file:

  "require": {
    "drupal/drupal-extension": "3.0.*@dev",
    "drupal/drupal-driver": "1.1.*@dev"

The field-handling system provides an integration with several highly-used field types, like:

Date fields

Date field values can be included in a test scenario by using the following notation:

  • Single date field value can be expressed as 2015-02-08 17:45:00
  • Start and end date are separated by a dash -, for ex. 2015-02-08 17:45:00 - 2015-02-08 19:45:00.
  • Multiple date field values are separated by a comma ,

For example, the following Gherkin notation will create a node with 3 date fields:

When I am viewing a "post" content:
  | title       | Post title                                |
  | field_date1 | 2015-02-08 17:45:00                       |
  | field_date2 | 2015-02-08 17:45:00, 2015-02-09 17:45:00  |
  | field_date3 | 2015-02-08 17:45:00 - 2015-02-08 19:45:00 | Entity reference fields

Entity reference field values can be expressed by simply specifying the referenced entity's label field (e.g. the node's title or the term's name). Such an approach wants to keep up with BDD's promise: i.e. describing the system behavior by abstracting, as much as possible, any internal implementation.

For example, to reference to a content item with title "Page one" we can simply write:

When I am viewing a "post" content:
  | title           | Post title |
  | field_reference | Page one   |

Or, in case of multiple fields, titles will be separated by a comma:

When I am viewing a "post" content:
  | title           | Post title         |
  | field_reference | Page one, Page two | Link fields

A Link field in Drupal offers quite a wide range of options, such as an optional link title or internal/external URLs. We can use the following notation to work with links in our test scenarios:

When I am viewing a "post" content:
  | title       | Post title                                              |
  | field_link1 |                                       |
  | field_link2 | Link 1 -                              |
  | field_link3 | Link 1 -, Link 2 - |

As you can see we use always the same pattern: a dash - to separate parts of the same field value and a comma , to separate multiple field values.

Text fields with "Select" widget

We can also refer to a select list value by simply referring to its label, so to have much more readable test scenarios. For example, given the following allowed values for a select field:

option1|Single room
option2|Twin room
option3|Double room

In our test scenario, we can simply write:

When I am viewing a "post" content:
  | title      | Post title               |
  | field_room | Single room, Double room | Working with other entity types

Field-handling works with other entity types too, such as users and taxonomy terms. We can easily have a scenario that would create a bunch of users with their relative fields by writing:

Given users:
  | name    | mail                | language | field_name | field_surname | field_country  |
  | antonio | | it       | Antonio    | De Marco      | Belgium        |
  | andrea  |  | it       | Andrea     | Pescetti      | Italy          |
  | fabian  |  | de       | Fabian     | Bircher       | Czech Republic | Contributing to the project

At the moment field-handling is still a work in progress and, while it does support both Drupal 7 and Drupal 8, it covers only a limited set of field types, such as:

  • Simple text fields
  • Date fields
  • Entity reference fields
  • Link fields
  • List text fields
  • Taxonomy term reference fields

If you want to contribute to the project by providing additional field type handlers you will need to implement this very simple, core-agnostic, interface:

namespace Drupal\Driver\Fields;

* Interface FieldHandlerInterface
* @package Drupal\Driver\Fields
interface FieldHandlerInterface {

   * Expand raw field values in a format compatible with entity_save().
   * @param $values
   *    Raw field values array.
   * @return array
   *    Expanded field values array.
  public function expand($values);

If you need some inspiration check the current handlers implementation by inspecting classes namespaced as \Drupal\Driver\Fields\Drupal7 and \Drupal\Driver\Fields\Drupal8.

Tags: Drupal PlanetTest Driven DevelopmentBehat
Categories: Elsewhere Drupal Blog: Wordpress, Drupal and SEO.

Tue, 24/03/2015 - 17:00

Something that’s seen a resurgence of late is the importance of SEO and site/page ranking (though if your job revolves around content, you’d probably say it never left). It seems like after the initial crush of SEO and SEO specialists in the early-ish days of the web, things like backlink ranking, metadata, alt tags and all those other accessibility tools went the way of the dodo. Gone were the days where people massaged their content to smash in as many keywords as possible, where SEO specialists were getting paid obscene amounts of money to add in <meta> data into your html templates. Design reigned supreme.

But with the sheer amount of information available online, there remains a pressing and consistent need to ensure that your site rises above the fray; you want to be the expert, the forum for discussion, the end-all-be-all. So you’ve put together that lovely little site with the cool hamburger nav, the beautifully optimized content, the frequently updated blog and news sections--what’s next?

One of the key tools that people don’t really use is Google analytics; sure, everyone’s got that tracking code embedded in their templates or footer, and every so often, you’ll go in there and take a look at the cool line graph that tells you...well, nothing really. If you dig deeper into GA, you get an awesome picture of where, when, how, and even why people are visiting your site. You can see which content people like, which content is shared and liked, how often and by whom.

So that’s step one: Use GA to it’s full potential.

They have enough tools to make you cry, but if you make the effort to wade through them, you can tailor it to not only fit your content or website better, you can also make website a better fit for the web itself. Both Drupal and Wordpress make it so easy to add in the GA tracking code that there’s really no excuse to not have it up and running, secreting away all those squirrely little details Google is so fond of.

But more importantly, on the subject of tools, is a wonderful little plugin for Wordpress called Yoast. If you’ve worked with WP, have a WP site, or even browse the internet, you’ve probably heard of this plugin, and for good’s stunningly easy to setup and use. It tells you what pages are awful, how many keywords you’re missing, when your content is poorly optimized, when your images don’t have tags and text, and a number of other issues that take the best stab at Google’s inscrutable SEO rules/ranking criteria as you can get. This plugin is so ubiquitous as to be almost mandatory if you care at all about getting your website seen--the makers claim that Yoast has been downloaded almost 15 million times. So what’s the option for Drupal?

The short answer is, there isn’t one.

Sure, when it comes down to it, you have the same options as WP sites--being customizable is, after all, kind of Drupal’s thing. You can edit your templates to add in your markup, you can install dozens of modules (XML sitemap, pathauto, Google analytics, redirect, metatag, token, page title, SEO checker, SEO checklist...and the list goes on), and you’ll eventually get the same functionality as one WP plugin that takes literally two minutes to add and install. And that’s including the time it takes to actually FTP in.

And I suppose this all fits in with Drupal’s more...Drupal-y...audience. It’s open source--you’re expected to code, to configure, to muck, to install and extend. It’s just one of those things where you shouldn’t have to install so many different, specialized modules to get the functionality you need to optimize. Sure-- there’s even a module called SEO Tools -- but it has a list of 18 additional “recommended/required modules,” and all that gets you is a screen that looks remarkably like the Google analytics dashboard.

I hesitate to use the word “lazy,” when what I really mean is “efficient,” or the even more adept “optimized,” but really--you just spent weeks/months and thousands of dollars getting a site up and running, UX’d, designed, sprinted and agile-d. The final step, the key step to actually getting your site seen, should not be a massive, dozen-module installing, template editing undertaking.

Obviously, the SEO ideal for a fresh or redesigned Drupal site is a thorough and well-planned strategy phase, and if there’s time, budget, interest (and willpower) to structure your content around key SEO strategies, it’s perfect. But if you’ve ever worked on websites, you know that sometimes you just need something that works well out of the box.

WP has Yoast. Where’s Drupal’s “something?” Consider the gauntlet thrown.

Categories: Elsewhere

Drupal Easy: Book Review: Drush for Developers (Second Edition)

Tue, 24/03/2015 - 14:48

Calling this book a "second edition" is more than a little bit curious, since there is no Drush for Developers (First Edition). I can only assume that the publisher considers Juampy's excellent Drush User's Guide (reviewed here) as the "first edition" of Drush for Developers (Second Edition), but that really minimzes ths book, as it is so much more than an updated version of Drush User's Guide. It would be like saying The Godfather, Part 2 is an updated version of The Godfather - which is just crazy talk. Drush Developer's Guide is more of a sequel - and (like The Godfather, Part 2) a darn good one at that.


read more

Categories: Elsewhere

Drupalize.Me: Tutorial: Vagrant Drupal 8 Development

Tue, 24/03/2015 - 14:04

Vagrant Drupal Development (VDD) is a ready-to-use development environment using a virtual machine. Why use it? It provides a standard hosting setup, contained in a virtual machine, for developing with Drupal. This allows you to get up and running really, really quickly, without knowing anything about server administration.

Categories: Elsewhere