Subscribe to feed Planet Drupal
Drupal.org - aggregated feeds in category Planet Drupal
Bijgewerkt: 52 min 6 sec geleden

Web Wash: Build a Blog in Drupal 8: Managing Blocks

di, 2015/10/20 - 10:26pm

The Block system in Drupal allows you to add arbitrary content into regions within a theme. A block could be as simple as just text or list content using Views.

In Drupal 7, the Block system is pretty limiting. For instance, a single block can only be assigned to a single region. You also have very basic control of hiding and displaying blocks.

To handle these short comings in Drupal 7 you would use Panels for complex layouts and Bean so you can add fields to blocks.

In Drupal 8, the Block system has been revamped and it's more flexible. The two big improvements: assign a single block to multiple regions and fieldable block types.

In this tutorial, we'll continue work on our Drupal 8 blog site. We'll add a static call-to-action which'll only appear in the sidebar on the blog page. This call-to-action could be some promotional content or a newsletter sign-up form.

Then we'll create a custom block type which we'll use to create reusable promotional content that can be added to any blog post.

Categorieën:

Evolving Web: Node smuggling, aka poor man's node_export

di, 2015/10/20 - 9:09pm

I needed to create a new webform on a production site recently. But as a dev, I don't have direct access to the production admin backend; I'm only allowed to push code changes and let the client's team migrate them to prod via drush updb. So I'm supposed to export the webform configuration to code, and deploy it via an update hook, but how?

read more
Categorieën:

Aten Design Group: Drupal 8: Programatically Adding a Views Footer

di, 2015/10/20 - 8:00pm

Recently, I needed to add some dynamic content to a Views footer. Specifically, I needed to change a link in the Views footer based on the current path, which isn’t an option from the Views UI. I found some good documentation showing how this can be done in older versions of Drupal (https://www.drupal.org/node/749452), but nothing for Drupal 8. I figured the approach must be similar in Drupal 8 so I started searching and reverse engineering.

First, I added a footer directly through the Views UI and exported my sites configuration using Drupal 8’s configuration management tools. Finding the footer in the exported YAML file provided some valuable insight on how I might add the footer programmatically.

Views Footer as found in the YAML export: footer: area_text_custom: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: '' empty: false tokenize: false content: Footer content is great plugin_id: text_custom

The YAML Views export provided the settings I needed to add the footer, but I also needed to figure out the right place to do it in code. If you are familiar with Views hooks, then you know there are a ton of them and sometimes finding the right one to use is a bit of trial and error. Since some of the Drupal 7 examples I found used function hook_views_pre_view(), I started with that hook. Using the Devel module, a great option for debugging in Drupal, and its dpm() function, I inspected the $view object. In Drupal 8, dpm() shows the available methods for an object. With a little bit of guesswork, the setHandler method seemed like the correct choice.

Output from the dpm() function.

I was able to add a Views footer with some code in a custom module: use Drupal\views\ViewExecutable; function YOURMODULENAME_views_pre_view(ViewExecutable $view, $display_id, array &$args) { if ($view->id() == 'view_machine_name' && $display_id === 'view_display') { $options = array( 'id' => 'area_text_custom', 'table' => 'views', 'field' => 'area_text_custom', 'relationship' => 'none', 'group_type' => 'none', 'admin_label' => '', 'empty' => TRUE, 'tokenize' => FALSE, 'content' => ‘Footer content is great.’, 'plugin_id' => 'text_custom', ); $view->setHandler('view_display', 'footer', 'area_text_custom', $options); } }

One piece of the Drupal 8 Views module has been solved!

Categorieën:

David Lohmeyer's Blog: How to make custom Guzzle requests in Drupal 8 modules

di, 2015/10/20 - 7:27pm

If you're sending a request to a custom URL in Drupal 8, you might be tempted to implement a solution using cURL or another library. However, Drupal core comes with Guzzle, a "PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services." As with most things in Drupal, it's not obvious how to use something immediately, so here's a demo to show you how to take care of sending a request to an arbitrary URL inside a custom Drupal module. You might use this example class to display a status code on some page.

Categorieën:

Acquia Developer Center Blog: Creating Adaptable Content with Drupal 8

di, 2015/10/20 - 7:25pm

Not long ago, the only way content was delivered to you from the Web was via Web pages. You typed something into a browser and a server returned a page of information.

This singular method, however, has become outdated and no longer represents all the ways you and your applications are accessing content from the Web.

Tags: acquia drupal planet
Categorieën:

Drupal Association News: Cathy Theys: Innaugural Aaron Winborn Award Winner

di, 2015/10/20 - 7:10pm

Earlier this year the Drupal community lost one of our most porlific community members, Aaron Winborn. In addition to the code that Aaron contributed, he was a friend to everyone he met in the Drupal community. Aaron was the epitome of our unoffical motto: "Come for the code, stay for the community." To honor Aaron's memory, the Community Working Group, with the support of the Drupal Association, established the Aaron Winborn Award, to be given annually.

The Community Working Group accepted nominations over the spring and summer, with community members nominating dozens of their colleagues who represent the integrity, kindness and commitment to the Drupal community that Aaron did. From these nominations, the Community Working Group members and Hans Riemenschneider (who originated the idea) selected our innaugural winner: Cathy Theys

It's hard to imagine that there is anyone in the community who has not crossed paths with Cathy. She has been a champion for new contributors for as long as I have been part of Drupal, hosting office hours in IRC and helping to coordinate mentors at every DrupalCon sprint and beyond. She has personally sat by my side and used the socratic method to talk me through Git commands. She is a model of generosity and curiosity, and is a tremendous asset to the Drupal Community.

Cathy's reward is a scholarship and stipend to attend DrupalCon next year, as well as a very lovely Drupal trophy. We got the the chance to celebrate Cathy's award on stage at DrupalCon Barcelona, but I hope you will join me in congratulating her again now.

Categorieën:

Drupal Watchdog: Content Workflow Basics in Drupal 7

di, 2015/10/20 - 6:07pm
Article

Organizations of all types need the ability for individuals and teams to be able to create new online content and modify existing content, submit those changes for approval, approve or disapprove that work, and ensure that all the participants in the workflow can see the status of each piece of content in the system and be promptly notified if they must act upon it, to keep the process flowing smoothly. Drupal 7 is ideally suited as a framework for building a website that can support such a workflow setup – with numerous pertinent modules that operate well together.

We will examine some key modules for building this sort of website, as well as how to configure them and set permissions for some basic types of roles invariably employed in such workflows. Our goal is to set up the system so that the mechanics of the workflow are as automated as possible, but with a minimum of complexity.

The Usual Suspects

There are innumerable core and contributed modules that can be employed for crafting an effective workflow, and they tend to be grouped into three categories corresponding to different strategies for implementing whatever type of workflow is desired: Revisioning, Workbench Moderation, and the venerable Workflow.

Choosing one strategy does not preclude using modules geared toward another strategy. Here we will be using the Workflow approach, but it is good to be aware of the Revisioning module – which allows permitted users to create, moderate, and publish content revisions – and Workbench Moderation – a popular alternative which permits moderation down to the revision level.

For any basic content editing and publication system, the following modules can be utilized in some combination:

Categorieën:

Tim Millwood: Deploy: How it'll work in D8

di, 2015/10/20 - 5:40pm
Over the last 7+ years working with Drupal, one question always asked by clients is, how do I copy...
Categorieën:

DrupalCon News: Rise of the Drupal Community in India

di, 2015/10/20 - 4:56pm

The Drupal Association has partnered with Niswey, an India-based marketing firm, to provide marketing materials for DrupalCon Asia. Every few weeks, we'll be sharing the blogs and comic strips that our Niswey friends have created in anticipation of the convention.

Categorieën:

Zyxware Technologies: [Drupal] How to set destination as the link value in the l(), in case of urls with parameters

di, 2015/10/20 - 3:45pm

We can use the l() to add links in our Drupal pages. However, while using the output of drupal_get_destination() in the l() as link, it may end up in the wrong functionality. If the drupal_get_destination() returns a url with parameters involved, then using that directly in the l() will cause the link to redirect to wrong page.

DrupalDrupal Planet
Categorieën:

Drupalize.Me: Drupalize.Me Is Going to ZendCon

di, 2015/10/20 - 3:00pm

We'll be attending ZendCon 2015 this week, learning about what the PHP community is up to, and sharing our Drupal knowledge.

Categorieën:

ThinkShout: Meet the ThinkShout Team at BADCamp!

di, 2015/10/20 - 3:00pm

It’s another big week for us here at ThinkShout. We’re getting ready for a jam-packed weekend of Drupal at BADCamp in Berkeley, California. As we previously mentioned, we’re leading two half-day trainings on Friday, October 23rd. We’re thrilled that this training is completely sold out, and we’re looking forward to sharing our Salesforce and RedHen CRM curriculum!

Once again, we’re a sponsor and co-organizer of the Nonprofit Summit, which takes place on Thursday, October 22nd. This summit is also free to attend, and we encourage anyone in the nonprofit tech world in the Bay Area to come out for a day full of nonprofit-led lightning talks, and intimate discussion groups focused on Drupal topics that matter to you. The schedule is now live, so be sure to check it out and register if you’re interested in attending! Our own Brett Meyer will be leading a breakout session at the summit on fundraising with Drupal that you won’t want to miss!

We’re also Contrib Sponsors to BADCamp this year, which means we’ll have a table in the Pauley Ballroom West. We’d love to see your shining faces and chat about all things Drupal, tech, nonprofits, and even cats. This is an especially great time for job seekers to get to know us and our mission a little bit better. We’re still looking for a few good senior engineers to join our team, so if you think you might fit the bill, definitely drop by our table!

We’re looking forward to seeing you all in Berkeley!

Categorieën:

Code Enigma: Breaking words

di, 2015/10/20 - 2:39pm
Breaking words Language English Breaking words

Migrating away from legacy content management systems (CMS) can sometimes throw up some interesting technical challenges. Recently we were involved in a migration from a CMS where URL’s contained no word boundaries... here’s how we transformed these unfriendly URL’s and improved search engine optimisation.

Tue, 2015-10-20 13:39By chris

I'm sure we're all aware that human-readable URL's are a good thing, not only for us but for search engines too. Take, for example, the following URL:

/topsubjects/businessandintellectualproperty/businessandmanagementstudies/yourstudyprogram

Whilst it's readable (with effort), it's quite unfriendly and does nothing to promote the content of the page.

Initially I thought it an impossible (or at least very complicated) task to programmatically split a word such as "businessandintellectualproperty" into its component parts: "business and intellectual property". There were literally thousands of URL's so it was an impossible task to do manually.

The exported data from the legacy CMS contained human-readable page titles and the HTML of the body content so at least I had the option of using the page titles to generate the "your study program" part of the URL but what about the component parts of the URL? How could "businessandmanagementstudies" be transformed to "business-and-management-studies"?

Enter Wordbreaker! Wordbreaker (and Indexer) are utilities that are packaged with Sphinx (since version 2.1.1), an open source full text search server. Given that you have some useful data somewhere (in my case, the combined HTML body content of all of the pages in the CMS), Indexer can be used to create a frequency dictionary which in turn is passed into Wordbreaker along with the string you want to split, such as "businessandmanagementstudies" and lo and behold, out pops "business and management studies". It's magic, let me explain how to use both Indexer and Wordbreaker!

Creating a frequency dictionary with Indexer

The first thing you need to do is to identify the most useful data you have from which to create a frequency dictionary. A frequency dictionary is essentially a list of unique words found in a body of data with a frequency count of how often each word appears. Common words appear often so have a high frequency count whilst un-common words appear less frequently and thus have a low frequency count. Wordbreaker uses a frequency dictionary to determine the likelihood of the words it finds in the string actually being the words you want.

To give you an idea of what a frequency dictionary looks like, I've created one using the content of this blog post, here's a snippet:

the 51 to 30 of 27 a 23 frequency 16 you 13 in 12 dictionary 11 content 11 and 9

Clearly then, the richness of your source data and its relevance to the strings you're trying to split is an important factor in how successful the word splitting will be. In my migration, I used the combined content of the entire website to create a frequency dictionary which thankfully proved to be quite successful. What would have been potentially days of mind-numbing editing of URL's was reduced to a few hours of reviewing and fixing the few unsuccessful cases.

So, now you've identified your data, how do you create a frequency dictionary?

To use Indexer, you'll first need to create a Sphinx configuration file. This example shows how you can configure Sphinx to index data from an XML file:

source demo { type = xmlpipe2 xmlpipe_command = cat source.xml xmlpipe_fixup_utf8 = 1 } index demo { source = demo path = /tmp/demo } indexer { mem_limit = 128M }

Here we have Sphinx indexing the content of source.xml but it could easily be configured to index content from a MySQL or PostgreSQL database. See the sphinx.dist.conf file that comes with Sphinx for examples of how to do this.

Now let's take a look at the content of the source.xml file:

<?xml version="1.0" encoding="utf-8"?>                                 1   2     

For conciseness, the example contains only two documents with hardly any content, in reality you'd want much more source content with which to generate a rich frequency dictionary.

Now, assuming you've installed Sphinx already, the command for producing the frequency dictionary is:

$ indexer --buildstops demo.dict 100000 --buildfreqs demo -c sphinx.conf

The --buildstops flag tells indexer to stop short of actually producing an index and to just produce the list of words. The --buildfreqs flag tells indexer to add the frequency count.

demo.dict is the name of the resulting frequency dictionary file.

demo is the name of the source to use (referred to in sphinx.conf, the configuration file to use for this operation).

We've now got everthing we need to start splitting strings into their component words.

Using Wordbreaker

The command for doing so is:

$ echo businessandmanagementstudies | wordbreaker --dict demo.dict split

And the result:

business and management studies

I think that's pretty amazing and more importantly, so did our client! We were able to pass each section of the URL to Wordbreaker, replace spaces in the string that Wordbreaker returned and transform URL's like this:

/topsubjects/businessandintellectualproperty/businessandmanagementstudies/yourstudyprogram

Into URL's like this:

/top-subjects/business-and-intellectual-property/business-and-management-studies/your-study-program

I did a lightening talk at the October North West Drupal User group, here are the slides - http://slides.com/matason/wordbreaker

And here's the blog post from Sphinx about Wordbreaker - http://sphinxsearch.com/blog/2013/01/29/a-new-tool-in-the-trunk-wordbrea...

Our hosting stack from the bottom up - Part 1Blog Prevent ctools custom "content type" plugin's title from being overridenBlog Drupal and PHP Traits - Developer loveBlog
Categorieën:

tanay.co.in: Show off your Drupal 8 Recipe at Drupalcon Asia!

di, 2015/10/20 - 12:14pm

The easiest way to get started with Drupal is to do some stuff with Drupal, without writing any code. Yes, there is a module for everything in Drupal. But what makes Drupal even more powerful is how you could get these modules work together, again without any coding!

 

So, What is a Drupal Site Building Recipe?

Well it could be a bunch of modules that you could put together to build a site that accomplishes a set goal. A set of instructions on how you configured the modules to work together would make the recipe even more interesting.

 

Recipes are so popular with Drupal, that Drupal Documentation has a dedicated page that lists popular recipes contributed by the community - https://www.drupal.org/documentation/site-recipes

 

The same is the reason why you find so many “cookbooks” for Drupal that try to teach Drupal using recipes!

 

 

A recipe could show how to achieve something using a Drupal Site. A few examples from the existing list from the documentation:

 

Well, it does not stop there! If you wish to make your recipe easily accessible and configurable, you could also go a step further and consider building a distro that makes setting up your recipe even more easier!

 

“Distributions (distros) provide site features and functions for a specific type of site as a single download containing Drupal core, contributed modules, themes, and pre-defined configuration. They make it possible to quickly set up a complex, use-specific site in fewer steps than if installing and configuring elements individually.“

 

You can find the popular distros listed here. Commerce Kickstart is a great example which allows any Drupal Site Builder to setup a fully functional ecommerce site in minutes. Conference Organizing Distribution is another great distribution that has been enabling Event Organizers around the world in setting up an event site in minutes!

 

With Drupal 8 around the corner, the need for such recipes and distros is even greater than it was ever before.

  • How can you set up faceted search on a Drupal 8 site?

  • How can you setup a video player on Drupal 8 site?

  • How could I build a site like Stack Exchange using Drupal?

  • What are the options available for setting up a Multilingual Site in Drupal?

  • What are the module options available? Which one should I choose? How is one different or better than the other?

 

- These are all questions that have been discussed, answered, and documented for D7. With D8 around, all of these questions become relevant again and need some mind blowing recipes to help users understand the options available, to choose the ones that fit them best and to learn about how to use them.

 

Have you accomplished something significant with Drupal recently that you would like to showcase?  Do you have a new D8 recipe, or a new distro that you are working on, that you would like to present at the next Drupalcon happening in India? Here is your chance!

 

Only a few days left before Drupalcon Asia closes its door to session proposals on November 2nd. Submit your session proposal for the Site Building Track @ https://events.drupal.org/asia2016/submit-session

 

Also, besides recipes, there is a bunch of other stuff that you could present in the Site Building track. Check out the track description for more details and suggested topics. You can also check out the current proposed sessions here.

 

See you at the con with your recipe. Meanwhile, Keep cooking!

 
Categorieën: