[[views-duplicate]]

=== Duplicating a View

[role="summary"]
How to create a new page by duplicating a view.

(((View,duplicating)))
(((Views module,duplicating a view)))
(((Module,Views)))

==== Goal

Create a page listing recipes by duplicating the existing Vendors view.  Modify
the page so that the recipes are displayed in a grid and can by filtered by
ingredients.

==== Prerequisite knowledge

* <<views-concept>>
* <<views-parts>>
* <<views-create>>

==== Site prerequisites

* The Vendor and Recipe content types must exist; both must have Main image
fields, and the Recipe content type must have an Ingredients field. Your site
must also have a couple of Recipe content items. See <<structure-content-type>>,
<<structure-fields>>, <<structure-taxonomy-setup>>, <<structure-form-editing>>,
and <<content-create>>.

* The Vendors view must exist. See <<views-create>>.

==== Steps

. In the _Manage_ administrative menu, navigate to _Structure_ > _Views_
(_admin/structure/views_). Find the view "Vendors" and click _Duplicate_ in its
dropdown button. (Note that the names of views that came with your installation
profile are shown in English on this page; see <<language-concept>> for an
explanation.)
+
--
// Views page (admin/structure/views), with operations dropdown
// for Vendor view open.
image:images/views-duplicate_duplicate.png["Duplicate existing view",width="100%"]
--

. Name the duplicate "Recipes" and click _Duplicate_. The view configuration
page appears.

. To change the title of the view page to "Recipes", click Vendors in the
_Title_ field under _Title_. The _Page: The title of this view_ pop-up
appears. Enter "Recipes". Click _Apply_.
+
--
// View title configuration screen.
image:images/views-duplicate_title.png["Change view title",width="100%"]
--

. To change from a table to a grid format, click _Table_ in the _Format_ field
under _Format_. The _Page: How should this view be styled_ pop-up
appears. Check _Grid_ and click _Apply_. The _Page: Style options_ pop-up
appears. Retain the default values and click _Apply_.

. To retain only the title and image fields for the Recipes view, click
_Content: Body_ under _Fields_. Click _Remove_ in the pop-up that appears.

. To change the content type filter to use the Recipe content type, click
_Content: Type (=Vendor)_ under _Filter criteria_. In the _Configure
filter criterion: Content: Type_ pop-up, check Recipe and uncheck Vendor. Click
_Apply_.

. To add a further filter that is exposed to visitors, click _Add_ in the
dropdown button under _Filter criteria_. Search for "ingredients" and check
"Ingredients (field_ingredients)". Click _Add and configure filter criteria_.

. The appearing pop-up offers extra settings on vocabulary and selection
type. Click _Apply and continue_. The next pop-up allows you to expose this
filter to visitors. Fill in the fields as shown below, and click _Apply_.
+
[width="100%",frame="topbot",options="header"]
|================================
| Field name | Explanation| Example value
| Expose this filter to visitors, to allow them to change it | Allow visitors to filter and search | Checked
| Required | Whether a value has to be provided or not | Unchecked
| Label | Label shown for this filter on the view page | Find recipes using...
|================================
+
--
// Ingredients field exposed filter configuration.
image:images/views-duplicate_expose.png["Expose filter"]
--

. To change the _Path_ label field to "Recipes", click "/vendors" in the _Path_
field under _Page settings_. In the pop-up that appears, enter the path
"recipes" and click _Apply_.
+
Note that when editing a view, you enter paths without the leading "/", unlike
on other administrative pages (such as when providing a path to a content item
page).

. To change the menu link title, click "Normal: Vendors" in the _Menu_ field
under _Page settings_. In the pop-up that appears, change the title to "Recipes"
and click _Apply_.

. In order to use Ajax (see <<glossary-ajax,Ajax entry in the Glossary>>) to
make filtering and paging faster for users, under _Advanced_ > _Other_, click
_No_ in the _Use AJAX_ field. Check _Use AJAX_ in the pop-up that appears, and
click _Apply_.

. Click _Save_ to save the view.

. Go back to the home page and click Recipes in the navigation to view the new
Recipes page.
+
--
// Completed recipes view output.
image:images/views-duplicate_final.png["Recipes view",width="100%"]
--

==== Expand your understanding

The link to the view in the main navigation will probably not be in the right
place. Change the order of the menu items in the main navigation. See
<<menu-reorder>>.

==== Related concepts

* <<planning-structure>>
* <<glossary-ajax, Ajax entry in the Glossary>>

==== Videos

// Video from Drupalize.Me.
video::https://www.youtube-nocookie.com/embed/weWFDgw84_M[title="Duplicating a View"]

//==== Additional resources


*Attributions*

Written and edited by https://www.drupal.org/u/lolk[Laura Vass] at
https://pronovix.com/[Pronovix],
and https://www.drupal.org/u/jojyja[Jojy Alphonso] at
http://redcrackle.com[Red Crackle].
