Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Custom content view (part 2)

Parent Feed: 

In previous article, we have built a simple custom view from sales data. In this article we will show how to create a relationship with another table, add access control and a menu link. You can also watch the video with complete built.


Table relationship

The purchases are linked to a supplier ID. This ID is a reference in the Address book table. To create the relationship with address book, click on "Add" under "ADVANCED":

relationship add

In the tables list, select the "Client" linked to sales:

select table

After the table is linked, you can add new fields from Address book. We will need the Address book ID and the Name (of supplier).

You can click on "Add" in fields section:

add fields

In the field list, Select the ID and Name and configure the data columns. We only display the Name and hide the ID:

configure fields

Like for the link to document, we can add a link to the supplier data. Open the "Name" field for editing by clicking on "(Address book link to purchase) ek address book: Name (Supplier) ". In the configuration, under "REWRITE RESULTS", select "/address_book/{{ id_1 }}

We now have a table with supplier name linked to Address book:



Access to views can be controlled like any other page in Drupal. you can restrict access by role or permission.

to do that, go to page settings and click "Unrestricted" to edit access:

page settings

In the form, select the type of access control you want, role or permission. In our case with select a "Permission" which is attached to the sales module to list purchases.




The last step is to create a menu for easy navigation to the data view. In the page settings section, click "No menu" to open the menu form:

page settings menu

We create a normal menu item to be listed under parent sales menu:

menu select

The custom view is now ready and can be saved. Users with correct access permission will be able to open, filter and read data on the new page.

You can watch our video for building this custom view or test the full example result with our online demo

build custom view part 2

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web