Planet Drupal

Syndicate content
Drupal.org - aggregated feeds in category Planet Drupal
Updated: 15 min 6 sec ago

Code Karate: Drupal 7 Sweaver Module: Change your theme style with no CSS code

Thu, 12/11/2014 - 14:49
div class=field field-name-field-episode-number field-type-number-integer field-label-abovediv class=field-labelEpisode Number:nbsp;/divdiv class=field-itemsdiv class=field-item even185/div/div/divdiv class=field field-name-field-ddod-video field-type-file field-label-hiddendiv class=field-itemsdiv class=field-item evenimg src=http://codekarate.com/sites/default/files/styles/large/public/media-youtube/U_DnhKbcpVc.jpg?itok=cap0TBFO alt=Drupal Role Assign Module: Controlling who can assign what roles on your Drupal site //div/div/divdiv class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpThe a href=https://www.drupal.org/project/sweaver rel=nofollowDrupal 7 Sweaver module/a makes it easy to change the style of your Drupal theme without having to write any CSS code or dig through any template files. The Sweaver module provides a simple to use designer toolbar that sits at the bottom of the page and allows you to instantly change the look of your Drupal theme./p/div/div/divdiv class=field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-abovediv class=field-labelTags:nbsp;/divdiv class=field-itemsdiv class=field-item evena href=/category/tags/drupalDrupal/a/divdiv class=field-item odda href=/category/tags/drupal/drupal-7Drupal 7/a/divdiv class=field-item evena href=/category/tags/drupal/theme-developmentTheme Development/a/divdiv class=field-item odda href=/category/tags/drupal-planetDrupal Planet/a/divdiv class=field-item evena href=/category/tags/uidesignUI/Design/a/divdiv class=field-item odda href=/category/tags/uidesign/cssCSS/a/div/div/div

Code Karate: Smart Paging: How to display a node on multiple pages

Thu, 12/11/2014 - 14:18
div class=field field-name-field-episode-number field-type-number-integer field-label-abovediv class=field-labelEpisode Number:nbsp;/divdiv class=field-itemsdiv class=field-item even184/div/div/divdiv class=field field-name-field-ddod-video field-type-file field-label-hiddendiv class=field-itemsdiv class=field-item evenimg src=http://codekarate.com/sites/default/files/styles/large/public/media-youtube/iK1aCGMBQZw.jpg?itok=A-52XsMn alt=Smart Paging: How to display content on multiple pages //div/div/divdiv class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpThe a href=https://www.drupal.org/project/smart_paging rel=nofollowSmart Paging module/a is one of those nice to have modules. This module allows the ability to break content on a particular node into multiple pages. It is important to remember though that this doesn't mean you have to create multiple nodes or Drupal pages. This module works off of the same node. Neat! /p/div/div/divdiv class=field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-abovediv class=field-labelTags:nbsp;/divdiv class=field-itemsdiv class=field-item evena href=/category/tags/drupalDrupal/a/divdiv class=field-item odda href=/category/tags/drupal/core-concepts/content-typesContent Types/a/divdiv class=field-item evena href=/category/tags/drupal/drupal-7Drupal 7/a/divdiv class=field-item odda href=/category/tags/drupal/site-buildingSite Building/a/divdiv class=field-item evena href=/category/tags/drupal-planetDrupal Planet/a/div/div/div

Metal Toad: Drupal 8 Migrations, part 4: Migrating Nodes from Drupal 7

Thu, 12/11/2014 - 01:51
span class=field field-node--title field-name-title field-type-string field-label-hidden data-quickedit-field-id=node/923/title/en/rssDrupal 8 Migrations, part 4: Migrating Nodes from Drupal 7/span span class=field field-node--created field-name-created field-type-created field-label-hidden data-quickedit-field-id=node/923/created/en/rssDecember 10th, 2014/span span class=field field-node--uid field-name-uid field-type-entity-reference field-label-hidden data-quickedit-field-id=node/923/uid/en/rssa title=View user profile. href=/people/keithdechant lang= about=/people/keithdechant typeof=schema:Person property=schema:name datatype= class=usernameKeith Dechant /a/span div class=field field-node--body field-name-body field-type-text-with-summary field-label-hidden data-quickedit-field-id=node/923/body/en/rss div class=field-items div class=field-itempDrupal 8 provides a flexible, plugin-based architecture for migrating data into a site. In a href=/blog/migrating-taxonomy-drupal-7-to-drupal-8Part 3 of this series/aspan, we explored how to migrate taxonomies from a Drupal 7 site. We will now expand on this by migrating basic nodes from a Drupal 7 site into Drupal 8./span/p pThe code examples in this post build on the migration module begun in a href=/blog/migrating-users-drupal-7-to-drupal-8Part 2 of this series/a. If you are trying this code out yourself, it is recommended to start building your custom migration module according to the examples in that post./p h3The game plan for migrating nodes/h3 pBecause Drupal nodes can be of many types and have many different user-defined fields, it is complicated to write a single migration script that can handle all fields for all node types. To keep things simple, we will only migrate the built-in Article content type, which has the same default fields in Drupal 7 and Drupal 8./p pThe eventual plan of the Migrate Drupal core module is to build a dynamic migration path that can migrate the fields for any content type. When this is completed, it will likely supersede some of the code shown in this article./p h3The migration definition/h3 pStarting with the Migrate Custom module we created in Part 2, we now add the following configuration file./p pspan class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/config/install/migrate.migration.custom_article.yml/code/span/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalid: custom_article source: plugin: custom_article destination: plugin: entity:node type: article bundle: article process: nid: nid vid: vid type: type langcode: plugin: static_map bypass: true source: language map: und: en title: title uid: uid status: status created: created changed: changed promote: promote sticky: sticky 'body/format': plugin: static_map bypass: true source: body_format map: 1: plain_text 2: restricted_html 3: full_html 4: full_html 'body/value': body_value 'body/summary': body_summary field_tags: tags field_image: images/pre/div /div pPay attention to the last two fields in the definition, field_tags and field_image. These fields can be configured to accept multiple values. (In the case of field_image the out-of-the-box configuration allows only one value, but this is easy to change using the Admin UI.) We account for these in the migration by providing only a single property name here. In our source plugin below, we will set these properties to be arrays, thus allowing as many values as exist in our source data./p pWhat's more, field_image, like the body, is a compound field, in this case consisting of a file ID, ALT text, width, and height. We could specify those values in the definition, but that would limit us to importing only one image. Instead, we will use an associative array in our source plugin to populate all the components of the compound field./p h3The source plugin/h3 pSimilar to our Users source plugin in a href=/blog/migrating-users-drupal-7-to-drupal-8Part 2 of this series/a, our Blog source definition needs to implement both the span class=geshifiltercode class=text geshifilter-textquery()/code/span and span class=geshifiltercode class=text geshifilter-textprocessRow()/code/span methods. We will do this in the following file:/p pspan class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/src/Plugin/migrate/source/Article.php/code/span/p div class=geshifilter div class=php geshifilter-php style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalspan style=color: #000000; font-weight: bold;lt;?php/span   span style=color: #009933; font-style: italic;/** * @file * Contains \Drupal\migrate_custom\Plugin\migrate\source\Article. *//span   span style=color: #000000; font-weight: bold;namespace/span Drupal\migrate_custom\Plugin\migrate\sourcespan style=color: #339933;;/span   span style=color: #000000; font-weight: bold;use/span Drupal\migrate\Plugin\SourceEntityInterfacespan style=color: #339933;;/span span style=color: #000000; font-weight: bold;use/span Drupal\migrate\Rowspan style=color: #339933;;/span span style=color: #000000; font-weight: bold;use/span Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBasespan style=color: #339933;;/span   span style=color: #009933; font-style: italic;/** * Drupal 7 Blog node source plugin * * @MigrateSource( * id = custom_article * ) *//span span style=color: #000000; font-weight: bold;class/span Article span style=color: #000000; font-weight: bold;extends/span DrupalSqlBase span style=color: #000000; font-weight: bold;implements/span SourceEntityInterface span style=color: #009900;{/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span queryspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #666666; font-style: italic;// this queries the built-in metadata, but not the body, tags, or images./span span style=color: #000088;$query/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;select/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'node'/spanspan style=color: #339933;,/span span style=color: #0000ff;'n'/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;condition/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'n.type'/spanspan style=color: #339933;,/span span style=color: #0000ff;'article'/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;fields/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'n'/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/span span style=color: #0000ff;'nid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'vid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'type'/spanspan style=color: #339933;,/span span style=color: #0000ff;'language'/spanspan style=color: #339933;,/span span style=color: #0000ff;'title'/spanspan style=color: #339933;,/span span style=color: #0000ff;'uid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'status'/spanspan style=color: #339933;,/span span style=color: #0000ff;'created'/spanspan style=color: #339933;,/span span style=color: #0000ff;'changed'/spanspan style=color: #339933;,/span span style=color: #0000ff;'promote'/spanspan style=color: #339933;,/span span style=color: #0000ff;'sticky'/spanspan style=color: #339933;,/span span style=color: #009900;)/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$query/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;orderBy/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'nid'/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$query/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span fieldsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$fields/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;baseFields/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$fields/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'body/format'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Format of body'/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$fields/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'body/value'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Full text of body'/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$fields/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'body/summary'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Summary of body'/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$fields/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span prepareRowspan style=color: #009900;(/spanRow span style=color: #000088;$row/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$nid/span span style=color: #339933;=/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;getSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'nid'/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span   span style=color: #666666; font-style: italic;// body (compound field with value, summary, and format)/span span style=color: #000088;$result/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;getDatabase/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;query/spanspan style=color: #009900;(/spanspan style=color: #0000ff;' SELECT fld.body_value, fld.body_summary, fld.body_format FROM {field_data_body} fld WHERE fld.entity_id = :nid '/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;':nid'/span span style=color: #339933;=gt;/span span style=color: #000088;$nid/spanspan style=color: #009900;)/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;foreach/span span style=color: #009900;(/spanspan style=color: #000088;$result/span span style=color: #b1b100;as/span span style=color: #000088;$record/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'body_value'/spanspan style=color: #339933;,/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;body_value/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'body_summary'/spanspan style=color: #339933;,/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;body_summary/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'body_format'/spanspan style=color: #339933;,/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;body_format/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #666666; font-style: italic;// taxonomy term IDs/span span style=color: #666666; font-style: italic;// (here we use MySQL's GROUP_CONCAT() function to merge all values into one row.)/span span style=color: #000088;$result/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;getDatabase/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;query/spanspan style=color: #009900;(/spanspan style=color: #0000ff;' SELECT GROUP_CONCAT(fld.field_tags_tid) as tids FROM {field_data_field_tags} fld WHERE fld.entity_id = :nid '/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;':nid'/span span style=color: #339933;=gt;/span span style=color: #000088;$nid/spanspan style=color: #009900;)/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;foreach/span span style=color: #009900;(/spanspan style=color: #000088;$result/span span style=color: #b1b100;as/span span style=color: #000088;$record/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #b1b100;if/span span style=color: #009900;(/spanspan style=color: #339933;!/spana href=http://www.php.net/is_nullspan style=color: #990000;is_null/span/aspan style=color: #009900;(/spanspan style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;tids/spanspan style=color: #009900;)/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'tags'/spanspan style=color: #339933;,/span a href=http://www.php.net/explodespan style=color: #990000;explode/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;','/spanspan style=color: #339933;,/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;tids/spanspan style=color: #009900;)/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span span style=color: #009900;}/span   span style=color: #666666; font-style: italic;// images/span span style=color: #000088;$result/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;getDatabase/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;query/spanspan style=color: #009900;(/spanspan style=color: #0000ff;' SELECT fld.field_image_fid, fld.field_image_alt, fld.field_image_title, fld.field_image_width, fld.field_image_height FROM {field_data_field_image} fld WHERE fld.entity_id = :nid '/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;':nid'/span span style=color: #339933;=gt;/span span style=color: #000088;$nid/spanspan style=color: #009900;)/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #666666; font-style: italic;// Create an associative array for each row in the result. The keys/span span style=color: #666666; font-style: italic;// here match the last part of the column name in the field table. /span span style=color: #000088;$images/span span style=color: #339933;=/span span style=color: #009900;[/spanspan style=color: #009900;]/spanspan style=color: #339933;;/span span style=color: #b1b100;foreach/span span style=color: #009900;(/spanspan style=color: #000088;$result/span span style=color: #b1b100;as/span span style=color: #000088;$record/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$images/spanspan style=color: #009900;[/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #009900;[/span span style=color: #0000ff;'target_id'/span span style=color: #339933;=gt;/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;field_files_fid/spanspan style=color: #339933;,/span span style=color: #0000ff;'alt'/span span style=color: #339933;=gt;/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;field_image_alt/spanspan style=color: #339933;,/span span style=color: #0000ff;'title'/span span style=color: #339933;=gt;/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;field_image_title/spanspan style=color: #339933;,/span span style=color: #0000ff;'width'/span span style=color: #339933;=gt;/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;field_image_width/spanspan style=color: #339933;,/span span style=color: #0000ff;'height'/span span style=color: #339933;=gt;/span span style=color: #000088;$record/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;field_image_height/spanspan style=color: #339933;,/span span style=color: #009900;]/spanspan style=color: #339933;;/span span style=color: #009900;}/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'images'/spanspan style=color: #339933;,/span span style=color: #000088;$images/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span   span style=color: #b1b100;return/span parentspan style=color: #339933;::/spanspan style=color: #004000;prepareRow/spanspan style=color: #009900;(/spanspan style=color: #000088;$row/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span getIdsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$ids/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'nid'/spanspan style=color: #009900;]/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'type'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #0000ff;'integer'/spanspan style=color: #339933;;/span span style=color: #000088;$ids/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'nid'/spanspan style=color: #009900;]/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'alias'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #0000ff;'n'/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$ids/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span bundleMigrationRequiredspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #b1b100;return/span span style=color: #009900; font-weight: bold;FALSE/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span entityTypeIdspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #b1b100;return/span span style=color: #0000ff;'node'/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * Returns the user base fields to be migrated. * * @return array * Associative array having field name as key and description as value. *//span span style=color: #000000; font-weight: bold;protected/span span style=color: #000000; font-weight: bold;function/span baseFieldsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$fields/span span style=color: #339933;=/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/span span style=color: #0000ff;'nid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Node ID'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'vid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Version ID'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'type'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Type'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'title'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Title'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'format'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Format'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'teaser'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Teaser'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'uid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Authored by (uid)'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'created'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Created timestamp'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'changed'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Modified timestamp'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'status'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Published'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'promote'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Promoted to front page'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'sticky'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Sticky at top of lists'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'language'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Language (fr, en, ...)'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$fields/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009900;}/span/pre/div /div h3Running the migration/h3 pWe need to add a new line to the end of our manifest.yml file:/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normal- custom_article/pre/div /div pRemember to reinstall the module to load the new migration configuration. See a href=/blog/migrating-taxonomy-drupal-7-to-drupal-8#reloading_configurationPart 3 of this series/a for more information./p pAs we did with our user migration, we now run the migration using Drush./p pspan class=geshifiltercode class=text geshifilter-textdrush migrate-manifest manifest.yml --legacy-db-url=mysql://{dbuser}:{dbpass}@localhost/{dbname}/code/span/p h3Next steps/h3 pThis migration only handles a single content type, and only the fields that are configured in an out-of-the-box Drupal site. To practice what you have learned here, try adding some custom fields to the content types, then add them to the migration definition and source plugin. For more practice, try writing a custom migration for a different content type, like the Basic Page, or a custom content type from your site./p /div /div /div

Metal Toad: Drupal 8 Migrations, part 3: Migrating Taxonomies from Drupal 7

Thu, 12/11/2014 - 01:38
span class=field field-node--title field-name-title field-type-string field-label-hidden data-quickedit-field-id=node/914/title/en/rssDrupal 8 Migrations, part 3: Migrating Taxonomies from Drupal 7/span span class=field field-node--created field-name-created field-type-created field-label-hidden data-quickedit-field-id=node/914/created/en/rssDecember 10th, 2014/span span class=field field-node--uid field-name-uid field-type-entity-reference field-label-hidden data-quickedit-field-id=node/914/uid/en/rssa title=View user profile. href=/people/keithdechant lang= about=/people/keithdechant typeof=schema:Person property=schema:name datatype= class=usernameKeith Dechant /a/span div class=field field-node--body field-name-body field-type-text-with-summary field-label-hidden data-quickedit-field-id=node/914/body/en/rss div class=field-items div class=field-itempDrupal 8 provides a flexible, plugin-based architecture for migrating data into a site. In a href=/blog/migrating-users-drupal-7-to-drupal-8Part 2 of this series/a, we explored how to migrate users from a Drupal 7 site. We will now expand on this by migrating Taxonomy vocabularies and terms from a Drupal 7 site into Drupal 8./p pThis article continues our work from a href=/blog/migrating-users-drupal-7-to-drupal-8Part 2/a. The code examples pick up where that post left off. If you are trying this code out yourself, it is recommended to start building your custom migration module according to the examples in that post./p h3Migrating Taxonomy Vocabularies/h3 pThe Migrate Drupal module (in Drupal 8 core) already contains a migration definition and source plugins to migrate taxonomy data from Drupal 6 to Drupal 8. All we need to do is to adapt the existing code to work with Drupal 7./p pThe migration definition:/p pStarting with the Migrate Custom module we created in Part 2, we now add the following configuration file./p pspan class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/config/install/migrate.migration.custom_taxonomy_vocabulary.yml/code/span/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalid: custom_taxonomy_vocabulary label: Drupal 7 taxonomy vocabularies migration_groups: - Drupal 7 source: plugin: custom_taxonomy_vocabulary process: vid: - plugin: machine_name source: machine_name - plugin: dedupe_entity entity_type: taxonomy_vocabulary field: vid length: 32 label: name name: name description: description hierarchy: hierarchy module: module weight: weight destination: plugin: entity:taxonomy_vocabulary/pre/div /div pHere we have examples of a few plugins not seen in the previous post:/p ullispan class=geshifiltercode class=text geshifilter-textmachine_name/code/span converts the string into a valid machine name./li lispan class=geshifiltercode class=text geshifilter-textdedupe_entity/code/span prevents machine name conflicts, which would cause imported data to overwrite existing data. For example, a machine name foo would be renamed to foo_2 if name foo already existed./li /ulpThe source plugin/p pTo define the source of our vocabulary data, we create a new file span class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/src/Plugin/migrate/source/Vocabulary.php/code/span with the following contents:/p div class=geshifilter div class=php geshifilter-php style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalspan style=color: #000000; font-weight: bold;lt;?php/span   span style=color: #009933; font-style: italic;/** * @file * Contains \Drupal\migrate_custom\Plugin\migrate\source\Vocabulary. *//span   span style=color: #000000; font-weight: bold;namespace/span Drupal\migrate_custom\Plugin\migrate\sourcespan style=color: #339933;;/span   span style=color: #000000; font-weight: bold;use/span Drupal\migrate\Rowspan style=color: #339933;;/span span style=color: #000000; font-weight: bold;use/span Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBasespan style=color: #339933;;/span   span style=color: #009933; font-style: italic;/** * Drupal 7 vocabularies source from database. * * @MigrateSource( * id = custom_taxonomy_vocabulary, * source_provider = taxonomy * ) *//span span style=color: #000000; font-weight: bold;class/span Vocabulary span style=color: #000000; font-weight: bold;extends/span DrupalSqlBase span style=color: #009900;{/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span queryspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$query/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;select/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'taxonomy_vocabulary'/spanspan style=color: #339933;,/span span style=color: #0000ff;'v'/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;fields/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'v'/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/span span style=color: #0000ff;'vid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'name'/spanspan style=color: #339933;,/span span style=color: #0000ff;'description'/spanspan style=color: #339933;,/span span style=color: #0000ff;'hierarchy'/spanspan style=color: #339933;,/span span style=color: #0000ff;'module'/spanspan style=color: #339933;,/span span style=color: #0000ff;'weight'/spanspan style=color: #339933;,/span span style=color: #0000ff;'machine_name'/span span style=color: #009900;)/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$query/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span fieldsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #b1b100;return/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/span span style=color: #0000ff;'vid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The vocabulary ID.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'name'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The name of the vocabulary.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'description'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The description of the vocabulary.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'help'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Help text to display for the vocabulary.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'relations'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'hierarchy'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'weight'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The weight of the vocabulary in relation to other vocabularies.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'parents'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;The Drupal term IDs of the term's parents./spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'node_types'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The names of the node types the vocabulary may be used with.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span getIdsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$ids/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'vid'/spanspan style=color: #009900;]/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'type'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #0000ff;'integer'/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$ids/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009900;}/span/pre/div /div pNote: this file was adapted from the Drupal 6 version in Drupal 8 core. For the original file, see span class=geshifiltercode class=text geshifilter-textcore/modules/migrate_drupal/src/Plugin/migrate/source/d6/Vocabulary.php/code/span/p pThe structure of this file is similar to the User source plugin in the previous article. However, because all the data we need is stored in the `taxonomy_vocabulary` table in the source database, we do not need to define the span class=geshifiltercode class=text geshifilter-textprepareRow()/code/span method./p h3Migrating Taxonomy Terms/h3 pWe can use a second migration definition to migrate our taxonomy terms. Create the following file:/p pspan class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/config/install/migrate.migration.custom_taxonomy_term.yml/code/span/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalid: custom_taxonomy_term label: Drupal 7 taxonomy terms migration_groups: - Drupal 7 source: plugin: custom_taxonomy_term process: tid: tid vid: plugin: migration migration: custom_taxonomy_vocabulary source: vid name: name description: description weight: weight parent: - plugin: skip_process_on_empty source: parent - plugin: migration migration: custom_taxonomy_term changed: timestamp destination: plugin: entity:taxonomy_term migration_dependencies: required: - custom_taxonomy_vocabulary/pre/div /div pIn this migration, we make use of the span class=geshifiltercode class=text geshifilter-textmigration/code/span process plugin for two of our properties, the vocabulary ID and the parent term ID. This preserves these references in case the referenced entity's ID or machine name changed during the import./p pSome machine names and/or IDs will likely change when running your import. This is to be expected, especially because Drupal 8 stores taxonomy vocabularies in the 'config' table, where they are accessed by their machine names instead of by the numeric IDs used in Drupal 7. Fortunately for us, the Migrate module records a map of the old and new IDs in the database. We can then use the span class=geshifiltercode class=text geshifilter-textmigration/code/span source plugin to easily look up the old ID or machine name./p pThe source plugin/p pTo define the source of our term data, we create a new file span class=geshifiltercode class=text geshifilter-textmodules/migrate_custom/src/Plugin/migrate/source/Term.php/code/span with the following contents:/p div class=geshifilter div class=php geshifilter-php style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normalspan style=color: #000000; font-weight: bold;lt;?php/span   span style=color: #009933; font-style: italic;/** * @file * Contains \Drupal\migrate_custom\Plugin\migrate\source\Term. *//span   span style=color: #000000; font-weight: bold;namespace/span Drupal\migrate_custom\Plugin\migrate\sourcespan style=color: #339933;;/span   span style=color: #000000; font-weight: bold;use/span Drupal\migrate\Rowspan style=color: #339933;;/span span style=color: #000000; font-weight: bold;use/span Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBasespan style=color: #339933;;/span   span style=color: #009933; font-style: italic;/** * Drupal 7 taxonomy terms source from database. * * @todo Support term_relation, term_synonym table if possible. * * @MigrateSource( * id = custom_taxonomy_term, * source_provider = taxonomy * ) *//span span style=color: #000000; font-weight: bold;class/span Term span style=color: #000000; font-weight: bold;extends/span DrupalSqlBase span style=color: #009900;{/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span queryspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$query/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;select/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'taxonomy_term_data'/spanspan style=color: #339933;,/span span style=color: #0000ff;'td'/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;fields/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'td'/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;'tid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'vid'/spanspan style=color: #339933;,/span span style=color: #0000ff;'name'/spanspan style=color: #339933;,/span span style=color: #0000ff;'description'/spanspan style=color: #339933;,/span span style=color: #0000ff;'weight'/spanspan style=color: #339933;,/span span style=color: #0000ff;'format'/spanspan style=color: #009900;)/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;distinct/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$query/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span fieldsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #b1b100;return/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/span span style=color: #0000ff;'tid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The term ID.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'vid'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Existing term VID'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'name'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The name of the term.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'description'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'The term description.'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'weight'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'Weight'/spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #0000ff;'parent'/span span style=color: #339933;=gt;/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;t/spanspan style=color: #009900;(/spanspan style=color: #0000ff;The Drupal term IDs of the term's parents./spanspan style=color: #009900;)/spanspan style=color: #339933;,/span span style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span prepareRowspan style=color: #009900;(/spanRow span style=color: #000088;$row/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #666666; font-style: italic;// Find parents for this row./span span style=color: #000088;$parents/span span style=color: #339933;=/span span style=color: #000088;$this/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;select/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'taxonomy_term_hierarchy'/spanspan style=color: #339933;,/span span style=color: #0000ff;'th'/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;fields/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'th'/spanspan style=color: #339933;,/span a href=http://www.php.net/arrayspan style=color: #990000;array/span/aspan style=color: #009900;(/spanspan style=color: #0000ff;'parent'/spanspan style=color: #339933;,/span span style=color: #0000ff;'tid'/spanspan style=color: #009900;)/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;condition/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'tid'/spanspan style=color: #339933;,/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;getSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'tid'/spanspan style=color: #009900;)/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;execute/spanspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #339933;-gt;/spanspan style=color: #004000;fetchCol/spanspan style=color: #009900;(/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #000088;$row/spanspan style=color: #339933;-gt;/spanspan style=color: #004000;setSourceProperty/spanspan style=color: #009900;(/spanspan style=color: #0000ff;'parent'/spanspan style=color: #339933;,/span span style=color: #000088;$parents/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span parentspan style=color: #339933;::/spanspan style=color: #004000;prepareRow/spanspan style=color: #009900;(/spanspan style=color: #000088;$row/spanspan style=color: #009900;)/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009933; font-style: italic;/** * {@inheritdoc} *//span span style=color: #000000; font-weight: bold;public/span span style=color: #000000; font-weight: bold;function/span getIdsspan style=color: #009900;(/spanspan style=color: #009900;)/span span style=color: #009900;{/span span style=color: #000088;$ids/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'tid'/spanspan style=color: #009900;]/spanspan style=color: #009900;[/spanspan style=color: #0000ff;'type'/spanspan style=color: #009900;]/span span style=color: #339933;=/span span style=color: #0000ff;'integer'/spanspan style=color: #339933;;/span span style=color: #b1b100;return/span span style=color: #000088;$ids/spanspan style=color: #339933;;/span span style=color: #009900;}/span   span style=color: #009900;}/span/pre/div /div h3 id=reloading_configurationReloading the configuration/h3 pRemember that migrations are configuration entities. To reload the configuration, we need to uninstall and reinstall our module. Here's a handy Drush command to do this:/p pspan class=geshifiltercode class=text geshifilter-textdrush pm-uninstall migrate_custom -y amp;amp; drush en migrate_custom/code/span/p h3Running the migration/h3 pWe need to add some new lines to our manifest.yml file:/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normal# A D7 user and taxonomy migration, with dependencies. - custom_user - custom_taxonomy_vocabulary - custom_taxonomy_term/pre/div /div pAs we did with our user migration, we now run the migration using Drush./p pspan class=geshifiltercode class=text geshifilter-textdrush migrate-manifest manifest.yml --legacy-db-url=mysql://{dbuser}:{dbpass}@localhost/{dbname}/code/span/p pWhen including multiple migrations in a single manifest, be aware that span class=geshifiltercode class=text geshifilter-textdrush migrate-manifest/code/span doesn't always run them in the order you specified. If, for example, your taxonomy migrations are being run before your user migration, and your taxonomy terms end up missing their UIDs, you might need to create two separate manifest files, to give yourself better control over the order./p pNext post: a href=/blog/migrating-nodes-drupal-7-to-drupal-8Migrating Nodes from Drupal 7/a./p /div /div /div

PreviousNext: Automated style guides with KSS-node

Wed, 12/10/2014 - 22:47
pDuring PreviousNext’s weekly developers meeting I recently gave a lightning talk about how to use a href=https://github.com/kss-node/kss-nodekss-node/a to auto-generate a website style guide. If you’ve even tangentially followed front-end development, you’ll find that this is yet-another blog post describing “project A implementing technology B with hip, new language/framework C.”/p pBut kss-node emis/em really cool and useful, especially if you understand how it fits into the larger picture of strongthe new web development/strong process. Fortunately, my a href=https://www.previousnext.com.au/blog/style-guide-driven-development-new-web-developmentprevious post/a provides that big picture, so if you’d like to understand how Agile is turning web development inside-out and how style-guide-driven development is the new website development workflow, please go read that first. Then head back here for the screencast to get you started with kss-node./p span property=dc:title content=Automated style guides with KSS-node class=rdf-meta element-hidden/span

Blue Drop Awards: We're Looking for Guest Bloggers!

Wed, 12/10/2014 - 21:20
div class=field field-name-body field-type-text-with-summary field-label-hidden div class=field-items div class=field-item even property=content:encoded pimg alt=image courtesy of http://onlinebusiness.volusion.com/ src=http://onlinebusiness.volusion.com/assets/GuestBlogger.png style=height: 25%; width: 25%; margin: 2px; float: left; //p pDo you have a unique way of using Drupal? Can you offer helpful tips about Drupal or even have creative solutions to those nagging problems associated with Drupal? Then we would like to offer you a free platform on which to share your voice./p pimg alt=image courtesy of http://www.landconference.org/ src=http://www.landconference.org/journals/2011-creative/images/index.jpg style=height: 25%; width: 25%; margin-left: 2px; margin-right: 2px; float: right; //p pWe are looking for people who would like to be featured on the Blue Drop Awards' website discussing the issues and topics surrounding the Drupal platform./p pAre you more into doing than telling? Create a video or podcast that offers helpful tips or information relevant to the Drupal community./p p/pcenterimg alt=image courtesy of amazee labs src=http://www.amazeelabs.com/sites/default/files/styles/service_image/public/drupal-community.jpg?itok=XAT7s20P style=height: 50%; width: 50%; margin-left: 2px; margin-right: 2px; //center pNot into creating content but still want to help? We still need volunteers to help manage the blog or newsletters./p pIf you're interested, please contact a href=mailto:erik@bluedropawards.orgerik@bluedropawards.org/a./p /div /div /div span property=dc:title content=We#039;re Looking for Guest Bloggers! class=rdf-meta element-hidden/span

Acquia: A Symfony Shop Embraces Drupal 8 Gets Down to Business

Wed, 12/10/2014 - 18:42
div class=form-item form-type-item labelLanguage /label Undefined /div div class=field field-name-body field-type-text-with-summary field-label-hidden div class=field-items div property=content:encoded class=field-item evenp strongChris Jolly, CTO a href=http://ontraq.eu/Ontraq Europe/a,/strong and his company have a strong technical background, going back to old school (pre-internet) IT. Their main focus until now has been eCommerce, Symfony, and solving hard problems like legacy-system integrations. Now, thanks to its use of Symfony framework components, they've started using Drupal 8 as their content management technology of choice! Chris and I talked at DrupalCon Amsterdam about getting there and what they're up to now. /p/div /div /div span property=dc:title content=A Symfony Shop Embraces Drupal 8 amp; Gets Down to Business class=rdf-meta element-hidden/span

Drupal Watchdog: Migrate Overview

Wed, 12/10/2014 - 18:16
div class=field field--article-edit-printtype field-type-list-text field-label-hidden field--rss Article /div div class=field field--article-body field-type-text-long field-label-hidden field--rss pimg src=http://cdn1.drupalwatchdog.com/sites/default/files/images/web/4.1-migrateoverview.jpg alt= width=45% class=img-responsive img-thumbnail margin-left align=right /br / Two years into the development of Drupal 8, Dries Buytaert announced that Drupal 8.0 might ship without an upgrade path./p p This unorthodox decision was made to support substantial improvements in Drupal’s major version upgrade process by introducing a robust new sub-system based on the popular contributed modules Migrate and Migrate D2D. The sub-system includes the Migrate module, which provides the basic framework and API, and the Migrate Drupal module, which provides the upgrade paths and framework to enable other Drupal-to-Drupal use cases in contrib./p p The substantial wins with this new approach include the ability to move directly from Drupal 6 to Drupal 8 – as well as the possibility of providing more fine-grained control over the process – and the option of continuous content migration./p p The migration team is working extraordinarily hard to be ready by the time that D8 is ready for beta. As of March 31, Migrate API has been committed to core. The last blocking issues for Migrate Drupal were resolved during the DevDays sprint, and the team will begin submitting patches for the D6 to D8 migration path to the core queue any day now./p h3A Drupal 6 to Drupal 8 upgrade without Migrate/h3 pWithout the new API, an abbreviated move from Drupal 6 to Drupal 8 would have looked something like:/p olliBackup your database /liliUpdate core and contrib to the latest version of 6 /liliDisable all contributed modules and switch to the core theme /liliDelete the D6 code and replace it with D7 core code /liliRun update.php /liliDownload the D7 contributed modules /liliEnable the contrib modules /liliRun update.php /liliRepeat to upgrade from D7 to D8 /li/olp For Drush users, the 'span class=geshifiltercode class=php geshifilter-phpdrush up/code/span' command would vastly simplify this, but two full upgrades — from 6 to 7, then 7 to 8 — would still have been required, inevitably losing data in each step./p /div

Annertech: Scalable Sustainable Media Management for Drupal Websites

Wed, 12/10/2014 - 18:08
span class=field field-node--title field-name-title field-type-string field-label-hiddenScalable amp; Sustainable Media Management for Drupal Websites/span div class=field field-node--body field-name-body field-type-text-with-summary field-label-hidden div class=field-items div class=field-itemp style type=text/css !--/*--![CDATA[/* !--*/ !--/*--![CDATA[/* !--*/ h2.western { font-family: Liberation Sans,sans-serif; font-size: 16pt; }h2.cjk { font-family: SimSun; font-size: 16pt; }h2.ctl { font-family: Lucida Sans; font-size: 16pt; }p { margin-bottom: 0.25cm; line-height: 120%; } /*--!]]]]![CDATA[*/ /*--!]]*/ /style/p/div /div /div

SitePoint PHP Drupal: 7 CRM Options Compatible with Drupal

Wed, 12/10/2014 - 18:00
ppI love Drupal and end up undertaking most of my programming projects with it. I have been using it for so long that I find it far easier to push out projects with Drupal than with anything else, despite it’s infamous learning curve./p pWhether you want to call Drupal a CMS (Content Management System), a CMF (Content Management Framework) or a CMSomething, the ‘C’ always stands for Content. Content is where Drupal shines and is what it’s designed for./p img src=http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2014/11/1416938561drupal8wide-1024x332.png alt=drupal8wide width=1024 height=332 class=alignnone size-large wp-image-95449 / pWhen an organisation is at a stage and mindset that they also want to manage their contacts and interactions effectively they will often need tools designed specifically for that function. These are generally referred to as a CRM, which stands for Client Relationship Manager or Constituent Relationship Manager, depending on the sector (For-Profit or Not-for-Profit respectively). CRMs are big business, with many free and paid options available, all with their own advantages and disadvantages./p pOften these interactions that people have with your organisation will include things such as registering for an event, making a donation, becoming a member, expressing interest in a product or receiving a newsletter. This all sounds quite simple, but often representing a business rule in the digital realm is very difficult as everyone thinks ‘their way’ is ‘the only way’ and that surely every off-the-shelf system should represent them out of the box./p/ppemContinue reading %a rel=nofollow href=http://www.sitepoint.com/7-crm-options-compatible-drupal/7 CRM Options Compatible with Drupal/a%/em/p

Code Drop: Drupal Security Tips for Developers

Wed, 12/10/2014 - 05:30
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpI’ve recently been reviewing a few security related patches and it soon became apparent that many developers make the same mistakes over and over in regards to best practices for security in a href=https://codedrop.com.au/drupalDrupal/a. So below, a very short post on the common mistakes and solutions./p h2Correct usage of t()/h2 pUse the right placeholder for a href=https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7t()/a. You should be using % and @ which are both escaped to protect against Cross Site Scripting vulnerabilities. Whenever you use ! as a placeholder, double check the content has already been escaped./p h2Escaping Output in #markup/h2 pIf you’re providing a custom field, widget and formatter you need to make sure that any content coming from the admin is correctly escaped. For example, you’re implementing hook_field_formatter_view() and doing something like:/p p /p/div/div/div

Drupal governance announcements: DrupalSouth - Early Bird tix almost sold out!

Wed, 12/10/2014 - 02:26
pThere are only a few early bird tickets left. So if you want one, grab it now./p pa href=https://melbourne2015.drupal.org.au/conference/tickets title=https://melbourne2015.drupal.org.au/conference/ticketshttps://melbourne2015.drupal.org.au/conference/tickets/a/p

Pixelite: How to add subtabs under the User Edit tab in Drupal

Wed, 12/10/2014 - 01:00
h2 id=tldrtl;dr;/h2 pTo get your tabs to appear on the user edit page use a href=https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_categories/7hook_user_categories()/a and a href=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_alter/7hook_menu_alter()/a./p h2 id=the-detailThe detail/h2 pGetting submenu items to appear within the user edit area of Drupal has not always worked as I would expect from reading the documentation around a href=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7hook_menu()/a. As it happens the user module provides hooks to make this quite simple./p pa href=https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_categories/7hook_user_categories()/a allows you to return a subset of the parameters you’d expect to see in a href=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7hook_menu()/a./p pIn this example we would have a new set of tabs added to the User Edit page. The first is emAccount/em and is now presented because we have more than one tab here now. The second is emReport Settings/em and it would have a URL like codeuser/12345/edit/report_settings/code where emreport_settings/em is taken from the name parameter./p div class=highlightprecode class=language-php data-lang=phpspan class=cplt;?php/span span class=sd/**/span span class=sd * Implements hook_user_categories()./span span class=sd *//span span class=kfunction/span span class=nfmy_module_user_categories/spanspan class=p()/span span class=p{/span span class=kreturn/span span class=karray/spanspan class=p(/span span class=karray/spanspan class=p(/span span class=s1#39;name#39;/span span class=o=gt;/span span class=s1#39;report_settings#39;/spanspan class=p,/span span class=s1#39;title#39;/span span class=o=gt;/span span class=nxt/spanspan class=p(/spanspan class=s1#39;Report settings#39;/spanspan class=p),/span span class=s1#39;weight#39;/span span class=o=gt;/span span class=mi1/spanspan class=p,/span span class=s1#39;access callback#39;/span span class=o=gt;/span span class=s1#39;user_edit_access#39;/spanspan class=p,/span span class=s1#39;access arguments#39;/span span class=o=gt;/span span class=karray/spanspan class=p(/spanspan class=mi1/spanspan class=p),/span span class=p)/span span class=p);/span span class=p}/span span class=cp?gt;/spanspan class=x/span/code/pre/div pAt this point we have a new menu item presented as a tab on the user edit page and clicking it takes us to a blank form with a submit button. I think this is due to the way menu items can inherit behaviour from parent menu items. We’ll be wanting to overload that behaviour though and present our own form. This can be done through a href=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_alter/7hook_menu_alter()/a./p pChecking the keys of the array passed to a href=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_alter/7hook_menu_alter()/a we should find that we have a new one called codeuser/%user_category/edit/report_settings/code. We can edit this one to point it at our preferred form built using the a href=https://api.drupal.org/api/drupal/includes%21form.inc/group/form_api/7Form API/a as usual./p div class=highlightprecode class=language-php data-lang=phpspan class=cplt;?php/span span class=sd/**/span span class=sd * Implements hook_menu_alter()./span span class=sd *//span span class=kfunction/span span class=nfmy_module_menu_alter/spanspan class=p(/spanspan class=oamp;/spanspan class=nv$callbacks/spanspan class=p)/span span class=p{/span span class=nv$callbacks/spanspan class=p[/spanspan class=s1#39;user/%user_category/edit/report_settings#39;/spanspan class=p][/spanspan class=s1#39;page arguments#39;/spanspan class=p]/span span class=o=/span span class=karray/spanspan class=p(/spanspan class=s1#39;my_module_user_report_settings#39;/spanspan class=p,/span span class=mi1/spanspan class=p);/span span class=c1// We need to set the file path as it defaults to the user module./span span class=nv$callbacks/spanspan class=p[/spanspan class=s1#39;user/%user_category/edit/report_settings#39;/spanspan class=p][/spanspan class=s1#39;file path#39;/spanspan class=p]/span span class=o=/span span class=nxdrupal_get_path/spanspan class=p(/spanspan class=s1#39;module#39;/spanspan class=p,/span span class=s1#39;my_module#39;/spanspan class=p);/span span class=nv$callbacks/spanspan class=p[/spanspan class=s1#39;user/%user_category/edit/report_settings#39;/spanspan class=p][/spanspan class=s1#39;file#39;/spanspan class=p]/span span class=o=/span span class=s1#39;my_module.user.inc#39;/spanspan class=p;/span span class=p}/span span class=cp?gt;/spanspan class=x/span/code/pre/div h2 id=gotchasGotchas/h2 ul liYou will want to be clearing your menu cache a lot while getting this working. Every edit will require a codedrush cc menu/code./li liEnsure you have set the codefile path/code in the hook_menu_alter() if you have your have your page callback or form function for drupal_get_form() in a separate file./li /ul h2 id=commentsComments/h2 pIf you have found that this post has been helpful ping me in the comments, on twitter (a href=http://twitter.com/unifex@Unifex/a) or on a href=http://drupal.orgD.o/a at a href=http://drupal.org/u/GoldGold/a./p

Chapter Three: Principles of Configuration Management - Part One

Tue, 12/09/2014 - 20:16
pThis is the first in a series of posts about Drupal 8's configuration management system. This system is one of its most eagerly anticipated features, a href=https://drupalize.me/blog/201406/drupal-8-survey-insightsaccording to a recent survey/a. The Configuration Management Initiative (CMI) was the a href=http://buytaert.net/configuration-management-in-drupal-8first Drupal 8 initiative to be announced in 2011/a, and we've learned a lot during thousands of hours of work on the initiative since then. These posts will share what we've learned and provide background on the why and how./pbr / br / pimg alt=A set of dials and controls symbolising configuration management in Drupal 8. data-picture-align=center data-picture-group=c3 src=http://www.chapterthree.com/sites/default/files/istock_000008458911small.jpg style=font-size: 13px; line-height: 20.0063037872314px; //p

Open Source Training: Filter Drupal Content Based on File Type

Tue, 12/09/2014 - 19:11
!-- Start ScreenSteps Content -- div class=LessonContent div class=LessonSummary pimg style=float: right; src=https://www.ostraining.com/images/drupal/file-filter.png alt=file filter /One of our members asked an interesting question about Views./p pThey had a file field on their user profiles. In that field, the user could upload an image, an audio file, or link to a YouTube video. So far, so good. However, in Views, they only wanted to show that field if it contained a video./p pHere's the solution to that problem. We're going to show you how to filter Drupal content based on the type of file that's attached to it./pimg src=//feeds.feedburner.com/~r/ostrainingdrupal/~4/LS1hbvxnGHc height=1 width=1 alt=/

Drupal Watchdog: Test Now! - Travis Integration for your Drupal Modules

Tue, 12/09/2014 - 18:46
div class=field field--body field-type-text-with-summary field-label-hidden field--rss pa href=https://travis-ci.org/Travis-CI/a is a free-for-OSS continuous integration server, which has become very popular in the PHP world. Drush, Symfony, and dreditor all use it for frequently testing their code base and pull requests for regressions and ensuring new functionality has the needed test coverage./p pCompared to the current Drupal testbot, Travis-CI allows testing of not only simpletest on PHP 5.3 (for Drupal 7 projects), but of most everything that you can install on a Debian system, e.g. QUnit for JavaScript, Behat, PHPUnit, but also Ruby based projects, Bash projects, Go projects, etc./p pYou can also test various scenarios in a matrix like setup, e.g. different PHP versions to ensure your code runs on both PHP 5.3 and 5.4 or with different versions of a dependent library./p pThis flexibility comes with a price however, because you need to setup the whole environment yourself. The selected PHP version (with xdebug) and composer are pre-installed, but that's it. The Drupal base installation, the running of the tests, the parsing of the test output, and ensuring dependencies are there is all your own responsibility./p pAnd because of that there are many different span class=geshifiltercode class=php geshifilter-php.travis.yml/code/span files floating around the net for various scenarios of setting up this or that, but in the end everyone re-invents the wheel. Until now…/p h2As Easy as it Gets/h2 pI am proud to announce the a href=https://github.com/LionsAd/drupal_ti drupal_ti project/a, which allows any module on drupal.org to easily leverage travis-ci.org for testing:/p ulliPHPUnit/li liSimpleTest/li liBehat/li /ulpThe process (which I will show in more detail below) is as simple as copying a generic span class=geshifiltercode class=php geshifilter-php.travis.yml.dist/code/span file as span class=geshifiltercode class=php geshifilter-php.travis.yml/code/span to your modules root, push your repository to Github, activate the repository at travis-ci.org and you are done./p pOh, and while you are at it, if you add a span class=geshifiltercode class=php geshifilter-php.coveralls.yml/code/span file, then code coverage is automatically reported to a href=http://coveralls.iocoveralls.io/a, too (for PHPUnit)./p pAll the hard work of installing drupal, running a web server, setting up Selenium, etc. is done by drupal_ti./p pSo you don't have to copy some span class=geshifiltercode class=php geshifilter-php.travis.yml/code/span you found on the net and spend hours debugging little edge cases (HHVM and sendmail, how to parse the simpletest output, etc.), but can depend on a proven and self-tested code base./p h2Features/h2 ullistrongDrupal 8 ready/strong: drupal_ti supports both Drupal 7 and 8 modules. Use span class=geshifiltercode class=php geshifilter-phpDRUPAL_TI_ENVIRONMENT=drupal-8/code/span for your Drupal 8 modules./li listrongTested/strong: drupal_ti tests its own code base for both Drupal 7 and Drupal 8 modules./li listrongModular architecture/strong: drupal_ti has so called 'runners' and you can combine either e.g. phpunit simpletest or run them as separate workers by specifying a matrix./li listrongEnvironment aware/strong: drupal_ti has a file for each environment, which makes the code generic for both Drupal 7 and 8./li listrongExamples provided/strong: drupal_ti provides easy examples of the needed files in span class=geshifiltercode class=php geshifilter-phptests/drupal-{7,8}/drupal_ti_test/code/span. So you can get started easily!/li listrongExtensible/strong: By specifying span class=geshifiltercode class=php geshifilter-phpDRUPAL_TI_SCRIPT_DIR_BEFORE/code/span or span class=geshifiltercode class=php geshifilter-phpDRUPAL_TI_SCRIPT_DIR_AFTER/code/span you can easily create your own runners and environment includes that run before or after the main runners. This could even come from composer./li listrongUsable for non-travis CI/strong: Because drupal-ti is just a command and because span class=geshifiltercode class=php geshifilter-php.travis.yml/code/span just has some environment vars, you can just copy the main declarations to some span class=geshifiltercode class=php geshifilter-phpenvironment.sh/code/span file, set the span class=geshifiltercode class=php geshifilter-phpTRAVIS_BUILD_DIR/code/span and use it locally, too./li /ulh2An Example Conversion/h2 pMy module registry_autoload uses simpletest on drupal.org to test its features. Now I want to test some advanced trait support, which needs PHP 5.4, so travis-ci.org is an option to do so./p h3Step 1 - Create the GitHub Repository and Push Your Code/h3 olliSign in to github.com/li liClick: + gt; New repository, enter: registry_autoload/li liClick: Create repository/li /olpimg src=http://cdn1.drupalwatchdog.com/sites/default/files/github-create-new-repository.png class=img-responsive alt=Create a new GitHub repository named like your drupal.org module //p pCopy the commands displayed by Github to push your code to GitHub. I like to use drupal.org as my upstream and GitHub as my origin remote:/p pre $ git clone --branch 7.x-1.x Fabianx@git.drupal.org:project/registry_autoload.git $ cd registry_autoload $ git remote rename origin upstream $ git remote add origin git@github.com:LionsAd/registry_autoload.git $ git push -u origin 7.x-1.x /preh3Step 2 - Activate Travis-ci.org/h3 pimg src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-toggle-project-to-on-tools-icon.png class=img-responsive alt=Toggle the project to ON to activate travis-ci.org testing //p pNow head over to travis-ci.org:/p olliChoose Sign in with GitHub and follow instructions/li liClick on your name at the top right, Fabian Franz for me/li liClick: Sync now if you don't see the repository, yet/li liSimply switch the toggle to ON for the project/li liClick on the repository settings icon (the tools icon)/li liToggle Build only if .travis.yml is present/li liClick on Build history/li liLeave the browser window open/li /olh3Step 3 - Add drupal_ti .travis.yml/h3 pNow checkout a new branch, and add the span class=geshifiltercode class=php geshifilter-php.travis.yml/code/span file:/p pre $ git checkout -b travis-integration $ curl https://raw.githubusercontent.com/LionsAd/drupal_ti/master/.travis.yml.dist -O $ mv .travis.yml.dist .travis.yml /prep Then, customize the following parts of the file:/p pre # Configuration vars. - DRUPAL_TI_MODULE_NAME=registry_autoload - DRUPAL_TI_SIMPLETEST_GROUP=Registry /prep And:/p pre matrix: # [[[ SELECT ANY OR MORE OPTIONS ]]] - DRUPAL_TI_RUNNERS=simpletest /prep The simpletest group is returned from span class=geshifiltercode class=php geshifilter-phpgetInfo()/code/span in Drupal 7, but an annotation span class=geshifiltercode class=php geshifilter-php@group x/code/span in Drupal 8. Despite the name of the variable, you could also put in a class like span class=geshifiltercode class=php geshifilter-phpRegistryAutoloadTestCase/code/span. Basically anything that SimpleTest accepts on the command line as last argument. The clue is that this variable accepts spaces e.g. DrupalTi Test, which is else very difficult to achieve when passing variables around./p pNow add the file and push to GitHub:/p pre $ git add .travis.yml $ git commit -m Added travis integration $ git push origin travis-integration /preh3Step 4 - Watch the Test Run/h3 pNow head back over to your browser window and magically there will be a new build, click on it and you will see a matrix like structure, here shown for build #2:/p pimg src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-build-matrix-in-progress.png class=img-responsive alt=Travis CI build matrix in progress //p pClick on PHP 5.4 and click the little button on the far right with follow, to follow the output./p pAfter a while the build is finished and all tests passed:/p pimg src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-build-matrix-tests-passed.png class=img-responsive alt=Travis CI build passed //p pstrongCongratulations, your project is now tested on travis-ci.org!/strong/p pNow merge, the branch into your mainline and whenever you want to test a change on travis-ci.org just push a branch or make a pull request:/p pre $ git checkout 7.x-1.x $ git merge travis-integration $ git push origin 7.x-1.x # Also push the changes back to drupal.org $ git push upstream 7.x-1.x /prep The easiest way to work with this kind of integration is to push all patches to origin first and once satisfied, push to upstream. That way GitHub and drupal.org are always in sync./p h2To be Continued…/h2 pIn the next part of this series, I will explore how you can get started with unit testing locally and on travis-ci.org (using drupal_ti) and afterwards we will take a look at some easy behat setup./p pIf you are curious and want to start now, take a look at the span class=geshifiltercode class=php geshifilter-phprun-*/code/span scripts in:/p ulli a href=https://github.com/LionsAd/drupal_ti/tree/master/tests/drupal-7/drupal_ti_test/testshttps://github.com/LionsAd/drupal_ti/tree/master/tests/drupal-7/drupal_t.../a/li li a href=https://github.com/LionsAd/drupal_ti/tree/master/tests/drupal-8/drupal_ti_test/testshttps://github.com/LionsAd/drupal_ti/tree/master/tests/drupal-8/drupal_t.../a/li /ulpEnjoy and please leave me feedback either in the a href=http://www.drupal.org/project/drupal_tiDrupal issue queue /a or on the a href=https://github.com/LionsAd/drupal_ti/issuesGitHub project page/a./p h2About the Author/h2 pFabian Franz is a Senior Performance Engineer and Technical Lead at Tag1br / Consulting. He is author of the registry_autoload, service_container and render_cache modules for Drupal 7 and a contributor to Drupal 8 Core in the form of reviews, patches, and co-leader of the Twig initiative./p /div div class=field field--tags field-type-taxonomy-term-reference field-label-above field--rss div class=field-labelspan class=icon glyphicon glyphicon-tag aria-hidden=true/spanTags:nbsp;/div div class=field-items a href=/tags/testing typeof=skos:Concept property=rdfs:label skos:prefLabel datatype=Testing/a a href=/tags/contributed-modules typeof=skos:Concept property=rdfs:label skos:prefLabel datatype=Contributed modules/a a href=/tags/third-party-tools typeof=skos:Concept property=rdfs:label skos:prefLabel datatype=Third-party tools/a /div/div div class=field field--images field-type-image field-label-above field--rss div class=field-labelImages:nbsp;/div div class=field-items img typeof=foaf:Image class=img-responsive src=http://cdn1.drupalwatchdog.com/sites/default/files/github-create-new-repository.png width=877 height=531 alt= / img typeof=foaf:Image class=img-responsive src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-build-matrix-in-progress.png width=1128 height=485 alt= / img typeof=foaf:Image class=img-responsive src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-build-matrix-tests-passed.png width=1119 height=510 alt= / img typeof=foaf:Image class=img-responsive src=http://cdn1.drupalwatchdog.com/sites/default/files/travis-toggle-project-to-on-tools-icon.png width=893 height=44 alt= / /div/div

Aten Design Group: Debugging New to You Drupal Blocks

Tue, 12/09/2014 - 17:20
img src=http://atendesigngroup.com/sites/default/files/drupal-debugging-blocks.png width=1000 height=600 alt= /pLet’s say a friend (or a new client) asks you to make a small change to their Drupal website. You’ve never seen this site before and the original developer(s) are long gone. Of course the text is in some obscure block. Sometimes finding where to make the requested change is easy. Sometimes it’s not. I’m going to go through some debugging tips for such a case./p pThe first thing you should do is inspect that part of the page with your browser’s dev tools (e.g. a href=https://developer.mozilla.org/en-US/docs/Tools/Page_InspectorFirefox/a, a href=https://developer.chrome.com/devtoolsChrome/a). Often IDs and class names will help identify the block./p pHere’s an example of the DOM of a view block from the nodequeue module./p pspan class=geshifiltercode class=text geshifilter-textlt;div id=quot;block-views-nodequeue-2-blockquot; class=quot;block block-views contextual-links-region block--marqueequot;gt;/code/span/p pThe ID block-views-nodequeue-2-block means this is a views block. nodequeue-2 is the view machine name, and block is the name of the specific display in that view. You can browse the list of views at /admin/structure/views, or in this case, go directly to /admin/structure/views/view/nodequeue_2/edit/block. The path to edit a view in Drupal 7 is always at /admin/structure/views/view/[VIEW NAME]/edit/[DISPLAY NAME]. If contextual links are on, it may be even quicker to access the edit page from the options available. Look for a gear icon in the upper right corner of the section./p pHere’s a block defined in code:/p pspan class=geshifiltercode class=text geshifilter-textlt;div id=quot;block-cei-custom-blocks-cei-unicef-timelinequot; class=quot;block block-cei-custom-blocks contextual-links-regionquot;gt;/code/span/p pIn this case in cei_custom_blocks_block_info() defines a block delta: span class=geshifiltercode class=text geshifilter-text$blocks['cei_unicef_timeline']/code/span The code that defines this block’s output will either be in span class=geshifiltercode class=text geshifilter-textcei_custom_blocks_block_view()/code/span or that function will call another./p pIn one particular case I didn’t have a lot to go on. There was very little in the DOM. This members page consisted of user images, name, and title. The client requested one additional field be included for each user on the members page. It wasn’t a view or anything else easily identifiable. The output was in system block 0 which doesn't give me anything to go on. One particularly unique class name was block-totem-common-embed-type-search-0 (this was the totem install profile) but a search of the code turned up nothing. That’s because the code that built these blocks was highly abstracted. Reviewing that code didn’t reveal where I could add the field either. Finally I searched on another class name. I didn’t find exactly where the class name was inserted, but it happened to match a template file that was in one of the submodule's ‘inc’ directories./p div class=geshifilterpre class=geshifilter-text lt;divlt;?php print $attributes; ?gt;gt; lt;?php print $user_profile['images']['user_thumb']; ?gt; lt;?php print render($title_prefix); ?gt; lt;h3gt;lt;?php print render($user_profile['name']); ?gt;lt;/h3gt; lt;?php print render($title_suffix); ?gt; nbsp; lt;div class=quot;clearfixquot;gt;lt;/divgt; lt;/divgt;/pre/div pOnce I found that, making the needed modification was simple./p pTo help identify a block, you can also look at what is placing the block on the page. Some ways this can be done include the blocks UI, Context module, Panels, print directly in code, and template files. If a lot of blocks are placed using the blocks UI, this page can get unwieldy. It’s worth searching the codebase for any distinct phrases. A quick search in the database can also be useful./p pBlocks saved in the database are in the blocks and blocks_custom tables. One way to find such a block in the database uses a query for some matching text:/p div class=geshifilterpre class=geshifilter-textSELECT * FROM block_custom WHERE body LIKE quot;%participate in discussions%quot;\G/pre/div pThe query matched the following entry:/p div class=geshifilterpre class=geshifilter-text*************************** 1. row *************************** bid: 3 body: lt;pgt;lt;stronggt;A message from the GEC teamlt;/stronggt;lt;/pgt; lt;pgt;During the recent GEC baseline sharing events, one of the key messages that came through loud and clear from you was the value of meeting other projects and exchanging knowledge, sharing challenges, solutions, experiences and advice. We began to see the GEC community take root, and to continue this momentum we are launching the GEC forum amp;ndash; a place for the GEC Community of Practice to develop and grow. This will be the place for you share your expertise, participate in discussions, and interact with other projects that form the community of the Girlsamp;rsquo; Education Challenge. lt;a href=quot;http://www.educationinnovations.org/forums/introducing-girls%E2%80%99-education-challenge-forumquot;gt;Read more...lt;/agt;lt;/pgt; lt;pgt;amp;nbsp;lt;/pgt; nbsp; info: GEC welcome message (deliberately not in code) format: full_html/pre/div pSuch a block can be edited at /admin/structure/block/manage/block/3/configure. The path to edit a block is always at /admin/structure/block/manage/[Block ID]/configure./p pHopefully these tips will be useful the next time a completely unknown website is dropped in your lap./p

Acquia: PHP: Under the Hood, Running the Web

Tue, 12/09/2014 - 17:13
div class=field field-name-body field-type-text-with-summary field-label-hidden div class=field-items div property=content:encoded class=field-item evenp Most non-technical people out on the Web haven't heard of PHP before. They might not have even heard of many of the products that were built with this technology like Drupal, Magento, or WordPress. And together with other products built with PHP, these run about 83% of all internet web applications. The technology of PHP is very important to an enormous number of businesses, governments, and organisations around the world, so even though people might not be familiar with the language itself, there’s a very good chance they’ve used it online today. /p/div /div /div span property=dc:title content=PHP: Under the Hood, Running the Web class=rdf-meta element-hidden/span

Damien McKenna: Need help with (final?) release of Panels for Drupal 6

Tue, 12/09/2014 - 04:11
div class=field field-name-body field-type-text-with-summary field-label-hidden view-mode-teaserdiv class=field-itemsdiv class=field-item evenpAfter more than two and a half years since a href=https://www.drupal.org/node/1409446the last release/a, we need some help putting together what might be the final release of a href=https://drupal.org/project/panelsPanels/a for Drupal 6:/p/div/div/divsection class=field field-name-taxonomy-vocabulary-2 field-type-taxonomy-term-reference field-label-inline clearfix view-mode-teaserh2 class=field-labelTags:nbsp;/h2ul class=field-itemsli class=field-item evena href=/tags/drupalDrupal/a/lili class=field-item odda href=/tags/drupal-6Drupal 6/a/lili class=field-item evena href=/tags/drupal-planetDrupal Planet/a/lili class=field-item odda href=/tags/panelsPanels/a/li/ul/section

James Oakley: Installing the latest version of Drush

Tue, 12/09/2014 - 00:21
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpIn case you missed it, a href=https://github.com/drush-ops/drushDrush/a has evolved recently./p pQuick primer for beginners follows. (Although, if you haven't heard of Drush, the chances are this post was not written with you in mind. I blog about many subjects, and there aren't many readers who are interested in all of them!)/p pDrush stands for Drupal shell - it's a very powerful shell environment for managing Drupal sites using the command-line shell. span class=read-morea href=/blog/2014/12/installing_the_latest_version_of_drush title= rel=nofollowstronghellip;nbsp;Read morespan class=element-invisible about Installing the latest version of Drush/span/strong/a/span/p/div/div/divdiv class=field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-abovediv class=field-labelBlog Category:nbsp;/divdiv class=field-itemsdiv class=field-item evena href=/blog/categories/drupal_planetDrupal Planet/a/div/div/div