18.11.2015 Views

Beginning Drupal 8

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10 ■ Creating Pages<br />

We will wrap up the landing page by adding three additional Featured Article blocks by creating three<br />

additional articles for restaurants around Los Angeles. We’ll display the image uploaded for each<br />

restaurant article in the Featured Bottom regions near the bottom of the page (refer to Figure 10-1 for<br />

the region locations).<br />

We’ll first need to add a new term to the Subject vocabulary for Restaurants so that we can filter<br />

articles using <strong>Drupal</strong>Con 2015 Los Angeles as the event and Restaurants as the Subject. Follow the steps<br />

you performed earlier in the chapter (and in Chapter 4) to add the new term by navigating to Structure ➤<br />

Taxonomy. Click the “Add term” link in the Operations column for the Subject vocabulary by clicking the<br />

drop-down arrow next to list terms and then select add terms. In the Name field enter Restaurant and click<br />

the Save button.<br />

The next step is to create content. Click the Content link in the secondary menu and click the “Add<br />

content” button. Select the Article content type and create three new Articles selecting Restaurants from<br />

the list of subject taxonomy terms and upload images for each of the three restaurant articles. To upload an<br />

image click on the Browse button for the Image field, locate the image to upload, select it from the list of files<br />

presented, and click the Open button.<br />

With the content in place, we’re ready to create the view displays that will render the name and image of<br />

each restaurant as a block. Return to the Article view and:<br />

1. Click the Add button to create a new block.<br />

2. Give the first block a “Display name” of “Featured Restaurant 1.”<br />

3. We will want to display the name of the restaurant at the top of the block instead<br />

of using the Title field, so click the existing title, select “This block (override)”<br />

from the For select list at the top of the configuration panel for Title, blank out<br />

the existing title that appears in the text field, and click the “Apply (this display)”<br />

button.<br />

4. We also want to show fields instead of teasers or full content in our blocks, so<br />

click the Content link to the right of Show and select Fields. Leaving the other<br />

configuration options at their default values. When we select Fields as the option<br />

for what to show, the Views module automatically adds the Title field to the list of<br />

fields to display. Click the Apply button to return to the Views configuration page.<br />

5. We also want to display the image we uploaded for each restaurant, so click the<br />

Add link in the Fields section and scroll down through the list of fields until you<br />

find “Content: Image Appears in: article.” Alternatively, enter “Image” in the<br />

Search box at the top of the list of fields to quickly take you to the appropriate<br />

field. Check the box next to the Image field and change the selected option of<br />

“All displays” at the top of the “Add fields” form to “This block (override).” Next,<br />

click the “Apply (this display)” button at the bottom of the “Add fields” form. The<br />

“Configure field: Content: Image” form will be displayed next, allowing you to set<br />

how the image will appear in the block. Uncheck the “Create a label” box, as we<br />

don’t need a label to appear above the image. In the “Link image to select list,”<br />

pick the Content item to automatically make the image a hyperlink to the article<br />

about that restaurant, and then click “Apply (this display)” button at the bottom<br />

of the form.<br />

123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!