Pages

Tuesday, August 21, 2012

More Drupal 7 Tips and Tricks


Let's face it climbing the Drupal learning is no walk in the park; there is always something to learn, keeping up with the latest practices, code changes & modules in itself is a full time job. Well with the Drupal 7 tips and tricks series I hope to turn some of you into part-time researchers and full time "Drupalers".

Tip #1 - Themeing Product pages in Drupal Commerce

Fresh on the Drupal scene Drupal Commerce can be seen as an alternative to Ubercart. The focus behind Drupal commerce is a more seamless integration to Drupal 7 utilizing core features such as fields and entities and makes views integration less of a pain.
 
If you are familar with the print render ($content)make sure you add the product reference field. For example: print render($content['product:commerce_price']); for complete reference as to what your product--node.tpl.php should look like click here.

Tip #2 - Adding Author fields to Views 3

Adding the author field to a node may not be so easy to figure out right of the bat however, following this 2 step process should have the author of the content available in your fields section of your view.
1) Create a relationship in your view with "Content: Author"
2) After the relationship is set your should see an additional field called "User:Name"
That's it, author fields is now available at your disposal.
 

Tip #3 - Drush Cheat Sheet

What is drush?
Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

Tip #4 - Adding Related Content to a view in Drupal 7

1.    Create view (block)
2.    Add fields (title, a small image, date, whatever you like). Or teasers, what works as well.
3.    "Arguments" is from now on called "Contextual filters", so go there.
4.    Add the filter: "Content: Has taxonomy term ID"
5.    Configuration on this filter: -> When the filter value is NOT in the URL: -> Provide default value -> Type: Taxonomy Term ID from URL -> under that, check the box "Load default filter from node page, that's good for related taxonomy blocks." -> now check the boxes of the taxonomies you want involved here
6.    Now you need to add the second filter in order to exclude the current node from the list. Click [+] button of the contextual filters section.
7.    Select Content: Nid
8.    Set the 'when argument is not present' to 'Provide default argument'
9.    Set the 'Default argument type' to 'Content ID from URL'
10.   Go to "MORE" , and check the "Exclude" box.
11.    Add a block to your view and embed the block on your node pages
12.    Save your view
 

Tip #5 - Moving Drupal 7 site to a new server - Drupal Staging

Staging has been an issue for Drupal for quite some time now. However many people within the Drupal community are looking to change that with the future release of Drupal 8. Before we begin make sure your server meets the necessary requirements to run Drupal 7 to avoid php related syntax errors.
 
Export the database
The first thing you want to do is export the database. Using phpMyAdmin export the entire database to a file, the default configurations provided should work fine; you want to make sure to export the entire database. If you go within a database and choose the export method you would have to create the database on your target server, enter within that database, and then choose the import method.
By exporting the entire database you do not have to create a new one on your production server the exported file saved will do so automatically. Note: tested using .sql file
 
Copy the files
Should be straight forward here. Simply copy all files from your development server over to your target server.
 
Change your settings.php
The most important part of this process! Make sure you change the settings in your settings.php to reflect your target server or else you'll experience a lot of hair pulling moments. Do not neglect the $base_url this should be the path to your domain name.
Also you want to make sure .htaccess is included and RewriteBase is commented out.
 

Tip #6 - When designing Drupal themes make sure you take into consideration these elements:


  • Header
  • Footer
  • H1 - H5
  • Body
  • Link
  • Unordered List
  • Blockquote
  • Code
  • Admin Tabs (secondary tabs)
  • Collapsible Field Sets
  • Block Headers
  • Block Typography
  • More button
  • Submit Button or general button style
  • Input Field
  • Tags
  • Pagination
  • Basic Node Style
  • Table Style
  • Error Message
  • Status Message
  • Warning Message
  • Help Message
  • Default Profile Layout
  • Blog title and Byline
  • Breadcrumbs

No comments:

Post a Comment

Thanks for your comment.