Skip to Content

Newsfeeds

Conditional View Mode

New Drupal Modules - 18 January 2015 - 6:43am
Categories: Drupal

Commerce Finnish Smartpost

New Drupal Modules - 18 January 2015 - 6:37am

Integrate Finnish "Pakettiautomaatti" to Drupalcommerce

Categories: Drupal

File Attachment Icons

New Drupal Modules - 18 January 2015 - 6:37am
Categories: Drupal

Alexander Mikhailian: Data-mining Drupal users in a screenful of code

Planet Drupal - 18 January 2015 - 1:53am
Objective

Select like-minded users from a local community website.

Pre-requisites
  1. A Drupal website with the votingapi module enabled and at least a few dozen votes by registered users.
  2. A working installation of the R language.
Exract data

For each user, select all other users that voted on same node and comments:

SELECT v1.uid uid1, v2.uid uid2, u.name name2, v2.entity_id entity_id, v1.value value1, v2.value value2 FROM votingapi_vote v1 JOIN (votingapi_vote v2, users u) ON (v1.uid != v2.uid AND v1.entity_id=v2.entity_id AND v1.entity_type=v2.entity_type AND v2.uid=u.uid) WHERE v1.uid

This produces a table

Categories: Drupal

csv2sql

New Drupal Modules - 18 January 2015 - 1:18am

Development is done on GitHub

Convert CSV to SQL and create a table in your Drupal installation

CSV are a great way to give a client to enter their data that will be migrated to the site. However, for the migration itself, SQL would be quicker.

drush scr csv2sql.php /PATH/TO/file.csv

Will create a _raw_file table in the Drupal installation which drush is running under.

Categories: Drupal

Akshay Kalose: Drupal 8: Ajax in Forms

Planet Drupal - 17 January 2015 - 1:45pm

Why reload the whole page, when you can just update a certain parts of the DOM? Ajax allows you to do just this, to dynamically update content. Just one of the many great uses of Ajax is Form Validation. In this example, we will see how to implement this.

We will be making a simple form which will contain a text field that will validate if the username entered exists, and a button that will replace the text field value with a random existing username.

Building The Form

First, we need to define our two form elements:

$form['user_name'] = array( '#type' => 'textfield', '#title' => 'Username', '#description' => 'Please enter in a username', ); $form['random_user'] = array( '#type' => 'button', '#value' => 'Random Username', );

Next, to start using Ajax in Drupal, all you need to specify is the “callback“, or function to call, when the “event“, or trigger, is fired on that certain form element, in an array under the “#ajax” key:

$form['user_name'] = array( '#type' => 'textfield', '#title' => 'Username', '#description' => 'Please enter in a username', '#ajax' => array( // Function to call when event on form element triggered. 'callback' => 'Drupal\ajax_example\Form\AjaxExampleForm::usernameValidateCallback', // Javascript event to trigger Ajax. Currently for: 'onchange'. 'event' => 'change', );

In the “callback”, include the full namespaced class and function you want to call. The event can be any Javascript event without the “on”. A list of Javascript events can be found here.

Once you have added these two keys, you can add extra options such as “effect”, and “progress”. More options can be found on the Ajax API. Here are the finished elements:

$form['user_name'] = array( '#type' => 'textfield', '#title' => 'Username', '#description' => 'Please enter in a username', '#ajax' => array( // Function to call when event on form element triggered. 'callback' => 'Drupal\ajax_example\Form\AjaxExampleForm::usernameValidateCallback', // Effect when replacing content. Options: 'none' (default), 'slide', 'fade'. 'effect' => 'fade', // Javascript event to trigger Ajax. Currently for: 'onchange'. 'event' => 'change', 'progress' => array( // Graphic shown to indicate ajax. Options: 'throbber' (default), 'bar'. 'type' => 'throbber', // Message to show along progress graphic. Default: 'Please wait...'. 'message' => NULL, ), ), ); $form['random_user'] = array( '#type' => 'button', '#value' => 'Random Username', '#ajax' => array( 'callback' => 'Drupal\ajax_example\Form\AjaxExampleForm::randomUsernameCallback', 'event' => 'click', 'progress' => array( 'type' => 'throbber', 'message' => 'Getting Random Username', ), ), );

Creating The Callbacks

After creating our form elements, it is time to create the callback functions which will return the response of what to update on the page.

These callbacks will return an instance of \Drupal\Core\Ajax\AjaxResponse. Each AjaxResponse instance will contain jQuery commands that will execute on the form. You can use the “addCommand()” method on AjaxResponse to add commands that implement \Drupal\Core\Ajax\CommandInterface.

Some commands such as CssCommand and ChangedCommand did not work. Thankfully, there is InvokeCommand which allows you to run any jQuery command. You can construct it with a jQuery selector, method, and arguments:

public InvokeCommand::__construct($selector, $method, array $arguments = array())

Here are the two callbacks for our form:

public function usernameValidateCallback(array &$form, FormStateInterface $form_state) { // Instantiate an AjaxResponse Object to return. $ajax_response = new AjaxResponse(); // Check if Username exists and is not Anonymous User (''). if (user_load_by_name($form_state->getValue('user_name')) && $form_state->getValue('user_name') != false) { $text = 'User Found'; $color = 'green'; } else { $text = 'No User Found'; $color = 'red'; } // Add a command to execute on form, jQuery .html() replaces content between tags. // In this case, we replace the desription with wheter the username was found or not. $ajax_response->addCommand(new HtmlCommand('#edit-user-name--description', $text)); // CssCommand did not work. //$ajax_response->addCommand(new CssCommand('#edit-user-name--description', array('color', $color))); // Add a command, InvokeCommand, which allows for custom jQuery commands. // In this case, we alter the color of the description. $ajax_response->addCommand(new InvokeCommand('#edit-user-name--description', 'css', array('color', $color))); // Return the AjaxResponse Object. return $ajax_response; } public function randomUsernameCallback(array &$form, FormStateInterface $form_state) { // Get all User Entities. $all_users = entity_load_multiple('user'); // Remove Anonymous User. array_shift($all_users); // Pick Random User. $random_user = $all_users[array_rand($all_users)]; // Instantiate an AjaxResponse Object to return. $ajax_response = new AjaxResponse(); // ValCommand does not exist, so we can use InvokeCommand. $ajax_response->addCommand(new InvokeCommand('#edit-user-name', 'val' , array($random_user->get('name')->getString()))); // ChangedCommand did not work. //$ajax_response->addCommand(new ChangedCommand('#edit-user-name', '#edit-user-name')); // We can still invoke the change command on #edit-user-name so it triggers Ajax on that element to validate username. $ajax_response->addCommand(new InvokeCommand('#edit-user-name', 'change')); // Return the AjaxResponse Object. return $ajax_response; }

Finished Form

Here is our finished Ajax Example Form:

 

This blog post was created for Google Code-In 2014 to learn about a Drupal Core System.

Full Module Code .gist table { margin-bottom: 0; }

The post Drupal 8: Ajax in Forms appeared first on Akshay Kalose.

Categories: Drupal

Blueimp Gallery

New Drupal Modules - 17 January 2015 - 9:15am

blueimp Gallery is a touch-enabled, responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
It features swipe, mouse and keyboard navigation, transition effects, slideshow functionality, fullscreen support and on-demand content loading and can be extended to display additional content types.
It will convert any list of thumbnail images linked to original image on a Gallery.

Categories: Drupal

SyncDb

New Drupal Modules - 17 January 2015 - 9:11am

This project implements two Drush commands to export and import large databases.

By splitting tables into separate files and importing them in parallel we can reduce the overall processing time considerably.

Here is a description of each command:

  • drush dumpdb will dump database tables into the temporary directory of the current environment..
  • drush syncdb @example.dev will download sql files from @example.dev and install them in the current environment.

This command has been tested only in MySQL.

Categories: Drupal

3C Web Services: How to remove the Fieldset from a Drupal Address Field

Planet Drupal - 17 January 2015 - 7:57am

INTRODUCTION

The Drupal Address Field Module is a great tool that we use often. There are, however, many times when the default output causes some issues for us. Be default, Address Field places all of its individual field components inside of a Feldset wrapper. This is usually a nice feature but there are times when you may want to remove this Fieldset wrapper for ascetics. Or, perhaps, you'd like to place additional fields within the Address Field's Fieldset. We'll show you how to do both.

Categories: Drupal

DrupalOnWindows: Node Comments and Forums working together to boost user engagement

Planet Drupal - 17 January 2015 - 4:07am

It is frequent that customers approach us asking for help to rescue their projects from site builders. Sometimes they have technological issues (mainly slow sites) but sometimes it's just plain bad usability os some wrong marketing concepts.

We recently were asked for help from a site that gets about 5,000 unique visitors a day. Despite the not so bad visitor numbers for their niche, this page was getting very low user interaction. They barely got a handful (<10) of comments and forum posts in a whole year timespan.

Language English
Categories: Drupal

'Has making games gotten easier or harder as you get older? Why?'

Social/Online Games - Gamasutra - 16 January 2015 - 3:49pm

As the game industry matures, developers must balance the demands of their careers with the realities of growing older. Gamasutra asks its Twitter followers whether things get easier -- or harder. ...

Categories: Game Theory & Design

The Cherry Hill Company: Creating a Context Plugin

Planet Drupal - 16 January 2015 - 1:49pm

On a recent project I was using the combination of Field Collection, Entity Reference, Taxonomy Terms, and Context to make a reusable set of references to terms on various content types. Then, based on the referenced term, I wanted to satisfy a context condition.

Due to the somewhat complex structure, the context was not aware of the term referenced through entity reference and the field collection.

In a case like this, creating a custom context plugin was a good solution.

I got started by reading a couple of helpful posts by others: Custom Context Conditions and Extending Drupal's Context Module: Custom...

Read more »
Categories: Drupal

Advomatic: Views in Drupal 8: Improved Displays

Planet Drupal - 16 January 2015 - 11:09am
Now that Drupal 8 is in beta, I’ve been trying to spend some more time with it. Reading articles and watching presentations are good ways to keep up with where things are (or are going), but nothing beats actually using it. Simplytest.me, Pantheon, and Acquia Cloud all now provide free ways to spin up an instance... Read more »
Categories: Drupal

Endomondo connector

New Drupal Modules - 16 January 2015 - 10:54am
Categories: Drupal

GDC poll suggests most game developers still rely on self-funding

Social/Online Games - Gamasutra - 16 January 2015 - 9:50am

Big VC windfalls and crowdfunding successes make the headlines, but the majority of developers still fund their work using either their company's existing warchest or their own personal funds. ...

Categories: Game Theory & Design

Alt.Ctrl.GDC alternative input exhibit reveals GDC game lineup

Social/Online Games - Gamasutra - 16 January 2015 - 9:06am

Out of over 100 submissions, Game Developers Conference 2015 organizers have chosen 15 teams for the return of alt.ctrl.GDC, an on-site exhibit of alternative control schemes and games. ...

Categories: Game Theory & Design

Drupal Watchdog: Drush: The Swiss Army Knife for Drupal

Planet Drupal - 16 January 2015 - 8:41am
Article

I’m personally amazed at the new features and advances of Drupal 8. There are so many changes to talk about, but for this article I want to cover configuration management. In case you haven't yet heard, with the new version of Drupal we see all configuration stored in files instead of in the database. With the new version of Drush there are some built in tools to help manage these files.

At the time of this writing, the recommended version of Drush is 6; however, this article uses commands that were introduced with version 7. Before you can try any of these, you’ll need to be running that version of Drush. The tricky part is that it currently does not have a full release. Typically, you would not want to install a project’s dev release in a production environment. I’m going to assume you will be working locally, on a development server, or are confident you can’t hurt anything otherwise.

In a previous article I explained how to install Drush using Pear; however, the project is shifting to Composer. You can still install via Pear, or even manually, but it's recommended you switch to Composer. Drush has also been moved to GitHub; you will find additional instructions for installing with something other than composer there.

Assuming your environment already has Composer installed, get the latest release of Drush 7 and issue the below command.

composer global require drush/drush:dev-master --prefer-source

Next, verify that it installed:

drush version

The output should indicate you have Drush 7.0-dev, or something along those lines. If it didn't work you may need to log out and back in again before your SSH user will know it's installed.

Now that we have the latest and greatest, the next thing to do is get Drupal 8. Using Drush you can request a specific version of Drupal, or any project, by providing the version number. If you don’t provide a version it will find the recommended version and download that instead.

To get the dev version of Drupal, type this:

drush dl drupal-8.x-dev

Next, let’s get a site installed. Keep in mind that you will need to configure your web server and database since this command only handles the install of Drupal.

Categories: Drupal

Imagefield focus point

New Drupal Modules - 16 January 2015 - 6:47am
Imagefield focus point Overview

"Intelligent cropping for flexible image containers." This module exposes an
image formatter which utilises the library
jquery-focuspoint by jonom.

Categories: Drupal

Funky Date

New Drupal Modules - 16 January 2015 - 6:04am

This modules adds a formatter for date fields, it allows you to hide duplicate date parts.

Examples

  1. 10 December 2014 to 15 December 2014 will be outputted as 10 - 15 December 2014
  2. 10 November 2014 to 15 December 2014 will be outputted as 10 November - 15 December 2014
  3. 10/12/2014 to 15/12/2014 will be outputted as 10 - 15/12/2014
Categories: Drupal
Syndicate content


Google+
about seo