Fetch component VS Views module
Tags: dotnet, csharp, opensource, development
Published: 2023-06-22 15:48:08

In this tutorial, we present how to work with the fetch component of the [Elanat framework](https://elanat.net).

More information about Elanat framework.
[dev.to/elanatframework/elanat-framework-134d](https://dev.to/elanatframework/elanat-framework-134d)

Please, before reading this article, learn about the views module in Drupal, and then comment on the similarities or differences between the fetch component in the Elanat framework and the views module in Drupal.
[www.drupal.org/docs/7/modules/views/what-are-views](https://www.drupal.org/docs/7/modules/views/what-are-views)

The fetch component allows the user to extract database data and then combine it with HTML tags or other values and display these values in any part of the website he wants.

This component is very powerful and practical and does a lot of work.

**For example:**

- Show avatars of online users
- List of latest content by time
- The list of the latest content based on the number of views
- List of tags of the week
- Create rss
- Create a sitemap
- Grant temporary access
- Delete content after display
- And many other things

**Note:**
You can simply call a series of sql commands (add, edit and delete) in the database with or without data display.

There are two ways to add a add-on in the fetch component; one is to create by writing a query and the other is to upload a fetch add-on.

Here we teach how to create a add-on in the fetch component by writing a query.

**Step 1:**
After logging in, enter the admin panel; then select the _Add-ons_ system in the upper bar and after displaying the list of components, click on the _fetch_ component and then click on the _add_ button to open the space to add a new fetch.
Choose a name for your add-on in the _fetch name_ field and then enter your query in the _fetch sql query_ field and then click on the get _sql query column_ button.

![Fetch component tutorial add fetch 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pxnyum8463nwhje9liw.png)

**Step 2:**
After completing the steps of step 1, you will see the list of selected columns in the _sql query column_ section. Below, you can see the _fetch box_, which repeats the values of _fetch list item_ with the value of _$_asp item;_ It changes in the _fetch box_. In the _fetch list item_ section, you can combine database variables with HTML tags.

![Fetch component tutorial add fetch 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onkttu5xdijqbss9bwvw.png)

**Step 3:**
Click on the _fetch active_ and _fetch public access show_ checkboxes to activate them; In the _fetch menu_ section, you can select a part of the website where you would like your fetch add-on to appear. Then click on the _add fetch_ button.

Now you can see the result.

![Fetch component tutorial view it](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a53teezxgtlgtamk7uu7.png)

**Note:**
You can add the fetch add-on variable in any part of a page add-on so that the fetch add-on is displayed on that page. For this, you must activate the checkbox called _page use fetch_ on that page.

The fetch add-on variable is written as follows:
`$_fetch_name example;`
The fetch name _example_ value is _your fetch name_.

**Questions:**

- Do you think beginners can use fetch component in Elanat?
- Are professionals more comfortable with the Elanat fetch component or the views module in Drupal?
- Does the Drupal views module, like the fetch component in Elanat, have the ability to access all the database data and display the database data as desired?
- Does the Drupal views module, like the fetch component in Elanat, have the ability to edit and delete from the database in addition to displaying information?