Each view's display type has its own utility, and can be used to create a set of related displays
to fulfill a purpose. In this recipe, we will create a marketing bundle using a page display for a
sales presence landing page, a block display for an ad, and a feed with which customers can stay updated about new content.
Getting ready
f We'll be using the Product content type (details are in Appendix B, Bundles) f At least one piece of product content will be needed
How to do it...
On the view list page:
1. Navigate to the views list (admin/structure/views) and click the +Add new view
link.
2. Enter Marketing bundle as the view name, check the box for Description, and enter Landing page, ad and feed in the textbox.
4. In the Page title textbox, enter Greenberg Design Accessories Brings You the Best Bargains!.
5. Enter bargains in the Path textbox.
6. For Display format, select Grid and fields (the other two select boxes will disappear). 7. Change the Items to display field to 3.
Next, we will enter the settings to create a block: 1. Check the checkbox for Create a block.
2. For the block title, enter Another Great Greenberg Design Accessories Product.
3. Change titles (linked) to fields in Display format and change Items per page to 1. 4. Click the Continue & edit button.
At this point, we have defined the overall view, and now we can adjust its settings on the view
edit page:
1. Click the Settings link next to Grid, select This page (override) in the select box, change Columns from 4 to 3, and click the Apply (this display) button.
2. Click the Add button in the Fields section, select This page (override) from the select box, check the checkbox for Content: Product image, and click the Apply (this display) button.
3. In the Configure field: Content: Product image window, select This page (override)
from the select box, uncheck the Create a label checkbox, select Medium (220x220)
from the Image style select box, select Content in the Link image to select box, then click the Apply (this display) button.
4. Click the link for Content: Title in the Fields section, uncheck the checkbox for Link
this field to the original piece of content, click on the Rewrite Results link, check the checkbox for Rewrite the output of this field, enter <h2>[title]</h2> in the
Text box, then click the Apply (this display) button.
5. Click the Add button in the Header section, select This page (override) from the select box, click the Global: Text area checkbox, and click the Apply (this display)
button.
6. Enter <big>The liquidation area of Greenberg Design Accessories is where you can find amazing bargains in leftover and
discontinued products.</big> in the large textbox and click the Apply (this display) button.
7. Click the Add button in the Footer section, select This page (override) from the select box, click the Global: Text area checkbox, and click the Apply (this display) button.
That takes care of the page display; next we will configure the block display:
1. Click the Block button in the Displays section.
2. Click the link for Content: Title (desc) in the Sort criteria box, change the select box to This block (override), and click the Remove button.
3. Click the Add button in the Sort criteria box, check the checkbox for Global:
Random, click the Apply (this display) button, and the same again in the subsequent window.
4. Click the Content: Title link in the Fields section, change the select box setting to
This block (override), and click the Remove button.
5. Click the Add button in the Fields section, check the checkbox for Content: Product image, and click the Apply (this display) button.
6. Uncheck the Create a label checkbox, change the image style to Thumbnail (100x100), and click the Apply (this display) button.
7. Click the None link in the Block Settings section, enter Marketing bundle ad in the textbox, and click the Apply button.
The final step is to create the feed:
1. Click the +Add button in the Displays section and click the Feed link. 2. Click No path is set next to Path in the Feed settings section, enter
greenbergdesignaccessories/feed as the path, and click the Apply button. 3. Click the title in the Title box, change the select box setting to This feed (override),
enter The Newest Bargains from Greenberg Design Accessories in the textbox, and click the Apply (this display) button.
4. Click the Use site default RSS settings link for Show in the Format section, select
Title only from the Display type select box, then click the Apply button.
5. Click the Content: Title link in the Sort Criteria section, change the select box setting to This feed (override), and click the Remove button.
6. Click the Add button in the Sort Criteria section, check the checkbox for Content: Post date, and click the Apply (this display) button.
7. Change the select box setting to This feed (override), choose Sort descending, and click the Apply (this display) button.
8. Click the Save button.
9. Navigate to the block admin page (admin/structure/block), find Marketing bundle ad in the Disabled section and change the select box setting to Sidebar first, then click the Save blocks button.
10. Navigate to the home page to see the block shown in the following image:
11. Navigate to the RSS feed (greenbergdesignaccessories/feed).
12. If you do not have a RSS feed reader installed in your browser, you will probably see
the raw feed XML:
<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="http://dev.cookbook/bargains" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> <channel>
<title>The Newest Bargains from Greenberg Design Accessories</title>
<link>http://dev.cookbook/bargains</link> <description></description>
<language>en</language> <item>
<title>Hand-carved Floor Mirror</title> <link>http://dev.cookbook/node/22</link> <description></description>
<pubDate>Sat, 25 Jul 2015 23:36:36 +0000</pubDate> <dc:creator>ayen</dc:creator>
<guid isPermaLink="false">22 at http://dev.cookbook</guid>
</item> <item>
<description></description>
<pubDate>Sun, 12 Jul 2015 02:49:20 +0000</pubDate> <dc:creator>ayen</dc:creator> <guid isPermaLink="false">11 at http://dev.cookbook</guid> </item> </channel> </rss>
13. If you do have a RSS feed reader installed, you will see something similar to the following image:
How it works...
We created a node view that selects nodes of the product content type. We then built three displays: a block to use as an advertisement, an RSS feed to allows users to subscribe and keep current with the site, and a landing page that can be used, for example, when the user clicks on an ad at another site. The main idea behind this view is that each display can have
its own settings with regards to fields, sort criteria, and even the filter settings, though we used the same filter throughout this example.