Planet Drupal

Subscribe to Planet Drupal feed - aggregated feeds in category Planet Drupal
Updated: 18 min 31 sec ago

DrupalCon News: Eating Vegan in Barcelona

Wed, 19/08/2015 - 23:17

DrupalCon attendees can enjoy their visit to Barcelona taking a walk around some of the many 

Categories: Elsewhere frontpage posts for the Drupal planet: Drupal 7.39 and 6.37 released

Wed, 19/08/2015 - 22:45

Drupal 7.39 and Drupal 6.37, maintenance releases which contain fixes for security vulnerabilities, are now available for download. See the Drupal 7.39 and Drupal 6.37 release notes for further information.

Download Drupal 7.39
Download Drupal 6.37

Upgrading your existing Drupal 7 and 6 sites is strongly recommended. There are no new features or non-security-related bug fixes in these releases. For more information about the Drupal 7.x release series, consult the Drupal 7.0 release announcement. More information on the Drupal 6.x release series can be found in the Drupal 6.0 release announcement.

Security information

We have a security announcement mailing list and a history of all security advisories, as well as an RSS feed with the most recent security advisories. We strongly advise Drupal administrators to sign up for the list.

Drupal 7 and 6 include the built-in Update Status module (renamed to Update Manager in Drupal 7), which informs you about important updates to your modules and themes.

Bug reports

Both Drupal 7.x and 6.x are being maintained, so given enough bug fixes (not just bug reports) more maintenance releases will be made available, according to our monthly release cycle.


Drupal 7.39 is a security release only. For more details, see the 7.39 release notes. A complete list of all changes in the stable 7.x branch can be found in the git commit log.

Drupal 6.37 is a security release only. For more details, see the 6.37 release notes. A complete list of all changes in the stable 6.x branch can be found in the git commit log.

Security vulnerabilities

Drupal 7.39 and 6.37 were released in response to the discovery of security vulnerabilities. Details can be found in the official security advisory:

To fix the security problem, please upgrade to either Drupal 7.39 or Drupal 6.37.

Update notes

See the 7.39 and 6.37 release notes for details on important changes in this release.

Known issues


Front page news: Planet DrupalDrupal version: Drupal 6.xDrupal 7.x
Categories: Elsewhere

Drupal Easy: Long Form Drupal Training For Long Term Success

Wed, 19/08/2015 - 20:33

It's that time of year again - the next session of the Drupal Career Online program is about to get underway. Interested in learning Drupal best practices, common development shop workflows, as well as a bunch of the tools that modern Drupal professionals use every day? Looking to expand your current development team but don't have the time or the resources to train existing or new staff? If so, the Drupal Career Online program was designed with your needs in mind!

This will be the seventh time we've taught our curriculum, and the ninth time overall that is has been used for long-form Drupal training (Acquia has used it for their Acquia U program). We're confident that it provides students with the knowledge and experience to compress the amount of time it takes to become a Drupal professional.


read more

Categories: Elsewhere

Lullabot: A PHP Developer’s Guide to Caching Data in Drupal 7

Wed, 19/08/2015 - 20:30

If there’s one thing in programming that drives me up the wall, it’s patterns that I use once every few months, such that I almost remember what to do but inevitably forget some key detail. Lately, that has been when I’ve needed to cache data from remote web services. I end up searching for A Beginner's Guide to Caching Data in Drupal 7 and checking it’s examples against my code. That’s no fun at all.

After some searching for a different project, I found the Drupal Doctrine Cache project and thought "what if I could chain the static and Drupal cache calls automatically?" - and of course, it’s already done with Doctrine’s ChainCache class. ChainCache gives us a consistent API for all of the usual cache operations. The class takes an array of CacheProvider classes that can be used to cache data. When fetching data, it goes through them in order until it finds the object you’re looking for. As a developer, caching data in memory in a static cache is no different than caching it in MySQL, Redis, or anything else. On top of that, ChainCache handles saving and deleting entries through the entire chain automatically. If you update the database (and invalidate your cached data), you can clear the static and persistent caches with a simple $cache->delete(). In fact, as someone using the cache object directly, you might not even know that a static cache exists! For example, the ChainCache could be updated to also persist data in a local APC cache. Or, the persistent Drupal cache could be removed if it turned out not to improve performance. Calling code doesn't need to have any knowledge of these changes. All that matters is you can reliably save, fetch, and delete cached data with a consistent interface.

What does all this mean? If you’re already using Composer in your Drupal projects, you can easily use these classes to simplify any of your caching code. If you’re not using Composer, this makes a great (and simple) example of how you can start to use modern PHP libraries in your existing Drupal 7 project. Let’s see how this works.

Adding Drupal Doctrine Cache with Composer

The first step is to set up your module so that it requires the Drupal Doctrine Cache library. For modules that get posted on, I like to use Composer Manager since it will handle managing Composer libraries when different contributed modules are all using Composer on the same site. Here are the steps to set it up:

  1. Install Composer if you haven’t installed it yet.
  2. Create a Drupal module with an info file and a module file (I’ve put an example module in a sandbox).
  3. In the info file, depend on Composer Manager: dependencies[] = composer_manager
  4. Open up a terminal, and change to the module directory.
  5. Run composer init to create your initial composer.json file. For the package name, use drupal/my_module_name.
  6. When you get to the step to define dependencies (you can modify them later), add capgemini/drupal_doctrine_cache to require the library. You can add it later by editing composer.json or using composer require.

When you enable your module with Drush, Composer Manager will download the library automatically and put it in the vendor folder. For site implementations, it’s worth reading the Composer Manager documentation to learn how to configure folder paths and so on.

Using the CacheProvider for a Static and Persistent Cache

We’re now at the point where we can use all of the classes provided by the Drupal Doctrine Cache library and Doctrine Cache in our module. In a previous implementation, we might have had caching code like this:

function my_module_function() { $my_data = &drupal_static(__FUNCTION__); if (!isset($my_data)) { if ($cache = cache_get('my_module_data')) { $my_data = $cache->data; } else { // Do your expensive calculations here, and populate $my_data // with the correct stuff. cache_set('my_module_data', $my_data); } } return $my_data; }

We can now replace this code with the ChainCache class. While this is nearly the same amount of code as the previous version, I find it much easier to read and understand. One less level of nested if statements makes the code easier to debug. Best of all, to a junior or non-Drupal PHP developer, this code doesn’t contain any "Drupal magic" like drupal_static().

function my_module_function() { // We want this to be static so the ArrayCache() isn’t recreated on each function // call. In OOP code, make this a static class variable. static $cache; if (!$cache) { $cache = new ChainCache([new ArrayCache(), new DrupalDoctrineCache()]); } if ($cache->contains('my_module_data')) { $my_data = $cache->fetch('my_module_data'); } else { // Do your expensive calculations here. $my_data = 'a very hard string to generate.'; $cache->save('my_module_data', $my_data); } return $my_data; }

If the calling code needs to interact with the cache directly, it’s entirely reasonable to return the cache object itself, and document in the @returns tag that a CacheProvider is returned. Your specific caching configuration is safe and abstracted, avoiding sporadic drupal_static_reset() calls in your code.

Interfaces are the Future, and they’re Already Here

Even if you prefer the Drupal-specific version of this code, there’s something really interesting about how Doctrine, a small bit of glue code, and Drupal can now work together. The above is all possible because Doctrine ships a set of interfaces for caching, instead of just creating raw functions or concrete classes. Doctrine is helpful in providing many prebuilt cache implementations, but those can be swapped out for anything - including a thin wrapper around Drupal’s cache functions. You can even go the other way around, and tie Drupal’s cache system into something like Guzzle’s Cache Subscriber to cache HTTP requests in Drupal. By writing our code around interfaces instead of implementations, we let others extend our code in ways that are simply impossible with Drupal-7 style procedural programming. The rest of the PHP community is already operating this way, and Drupal 8 works this way as well.

Do you know about other PHP libraries that are great at working with Drupal 7’s core systems? Share them here by posting a comment below.

Categories: Elsewhere

Axelerant Blog: How to build an amazing Drupal radio

Wed, 19/08/2015 - 20:00

We love our hackathons at Axelerant, and we are always trying to build something that helps spread happiness. We thought it would be nice to have an internal web-based online radio, where people would be able to listen to songs along with some fun social characteristics.

Thus, one of our hackathons saw us getting down to build a Drupal radio website, with the following features.

  • Ability to upload songs
  • Ability to dedicate a song to anyone with a message
  • Play a random song when the dedicated song queue is empty
  • Integrate the radio site with Slack, and display the current track being played
  • Display the Up Next queue
  • Build the radio site using only Drupal, without any radio streaming software

Described below is how we went about putting the various components of the online radio together.

Uploading a song on the online radio

We created a content type called Song with the following fields:

  • Song field of type File to upload music files
  • Art field of type Image, to upload the album art
  • Tags of type Term Reference to tag artists, genres, etc.
  • Duration of type Number to track the song duration

An interesting part was the song duration. The getID3 library helped us fetch the song duration, and so, in the content type song feature I created a hook that added song duration on the creation of a new song. As it is automatically calculated and added, the song duration field is hidden from end users.

Uploading a song on an online radio, built using only Drupal

Dedicating a song on the Drupal radio

We created a content type called Request with the following three fields:

  • Song field of type Entity Reference that points to the song nodes
  • Dedicated-to of type Entity Reference that points to the User to whom the song is dedicated
  • Message of type Text for the message he/she wants to dedicate.
  • Played-at of type Date to keep track of when the song started playing
  • Default-request of type Boolean to know if this node is a song that is played by default or if its a request.

After a request is saved, the resulting node would be added to a nodequeue. The fields Played-at and Default-request are hidden.

Dedicating a song on an online radio, built using only Drupal

The Magic

We created a method that simulated a constantly playing playlist. It did three things

  1. Check if the requested song is playing.
  2. If not, play it.
  3. If the song is done playing, remove it and pull up the next requested song and play it.

The detailed logic looks like this:

  1. Check if there are any songs in the node_queue.
  2. If there are any, then check if the first song has already started playing by seeing if the Played-at is set or not.
  3. If it is not playing, set Played-at field to the current time, which means that this song has started playing.
  4. If it is playing, check if the current time has passed the Played-at + Duration time of the song being played. If it has passed, it means the song is done playing.
  5. If the song is done playing, remove the request, populate Played-at field for the top request with the current time.
  6. If there is no request, get a node marked as Default-request and put some random song, update Played-at to the current time and add it to the top of the queue.

This above function would be called twice, once by the cron and once just before the page that serves the song would be rendered.

Whenever a new song would get pulled, the site would send a Slack channel notification.

The View

The now playing song is rendered by the Views module. The view displays whichever song is at the top of the node_queue. We wrote a tiny .tpl file to stream the song rather than display the link to the song file. We used the HTML5 <audio> tag to render the MP3.

There was one more hurdle that we had to cross before we were done - we wanted the song being heard by everybody to be in sync. If we had rendered as-is, everybody would start hearing the song from the beginning. To avoid this, we also rendered the Played-at field to the front-end.

Thanks to the HTML5 audio object’s CurrentTime attribute, we could start a song with an offset. A tiny .js file would compute the difference between the current time and the Played-at time, and add that as an offset to the audio object, and voila! The song starts playing with a certain offset, achieving a sync across requests, and simulating an actual online radio.

Once the song ends, the js callback would reload the page, and our magic function would run again. The latest song would be pulled up or a newly dedicated song will be rendered by the view.

The View - An online radio built using only Drupal

If no one is listening, the cron keeps playing the next song at random, and Slack keeps notifying us of the currently played songs.

Slack notifications for the online radio using Drupal

We do a lot more cool stuff like this Drupal radio at Axelerant. To join us, visit our careers page or contact sales so we can do this for you.

The post How to build an amazing Drupal radio first appeared on Axelerant.

Categories: Elsewhere

Drupal Watchdog: VIDEO: DrupalCon Los Angeles Interview: Fabian Franz

Wed, 19/08/2015 - 17:15

In an exclusive, late-night interview, the fabulous Fabian Franz (Technical Lead, Tag1 Consulting) dishes the dirt on big-pipe Drupal and drops a grenade on our favorite social media platform: “You know what?” he says, “FaceBook cheats!” Hey, I’m totally not surprised; I saw the movie.

Want more Fabian? Read my interview with him (“Baby Steps”) in Drupal Watchdog 5.01 and, while you’re at it, subscribe:

Tags:  DrupalCon DrupalCon LA Video Interview Video: 
Categories: Elsewhere

Red Crackle: Inheritance

Wed, 19/08/2015 - 16:41
In this post, you will learn about inheritance in object-oriented PHP. You will understand when to use it and the benefits associated with its use. You will understand Method Overriding in PHP. You will also learn when to set the visibility of properties and methods to public, protected or private.
Categories: Elsewhere

Chromatic: Presenting at DrupalCamp Asheville 2015

Wed, 19/08/2015 - 16:11

Last weekend I enjoyed the awesomeness of DrupalCamp Asheville. The Asheville Drupal User Group did an amazing job once again. It was a great camp filled with positive people and smart sessions. This time around I was lucky enough to deliver my own presentation, SVG: How To Have Fun Making Your Site Look Hot!.

The session was filled with a great mix of people of all skill levels - from having little SVG exposure to people who employ it in all their projects. The talk catered to both as we reviewed everything from the basics of understanding SVG and getting it displayed on your site to more advanced topics like line-stroke animations and SVG filters.

This was my first presentation at a DrupalCamp, and it was very rewarding. I think everyone learned something, and it felt great to give back to a community that shares so much information on a daily basis.

Overall, the presentations were on point. A few sessions I attended that stood out were Bayo Fodeke and Mark Shropshire’s Decoupled Drupal with Meteor, Chris Russo’s Personal git workflow, for everyone! and Matt Davis’ Headless Challenges Answered:'s Presentation Framework.

Besides being a great camp, it’s located in Asheville, which is a true gem of the East Coast with vibrant arts, food and beer scenes. If you get the chance, you should definitely try to attend next year's camp. Whether you’ve never attended a camp or you’re a grizzled veteran, you’ll love the setting, the sessions, and best of all, the awesome people you’ll meet. See you in 2016!

Categories: Elsewhere

Drupal core announcements: Drupal 8 core updates for August 19th, 2015

Wed, 19/08/2015 - 16:06
What's new with Drupal 8?

Since the last Drupal 8 Core Update, Drupal 8 got a UI for responsive image mapping, a proposal for a new content model was put forward and a bunch of improvements were made to, notably: the first comment to an issue is now automatically generated to make it easier to see the original issue summary, test result output was improved, and it's now possible to test patches on PHP 5.4, 5.5, 5.6, and 7 simultaneously.

Some other highlights of the month were:

How can I help get Drupal 8 finished?

See Help get Drupal 8 released! for updated information on the current state of the software and more information on how you can help.

We're also looking for more contributors to help compile these posts. Contact mparker17 if you'd like to help!

Drupal 8 In Real Life Whew! That's a wrap!

Do you follow Drupal Planet with devotion, or keep a close eye on the Drupal event calendar, or git pull origin 8.0.x every morning without fail before your coffee? We're looking for more contributors to help compile these posts. You could either take a few hours once every six weeks or so to put together a whole post, or help with one section more regularly. If you'd like to volunteer for helping to draft these posts, please follow the steps here!

Categories: Elsewhere

Drupalize.Me: New Tutorials: Manage Drupal Sites with Pantheon

Wed, 19/08/2015 - 15:30

Today we are happy to present a new series teaching you how to Manage Drupal Sites with Pantheon, which is completely free thanks to the generous sponsorship of Pantheon. Pantheon is a great service for management your website development and launching your sites on an environment that has been optimized for Drupal.

Categories: Elsewhere

Zyxware Technologies: [Drupal] What is the usage of drupal_write_record function in Drupal 7?

Wed, 19/08/2015 - 13:39

The drupal_write_record function is used to insert or update a record in the database based on the schema of the table. It helps in executing less database query. Let's take a look at the function given below.

DrupalDrupal 7Drupal Planet
Categories: Elsewhere

Realityloop: Testing, Testing, 1, 0, 1

Wed, 19/08/2015 - 10:04
19 Aug Stuart Clark

At Realityloop I've been involved with some extremely complex site builds, varying from Commerce driven paywalls to fully fledged data reporting web applications. Yet, the hardest thing I've ever had to do is successfully sell automated testing to a client.

And the reason for that is relatively simple; Tests are hard to write, therefore time consuming and expensive.

However this is a misconception, while certain types of tests can be hard to write, any automated tests will recoup the costs in a short amount of time, and as such, you can’t afford not to have tests.

In part one of this post I will be explaining exactly why you need tests. In part two (due in three weeks) I will cover how to get started and implement your automated tests.


What are tests?

A test is exactly what it sounds like; a method to ensure that your project behaves as is expected.

Any steps taken by an individual to ensure the project is behaving correctly are considered to be manual tests, and while they are essential, they are time consuming.

For an example of what a test may be, let's look at the following scenario:

Fictitious Inc want a contact form on their website that will send emails to specific recipients based on the type of enquiry.

They need three enquiry types:

  1. Support to

  2. Sales to

  3. General enquiry to

Along with this requirement, they also wish to have a personalised auto-response per enquiry type.

Once this the above functionality has been created, all parties, at some point, will need to ensure that it does indeed work as expected.

This process is your manual test, which would look something like this:

Jarkko navigates to his Fictitious Inc. development site, clicks on the Contact menu item, selects the Support enquiry type, fills out some dummy data and submits the form.

He then ensures that the email was sent to the correct email address with the supplied data, and ensures that received the correct auto-response with the correct personalisations given the supplied data.

Lastly, he repeats the process with the other two enquiry types, ensuring that he supplies different data to his previous test(s).

That’s a test, and a relatively simple test, but already it's evident that it is time consuming. Throw in more complexity to the requirements and the time increases exponentially.

Any future work on this project, regardless of the area of work, should ensure that these same tests, as well as any other tests in the site, are run again. Otherwise you run the risk of accidentally breaking a core feature of the project.

As such, manual testing becomes excessively time consuming, and often a step that is skipped by all involved.

Automated testing is the answer.


What are automated tests?

There are various types of automated testing, but for the sake of this post I will be concentrating on "integration tests".

An automated test is, again, exactly what it sounds like; an automated method to ensure that your project behaves as is expected.

Take the previous scenario, currently each individual involved in the project (developer, tester, project manager, client, etc) could be spending anywhere between 2 and 10 minutes to manually test that small subset of the project functionality every time any changes are made to the project.

Automated, the same test should take no more than a 30 seconds in total, and can be run along with all other automated tests in one quick hit.


Manual testing vs Automated testing

In the above video you can see the Automated test running side-by-side with the Manual test.

The Automated tests are not only testing the same scenario as my Manual tests, but also installing a fresh copy of Drupal, enabling all required modules, flushing caches, reverting features and running a few additional checks that I didn't do in the Manual test.

For those of you who do not wish to watch the video, the results are as such:

Manual testing - 3 minutes 19 seconds

Automated testing - 27 seconds

However, there is still a time investment involved to create the tests. In this case it took me roughly 60 minutes to write the tests, in which time the manual tests could have been run about 18 times, assuming of course your manual tester doesn't decrease efficiency after running each test.



Continuous Integration

With the above simpletest, the responsibility of running the tests is still in the hands of a human, and as such you will only get your test results if someone bothers to run the tests.

Continuous integration relieves your human workers of that responsibility, instead automating the running of the automated tests.

Travis CI is one such service which is relatively well loved by the open source community due to the direct integration with Github.

Along with the benefit of running automated tests on every commit (or tag, if that is how you wish to configure it), Travis can run multiple testing jobs concurrently, allowing you to ensure you project works on a variety of different environments.

Travis CI jobs do take longer than running a Simpletest (based on my above video), which is due to Travis not only doing all the additional things that Simpletest is doing but also having to setup a complete environment prior to installing Drupal. However, as you can run potentially upwards of 10 concurrent jobs (on a Premium plan) this time loss is quickly negated.

Assuming you are on a free plan, and the current load on the server allows for 4 concurrent jobs taking a maximum of 1 minute and 20 seconds (the average from my own tests), you recoup the cost of the test development in only 4 commits.

Adding Travis integration to your Drupal project is relatively simple thanks to the Drupal Travis Integration project. It’s as simple as adding and configuring single file to your Github repository. However I’ll go into more detail on this in part 2 of this post.

drupaldrupal planet
Categories: Elsewhere

KnackForge: Drupal 6 Re-initializing Gmap in Jquery

Wed, 19/08/2015 - 08:15
Assume, I am able to print the gmap using Drupal code in a div. I would like this map to appear inside a fancybox and to be hidden on the website. I've managed to do it (fancybox works ok) however the map is not displayed correctly, I am getting "Javascript is required to view this map".   Here is an *experimental* method, that may allow you to successfully reboot a map.  
  1. // Init Fancybox
Categories: Elsewhere

KnackForge: How to deal with hover on touch screen devices

Wed, 19/08/2015 - 07:27
Links with hover styles on touch devices are a bit of a complication. In short, they don’t really exist on these devices. Creating fancy :hover styles can really add to the browser experience and help simplify your layout, but they simply will not work on a touch device. When a tablet or smartphone user taps your hover-styled link elements, the hover style shortly appears, and immediately the underlying link is followed/activated.   So how do we handle this problem? Do we sniff out touch devices and disable hover classes? Not at all: it can be fixed using jQuery, and with some minimal adjustments you can keep using your hover styles across all browsing devices   THE GOAL   When a touch user taps menu A, only the hover style for menu A is activated but the link does not open. After this, there are two possible options:   1. User taps menu A again -> menu A is opened. 2. User taps menu B -> mouseover for menu B is activated and the hover style for menu A is deactivated.   Another thing to keep in mind is that if a user taps menu A, then taps menu B and then taps menu A again, it should not consider menu A as being tapped for a second time (which would lead to the browser to open the link).   WHAT WE NEED TO ACCOMPLISH   To realize our goal, we need to accomplish the following using (jQuery)  
Categories: Elsewhere

KnackForge: Configure SOLR for Spatial Search Setup

Wed, 19/08/2015 - 07:18
Configure SOLR for Spatial Search Setup ----------------------------------------------------   One of our projects requires the spatial search to find the closest records for given address OR zipcodes. So we decided to use SOLR for performing spaital search based on latitude & longitude for getting the closest records.   This blog describes on SOLR configuration for location based spatial search and how to run queries on SOLR.   You can download latest SOLR from here :   Schema Changes :   To add location data (latitude, longitude) in documents, we need to update the schema.xml file. We need to add a new field type (specifically used for geospatial searching). In case it's not already present (depends on SOLR version), we have to add the below fieldType definition to the schema.xml file.   <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>   FieldType definition is done. Now we need to define the fields for location data.   <field name="latlon" type="location" indexed="true"  stored="true" />   indexed=true makes a field searchable (and sortable and facetable). For eg, if you have a field named test1 with indexed=true, then you can search it like q=test1:foo, where foo is the value you are searching for.   stored=true means you can retrieve the field when you search.   Indexing Location Data  
Categories: Elsewhere

Modules Unraveled: 145 Project Workflow and Drupal Issue Queues with Joshua Mitchell - Modules Unraveled Podcast

Wed, 19/08/2015 - 07:00
Published: Wed, 08/19/15Download this
  • Prioritizing work on Roadmap
    • Unblock Drupal 8
      • DrupalCI - testing infrastruture for Drupal code
      • upgrade to D7
    • Improve search
    • Implement new documentation section and tools
  • Two Factor Authentication
  • Issue Credits
  • Funding work
    • D8Accelerate
    • Ongoing Funding
Work that is coming later Questions from Twitter
  • hussainweb
    I think a hierarchical menu system has it's place - Gives a continuity and mark progress if you want to read a topic. #MUP145
  • hussainweb
    Can you attribute different patches in a single issue - some to the organization and some as a volunteer? #MUP145
  • hussainweb
    Some issues get abandoned after some work. Is that never counted? #MUP145
  • Paulius Pazdrazdys
    How much forums are being used? Maby you are thinking to more question -> answer model as stackoverflow has? #MUP145 (Issue about the subject - Petition to move forums to Stack Exchange)
Episode Links: Josh on drupal.orgJosh on TwitterTags: drupal.orgplanet-drupal
Categories: Elsewhere

KnackForge: Translation in Drupal 7 : How it works?

Wed, 19/08/2015 - 06:28

As we all know that, we were all getting projects and clients across the globe. But doing a multilingual website with each having different set of requirements make the website handling tougher and tougher. Also, building a multilingual web site involves much more than translating content from one language to another. Translation must be done with an awareness of a language's idioms as spoken within a geographic region. But in Drupal we’ve been provided with rich set of core and contrib modules, which supports translation for our website(s). When we go deeper in the concept of Drupal Translation, there is a lot more can be learnt. Well, here I explain you a few concepts that i’ve come across.

The Translation Methods:

In Drupal 7, we have two different types of translation methods, which we can call as two main modules to implement translation of content in order to make a site multilingual. One is Entity Translation (contrib) and the other one is Content Translation (core).

  1. Content Translation

    1. a core Drupal module that allows you to translate nodes.

    2. Translated nodes are mapped together, but if they are distinct nodes that can be treated separately.

  1. Entity Translation

    1. Translation module lets you translate particular fields, while only a single node or entity is created.

Categories: Elsewhere

KnackForge: Add placeholder, Alter or hide image captcha title

Wed, 19/08/2015 - 06:17

To add placeholder or alter the title, description and hide of the image captcha, do as follows

Use hook_form_FORM_ID_alter() and Form API pre_render function.


/** * Implements hook_form_FORM_ID_alter() */ function MY_MODULE_OR_THEME_form_contact_site_form_alter(&$form, &$form_state, $form_id) { $form['#pre_render'][] = 'yourform_pre_render'; } function yourform_pre_render($element) {   if (isset($element['captcha']['captcha_widgets']['captcha_response']['#title'])) {     // change title $element['captcha']['captcha_widgets']['captcha_response']['#title'] = t('Change title name');  // placeholder add $element['captcha']['captcha_widgets']['captcha_response']['#attributes']['placeholder'] = $element['captcha']['captcha_widgets']['captcha_response']['#title'];  // empty title $element['captcha']['captcha_widgets']['captcha_response']['#title'] = ''; $element['my_captcha_element']['captcha_widgets']['captcha_response']['#description'] = "New Description"; } return $element; }

You can also use hook_form_alter() function:

Categories: Elsewhere

Colan Schwartz: Get search results for compound words not in content with Drupal, Search API and Solr

Wed, 19/08/2015 - 01:01

It is possible to expand compound search terms to multi-term synonyms. That is, if your Drupal site content contains text such as "dark room" or "key note", and you don't want your users to get No results pages on searches for "darkroom" or "keynote" (respectively), you'll need to do a bit of extra work to make this happen.

Let's assume we've got a Drupal 7 site working alongside Solr to provide the advanced back-end search functionality, and the Search API plus Search API Solr Search modules to integrate the two systems. At the time of this writing, this is a widely used best-practice approach. However, it doesn't natively support the above use case.

Some potential options for setting this up include spellchecking and fuzzy searching. But Solr itself already supports the use of synonyms even though the Search API does not. So let's tweak Search API's set-up to work with it.

There are several steps required to make this happen.
  1. If you're got the tokenizer enabled on your search index, disable it by unchecking the box over at Administration » Configuration » Search and metadata » Search API » Your index name » Filters » Processors » Tokenizer, and then save the configuration. If the Tokenizer option is enabled, it will prevent the synonym functionality from kicking in.
  2. Modify the Solr configuration in your search collection over at /path/to/solr/collection-name/conf/schema.xml around line 162.
    • Before:         <!-- in this example, we will only use synonyms at query time
              <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    • After:         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  3. Define multi-term synonyms in the synonyms.txt file that's in the same folder as the above schema.xml file. Follow the form here.
    • darkroom => dark room
    • keynote => key note
  4. Restart the search engine. This is system dependent, but if you're using the GlassFish application server for example, you may be able to restart Solr with a command like sudo service GlassFish_solr restart.
  5. Clear the search index and rebuild it.
    1. Surf to Administration » Configuration » Search and metadata » Search API » Your index name.
    2. Hit the "Queue all items for reindexing" button.
    3. Hit the "Index now" button.

That should do it. You're all set!

Background reading For more information on how all of this really works, here are some useful articles on the subject.

This article, Get search results for compound words not in content with Drupal, Search API and Solr, appeared first on the Colan Schwartz Consulting Services blog.

Categories: Elsewhere