Advanced Components
  • Welcome
  • Start here
    • Setup
    • Dependencies
  • Getting Started
    • Front-end tooling
    • Create a new D9 theme
    • Component Architecture
    • Drupal Best Practices
    • Drupal Attributes
    • Twig Blocks
  • Basic Components
    • Global styles
    • Adding webfonts
    • Heading Component
      • Improving the Heading
    • Button Component
  • A component's lifecycle
    • Hero Component
    • Include statements
    • Drupal prep
    • Drupal entities
    • Homepage content type
    • View modes
    • Add Hero to homepage
    • Drupal cache & twig debugging
    • Twig template suggestions
    • Getting field values
    • Integrating the Hero
    • Drupal Libraries
    • Hero Image styles
  • Card component
    • Card Component
    • Component Variants
    • Card Variant
    • Author component
  • Drupal site building
    • Blog articles
    • View modes
    • Drupal Views
    • Author
    • Generate content
    • Adding Blog Lists to the Homepage
  • Drupal Integrations
    • Integrating the Card
      • Taxonomy terms
    • Integrating the Card Wide
    • Author integration
    • From our blog
    • Integrating From our blog
    • Featured Content
    • Integrating Featured Content
    • Blog image styles
    • Blog detail page
  • Extras
    • Image Styles
    • Navigation
  • Resources
    • Resources
Powered by GitBook
On this page
  • Exercise: Building a Homepage content type
  • Exercise: Adding the Hero field to the Homepage
  • Exercise: Create a new Node with a Hero

Was this helpful?

  1. A component's lifecycle

Homepage content type

Exercise: Building a Homepage content type

We'll build a new content type which we will use to build the homepage with all of its components shown in our design.

  1. From Drupal's Admin Toolbar, click Structure | Content Types

  2. Click the **Add content type **button

  3. In the name field type Homepage

  4. Click the Save and manage fields button at the bottom of the page

  5. Delete the **body **field

Exercise: Adding the Hero field to the Homepage

  1. While still in the Homepage content type, click the Add field button

  2. Under the Add a new field dropdown, scroll to the Reference section and select Content

    Label
    Machine name

    Hero

    field_hero

  3. Click the Save and continue button

  4. Change Allowed number of values_ to Limited - 1

  5. In the Reference Type section, choose Article under Content type

  6. Click the Save settings button

Exercise: Create a new Node with a Hero

Using the Homepage content type, create a new node and add a Hero component in it:

  1. From Drupal's Admin toolbar, click Content

  2. Click the Add content button

  3. Select Homepage

  4. As the Page title type** Homepage**

  5. In the Hero field, begin typing any characters and as article suggestions begin to display, select an article of your choice

  6. Click the **Save **button

The above exercise will create a node of type Homepage, with an article as the Hero. It is clear we have more work to do since the Hero article does not look like a Hero at all. We will clean things up in the following exercises.\

It's pretty obvious there are a lot of things that need improvement with our Hero, but we will get to that shortly.

PreviousDrupal entitiesNextView modes

Last updated 3 years ago

Was this helpful?

Drupal Node with Hero