Custom content view (part 2)

custom view

 

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:

preview

 

Permissions

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.

permission

permission

 

Menu

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

Add new comment

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.