# GatherContent parameters

> After you install the GatherContent integration, new parameter types are available.

Source: https://docs.uniform.app/docs/integrations/content/gathercontent/gathercontent-parameters

After you install the GatherContent integration, the following
parameter types are available. You can use these to incorporate
content from GatherContent into your components and compositions.

| Parameter type | Description |
| --- | --- |
| [GatherContent Items](#gathercontent-items) | Select an item from GatherContent. |

## GatherContent Items

This parameter type allows a Uniform user to select a
GatherContent item.

### Add parameter to component

To allow a user to select an item from GatherContent,
you must add a parameter to a component. The parameter is used
to store the identifier to the selected item when the user
selects an item.

1. In Uniform, navigate to your component.
2. Add a new parameter using the parameter type **GatherContent Items**.
3. The following values can be specified:

   | Name | Description |
   | --- | --- |
   | Allowed Templates | Specifies which templates will be available to select from when the parameter value is edited. You can select multiple templates to allow the user to select from a larger set of items. |
   | Required | Indicates whether the value is required when the component is used. |

   ![GatherContent Items parameter with a single content type selected.](https://docs.uniform.app/images/integrations/content/gathercontent/use-parameters/gathercontent-items/parameter-config.png)

### Edit parameter value

When you use a component with an GatherContent Items parameter,
by default no item will be selected. You are prompted to
select an item.

1. Click **Select**.

   ![](https://docs.uniform.app/images/integrations/content/gathercontent/use-parameters/gathercontent-items/edit-value-default.png)
2. Click the item you want to select.

   ![](https://docs.uniform.app/images/integrations/content/gathercontent/use-parameters/gathercontent-items/edit-value-selected.png)

   > **About this step:**
   >
   > A couple of filters are available. The dropdown allows you to filter by template. The text box allows you to filter by item name.
3. Click **Accept** to save your selection.
4. You will see details about the item you selected, including the title and some metadata.

   ![](https://docs.uniform.app/images/integrations/content/gathercontent/use-parameters/gathercontent-items/edit-value-saved.png)

   > **About this step:**
   >
   > After your selection is saved, you are presented with the following options:
   >
   > - If you want to edit the selected item in GatherContent, click **Edit**.
   > - If you want to deselect the item, click **Unlink**.

### Configure an enhancer

When an item is selected, Uniform only stores the identifier
for the item. Your front-end application must retrieve the
details for the item. Uniform provides an enhancer to
simplify this process.

> **Tip:**
>
> Using the enhancer provided by Uniform saves you from having
> to write logic to interact directly with GatherContent.

#### How Uniform stores the selected item

The following is an example of what Uniform
stores for the parameter.

```json
{
  "type": "gathercontent-items",
  "value": {
    "itemIds": [
      00000000
    ],
    "source": "default"
  }
}
```

There is one identifier in this value:

1. The item that was selected.

#### Add the enhancer

Uniform provides an enhancer so you don't need to write the API
calls to GatherContent to retrieve data for items.

1. Add the following npm packages to your front-end application:

   ```
   @uniformdev/canvas-gathercontent
   ```
2. In a text editor, open the file where you retrieve the
   composition definition from Uniform.

   :::info About this step
   You are looking for the code calls the async function
   `getComposition`. The code below assumes the
   object returned is set in a variable `composition`.
   :::
3. Add the following import statements:

   ```javascript
   import { 
       createGatherContentEnhancer,
       GatherContentClient,
       GatherContentClientList,
       CANVAS_GATHERCONTENT_PARAMETER_TYPES,
   } from '@uniformdev/canvas-gathercontent';
   ```
4. Add the following code:

   ```javascript
   const client = new GatherContentClient({
       apiKey: '!!! YOUR GC API KEY !!!',
       apiUsername: '!!! YOUR GC API USERNAME !!!',
       projectId: '!!! YOUR GC PROJECT ID !!!',
   });
   ```

   > **About this step:**
   >
   > We recommend you moving the GatherContent credentials to
   > environment variables rather than hard-coding them in the
   > front-end app.
5. Add the following code:

   ```javascript
   const clients = new GatherContentClientList({ client });
   const gcEnhancer = createGatherContentEnhancer({ clients });
   ```
6. Add the following code:

   ```javascript
   await enhance({
       composition,
       enhancers: new EnhancerBuilder().parameterType(
       CANVAS_GATHERCONTENT_PARAMETER_TYPES, 
       gcEnhancer,
       ),
       context: {},
   });
   ```

   > **About this step:**
   >
   > This registers the enhancer to be used for any occurrence
   > of the GatherContent Items parameter.

> **Next steps:**
>
> Now, the parameter value in the composition is mutated to
> include the field values for the selected GatherContent item
> (instead of just being an identifier).
