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 8 ■ <strong>Drupal</strong> Blocks<br />

On this form, you can override whether the title of the block “Who’s new” appears on the page when the<br />

block is displayed (uncheck the “Display title” check box), specify how many users will appear in the list of<br />

who’s new (“Items per block”), override the title by checking the Override title box and entering a new title in<br />

the text field that appears when you check the box, and assign the block to a new region.<br />

You may wish to only have this block appear on certain pages on your site. By default it appears on<br />

every page. For example, you may want the “Who’s new” block to only appear on the homepage of your<br />

site. At the bottom of the “Configure block” page (see Figure 8-4), you will see the Pages tab in the Visibility<br />

section. To set the block to only appear on the homepage, click the “Show for the listed pages” radio button<br />

and enter in the text box ( is the special term used to represent the homepage of your site).<br />

You could also specify other pages by entering the URL of that page in the text box (for example, /content).<br />

Figure 8-4. Choosing Visibility settings<br />

It is also possible to set a block so that it only appears for specific types of users based on their assigned<br />

roles. Click the Roles tab to examine and set the visibility by user role options. As an example, let’s set the<br />

block to only appear when the person visiting the site is logged in. (See Figure 8-5).<br />

Figure 8-5. Choosing roles-based settings<br />

Once you have clicked the “Authenticated user” check box, you can click the “Save block” button at the<br />

bottom of the page and return to the homepage of your site.<br />

To test your changes, navigate to a page other than the homepage and you’ll see that the “Who’s online”<br />

block is no longer displayed. Log out and return to the homepage and you’ll see that the “Who’s new” block<br />

no longer appears because you are no longer logged in.<br />

95

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

Saved successfully!

Ooh no, something went wrong!