Creating and Theming a Custom Content Type with Drupal 7
Let's add in a Display Suite layout; this is where all the magic happens. At the bottom of Manage Display, find the tab called Layout for event in default. Click, and using the Select a layout list, choose Two Column, and save the page. You'll notice you have an updated UI showing Right, Left and Disabled. All Fields default to Disabled, so position the Fields where you want them in your new two-column node layout. You either can drag your Fields up to the right or left area or use the Region select list to choose. I find the latter to be easier. Figure 9 shows the layout after repositioning Fields and saving the page.
Figure 9. The Finished Display Suite Layout
Add CSS to the Theme
By default, the two-column Display Suite layout is split 50%, but let's add some CSS to the theme to mirror the wireframe. Open styles.css, located at sites/all/themes/professional_theme/, and add this code after the final closing brace at the end of the file. You'll notice this CSS file has media queries in it, and for the sake of this demo, let's add our styles in after any media query, but you also could theme this per media query:
.group-right {
width: 36%;
padding-left: 2%;
float: right;
}
.group-left {
width: 62%;
}
.field-name-field-event-image {
margin-top: 20px;
}
.getlocations_map_canvas {
max-width: 100%;
}
From the admin toolbar, click on Content, and then choose Add content, and choose Event. You now will see a blank node create form. Fill in a Title, choose your Date, and fill in some Overview Text. Next, choose an address for your event, and once it's filled in, click the Geocode this address button, and your little map below will re-center itself on your address. Finally, upload an image, choose a link/title, and save your node. Figure 10 shows the final themed layout.
Figure 10. The Final Themed Layout for the Event Content Type
There's so much more you can do with custom content types and theming in Drupal 7; this is just the tip of the iceberg. To enhance the content editor experience, a nice addition would be to add a WYSIWYG editor to the Overview Text area. If you want to get more hands-on with code, you could dispense with Display Suite and add a node--event.tpl.php file to your theme folder and theme the Fields individually.
Resources
Professional Theme (front-end theme pictured in the demo): http://drupal.org/project/professional_theme
Date: http://drupal.org/project/date
Get Locations: http://drupal.org/project/getlocations
Link: http://drupal.org/project/link
Geocoder: http://drupal.org/project/geocoder
geoPHP: http://drupal.org/project/geophp
Display Suite: http://drupal.org/project/ds
Libraries API: http://drupal.org/project/libraries
Get Locations Documentation: http://drupalcode.org/project/getlocations.git/blob/refs/heads/7.x-1.x:/README.txt
Installing Drupal 7: http://drupal.org/documentation/install
Installation Tutorial Video: http://learnbythedrop.com/drop/173
Sign in/Create a Free Google Account: https://code.google.com/apis/console
Google Maps API Key (v.3.0): https://developers.google.com/maps/documentation/javascript/tutorial#api_key
Drupal Is Not a CMS: http://www.palantir.net/blog/drupal-not-cms
- « first
- ‹ previous
- 1
- 2
- 3
Danny Englander is a Drupal Developer specializing in theming, site building, UX, UI, responsive design and JQuery. He runs his own Drupal shop and freelances for various clients around the United States.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Web Development News
Developer Poll
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- What's the tweeting protocol?
- New Products
- RSS Feeds
- Readers' Choice Awards
- Dart: a New Web Programming Experience
- Reply to comment | Linux Journal
12 hours 36 min ago - Reply to comment | Linux Journal
15 hours 9 min ago - Reply to comment | Linux Journal
16 hours 26 min ago - great post
17 hours 1 min ago - Google Docs
17 hours 24 min ago - Reply to comment | Linux Journal
22 hours 12 min ago - Reply to comment | Linux Journal
22 hours 59 min ago - Web Hosting IQ
1 day 33 min ago - Thanks for taking the time to
1 day 2 hours ago - Linux is good
1 day 4 hours ago







Comments
Display Fields in a Table
That is all great information. Thank you for putting it together in one place.
However, suppose you have a number of fields in a content type and you wish to display them in a table with a column of lables and a column of values. How would one go about that?
Reply to comment | Linux Journal
Areas most at risk Dengue fever child chicken pox remedies
is endemic in Burma. Most store bought flea products for dogs contain permethrin, as does
substituting unbleached all-purpose flour for the whole wheat.
If you want contextual
If you want contextual tabular data to be displayed on each page then first you need to add the data fields to the content type in order to collect that data. Next, you need to create a view block to display the data. This is very easy to achieve by creating a view (views module) using the table format. You will need to configure the contextual settings of the view to only display data belonging to that page. Once you have accomplished that, the view can easily be inserted into the page in a number of ways depending on your choice of page layout method. With either Display Suite or Panels you can easily create a content pane and/or block that displays the view where you wish. Alternatively, you can embed the view directly in a custom page template. While this may sound like a lot of work, it is actually very simple and can be done in less than an hour depending on the number of fields you need to add to the content type. Hope this helps. Cheers, Kevin
Post new comment