Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Drupal CCK + Views. Changing the appearance of the staff gallery.

17/04/2025, by Ivan

In the previous lesson, using the Drupal Views and CCK modules, we created an employee gallery that is filled by creating content of the "Employee" type. In the content type "Employee", we added two fields: Full Name (text field) and About Employee (textarea). This lesson is created to show that the same data can be displayed in different ways using Views.

Currently, the employee gallery is displayed as follows:

Drupal cck

For convenience, I added a link to the employee view in the menu. Use the "Page" display's path property as the path to the view.

Drupal views

Method 1. Let’s work with the employee gallery view: remove the employee description from the general gallery, and make the Full Name a link to the employee node.

First, remove the description field from the employee gallery view. Go to the list of views (Site structure - Views) and select the employee gallery view, mine is named view_sotrudniki.

Click the edit button next to Fields and remove the employee description field. After deletion, save the changes. Don’t worry about deleting fields from the display — deleting a field from the view does not delete the data itself.

Views fields

Now without the description, the view looks like this:

Views fields

Now let’s make the Full Name a link to the employee node. Go to the employee view and select the Full Name field:

Views fields

At the bottom, in the Full Name field settings, check "Link this field to its node":

Link to node

Save the change, don’t forget to save the view as well. Now the Full Name is a link to the employee node:

Drupal views

Method 2. Let’s make the Full Name a link to the employee gallery view, but pass the employee node ID via the URL.

By the employee node ID, we will display a block with the employee’s description directly below the gallery. For example, if the employee node ID is 10, the link will lead to site_name/sotrudniki/10.

Go to the employee gallery view and add the field Content: nid. nid stands for node ID, i.e., the internal identifier of the node. When adding the nid field, specify that it should not be displayed (Exclude from display).

Exclude from display Views

Move the nid field to the very top so that the nid value is available when building the Full Name link.

Drupal views

Now go to the Full Name field settings, and configure the link like sotrudniki / [nid].

Change path

Uncheck "Link this field to its node", and check "Output this field as a link". Use token [nid] in the Link path (we moved nid to the top for this reason). Enter: sotrudniki/[nid]. Save the field and the view.

Now we need to create a block that displays the employee's description. Name it view_block_sotrudniki. In this view, add a Block display.

Views add display block

Add fields:
Content: Full Name
Content: About Employee

Filters:
Content: Published - yes
Content: Type - employee

Argument:
Content: nid - in the argument settings specify the following:

Views add argument

Provide default argument - if the argument is not present, allows specifying it using functions like arg(). The arg() function uses argument position in the URL (sotrudniki / [nid]). Indexing starts at zero, so the second argument is the node ID [nid], the first is "sotrudniki".

Other available argument options:
Node ID from URL – works when the first argument is "node" (e.g., node/14);
Taxonomy Term ID from URL – works when the first argument is "term";
User ID from URL – works when the first argument is "user";
We’ll explore these in later lessons. For now, enter the PHP code return arg(1);

Save the argument and the view. A new block should appear: view_block_sotrudniki: Block. This block is created whenever a Block display is added to any view. Place the view_block_sotrudniki: Block in the Content region. In the block’s visibility settings, specify that the block should only be shown on URLs that contain the word "sotrudniki" and some ID after it (/* – the asterisk after the slash means any value is expected).

Drupal cck

Go to the page site_name/sotrudniki — now clicking an employee's Full Name will display the Full Name and About info below the gallery.