{"id":2182,"date":"2015-01-03T15:47:54","date_gmt":"2015-01-03T13:47:54","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=2182"},"modified":"2015-01-03T17:42:34","modified_gmt":"2015-01-03T15:42:34","slug":"drupal-7-creating-a-complex-content-type","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=2182","title":{"rendered":"Drupal 7 &#8211; Creating and Feeding Complex Content Types"},"content":{"rendered":"<p>It is no secret that one of the most important aspects of a website is its content &#8211; now more than ever. As websites become more complex, the information within often becomes increasingly complex to author and manage. While content management systems like Drupal have strong content authoring abilities out of the box, it\u2019s easy to neglect this aspect of a site, thus creating an uphill struggle for administrative users that are less familiar with the system.<\/p>\n<p><a href=\"http:\/\/drupal.org\/project\/field_collection\">field collections<\/a>\u00a0is a simple, easy to implement module that we frequently use to enhance and streamline the content editing process. When the website enters in production another module like <a href=\"http:\/\/drupal.org\/project\/field_group\">Field groups<\/a> is very important to make authors update more confortable. At the end of this post, I will explain shortly the aim of that plugin.<\/p>\n<p>Once the complex content modelling is complete we often need to migrate<strong> old data company <\/strong> or<strong> feeds with data<\/strong> the new drupal site<\/p>\n<p>For all of that, you will need all the main modules below to install including the <strong>Entity and Ctools<\/strong> modules :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2199\" alt=\"feeds\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds.jpg\" width=\"153\" height=\"97\" \/><\/a><\/p>\n<p><strong>Once Feeds activated in Drupal this allow you to configure a Processor a Parser :<\/strong><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-processor.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2235\" alt=\"feeds-processor\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-processor-1024x426.jpg\" width=\"600\" height=\"249\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-processor-1024x426.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-processor-300x124.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-processor.jpg 1124w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-parser.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2236\" alt=\"feeds-parser\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-parser-1024x451.jpg\" width=\"600\" height=\"264\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-parser-1024x451.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-parser-300x132.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/feeds-parser.jpg 1113w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h2>Multiple related content fields using field collection<\/h2>\n<div>A fairly common problem we used to run into was the inability to add multiple sets of fields. That is, while a single field can be set to a specific value or unlimited, allowing you to add multiple entries into a field, historically there was no easy to allow you to add multiples of a group of fields.<\/div>\n<div><\/div>\n<div>An example would be if an editor needed to various quantities of actors or actresses to a play, along with the part they played. Field collections are created as entities within Drupal and \u00a0integrate well with the views module. Maintaining field collections is also very easy, it comes with it\u2019s own administrative page available from the structure section. Adding a new field collection is as easy as adding any other field to a content type.<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/examplefc.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2203\" alt=\"examplefc\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/examplefc.png\" width=\"673\" height=\"296\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/examplefc.png 843w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/examplefc-300x132.png 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/a><\/div>\n<div><\/div>\n<div><strong>An example of a field collection in action during content editing.<\/strong><\/div>\n<div><\/div>\n<div><\/div>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fc1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2215\" alt=\"fc1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fc1.jpg\" width=\"510\" height=\"48\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fc1.jpg 1007w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fc1-300x28.jpg 300w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p><strong>Another example of complex content types using Tags \/ Fields collections \/ text zones<\/strong> &#8230;<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/complex_type.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2223\" alt=\"complex_type\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/complex_type-1024x208.jpg\" width=\"600\" height=\"121\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/complex_type-1024x208.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/complex_type-300x61.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/complex_type.jpg 1046w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>Sample configuration feed csv import into field collection<\/strong>:<br \/>\nHow to feed a complex collection Field with csv import (unicode format):<br \/>\nRemember for double quotes you must replace them : every &#8221; with &#8220;&#8221;&#8221; in order to make feed import working.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2193\" alt=\"fielscollection1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection1-300x173.jpg\" width=\"300\" height=\"173\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection1-300x173.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection1-1024x590.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection1.jpg 1252w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection2.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2194\" alt=\"fielscollection2\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection2-300x162.jpg\" width=\"300\" height=\"162\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection2-300x162.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection2-1024x553.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection2.jpg 1220w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection3.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2195\" alt=\"fielscollection3\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection3-300x201.jpg\" width=\"300\" height=\"201\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection3-300x201.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection3-1024x687.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection3.jpg 1225w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection4.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2196\" alt=\"fielscollection4\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection4-300x191.jpg\" width=\"300\" height=\"191\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection4-300x191.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection4-1024x653.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/fielscollection4.jpg 1252w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/drp-datas.jpg\"><img loading=\"lazy\" class=\"aligncenter\" alt=\"drp-datas\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/drp-datas-300x39.jpg\" width=\"300\" height=\"39\" \/><\/a><\/p>\n<p><strong>Feeds Tamper<\/strong> is very important to manage multivalued field import, it works with feeds import module :<br \/>\nA sample of confiuration csv table like this format : isn;value1|value2|value3. You must add a plugin with tamper on second zone that explode values around | &#8230;.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-plugins.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2231\" alt=\"tamper-plugins\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-plugins.jpg\" width=\"569\" height=\"390\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-plugins.jpg 673w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-plugins-300x205.jpg 300w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2197\" alt=\"tamper\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-300x132.jpg\" width=\"300\" height=\"132\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-300x132.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper-1024x452.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/tamper.jpg 1148w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Sample Mapping feed import for a zone Tag or Term reference type in Drupal :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2227\" alt=\"geo\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-1024x469.jpg\" width=\"600\" height=\"274\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-1024x469.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-300x137.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo.jpg 1145w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-tamper.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2229\" alt=\"geo-tamper\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-tamper-1024x461.jpg\" width=\"600\" height=\"270\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-tamper-1024x461.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-tamper-300x135.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/geo-tamper.jpg 1135w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>A visual basic program<\/strong> on Access 2010 for preparing files for multivalued fields import in drupal &#8230;<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/vb-tamper.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2190\" alt=\"vb-tamper\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/vb-tamper.jpg\" width=\"677\" height=\"558\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/vb-tamper.jpg 869w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/vb-tamper-300x247.jpg 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/p>\n<p>XML Feeds works with xml files nodes , it works with feeds import module :<br \/>\nA sample of confiuration for this format importer :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2191\" alt=\"xml-feed1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed1-300x213.jpg\" width=\"300\" height=\"213\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed1-300x213.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed1-1024x729.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed1.jpg 1183w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed2.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2192\" alt=\"xml-feed2\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed2-300x201.jpg\" width=\"300\" height=\"201\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed2-300x201.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed2-1024x688.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/xml-feed2.jpg 1216w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>Improving the out-of-the-box editing experience<\/h2>\n<p>The drupal plugin <a href=\"http:\/\/drupal.org\/project\/field_group\">Field groups<\/a> is used to group fields together in a variety of ways during the editing process. By default, Drupal simply spits out any and all fields onto the content editing page in the order specified within the content type.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/groupfields.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2233\" alt=\"groupfields\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/groupfields.png\" width=\"586\" height=\"333\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/groupfields.png 837w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/groupfields-300x170.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><\/p>\n<p><strong>Example of using field groups to group content fields together.<\/strong><\/p>\n<div><\/div>\n<div>As you can see &#8211; this makes for a much easier editing experience for the user. Related fields are grouped together using vertical tabs so the editor can simply click through each section quickly without having to scroll through a long list of fields.<\/div>\n<div><\/div>\n<div>Cheers<\/div>\n","protected":false},"excerpt":{"rendered":"<p>It is no secret that one of the most important aspects of a website is its content &#8211; now more than ever. As websites become more complex, the information within often becomes increasingly complex&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2842,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,139,6,25],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2182"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2182"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2182\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2842"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}