> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Explorer - metadata view v1

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = href;
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

<RelatedLinks
  title="REQUIRED GUIDES"
  items={[
{ label: translate("Installation"), href: "/guides/embed/ui-elements/installation", badge: "GUIDE" }
]}
/>

<Note>
  The `v1` of the metadata view Content Explorer has reached end of support. While `v1` remains available in the `24.0.0` package, it will no longer receive bug fixes or new features. Follow the migration guide and switch to the `v2` metadata view of Content Explorer in order to receive the newest features.
</Note>

With Content Explorer you can display files and folders based on their metadata.
The metadata view uses <Link href="/reference/resources/get-metadata-templates-id">metadata template</Link> and <Link href="/guides/metadata/queries">metadata query</Link> to find the data you want to display.

<Frame>
  <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/embed/ui-elements/explorer-view.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=cf627a11cd18d49f716efd0a0466a84d" alt="Metadata view" width="1037" height="399" data-path="images/guides/embed/ui-elements/explorer-view.png" />
</Frame>

## Prerequisites

* Read the <Link href="/guides/embed/ui-elements/explorer">Content Explorer</Link> guide.
* Check the <Link href="/guides/metadata/#metadata-terminology">metadata terminology</Link>.
* Check the information on <Link href="/guides/metadata/queries">metadata queries</Link>.

## Create and configure an app

1. <Link href="/guides/applications/platform-apps/create">Create a Box app</Link>.
2. Add the local development address in the CORS Domains: <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/embed/ui-elements/box-app-cors.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=5a0ee09c03978dc56bcbd4d369eaa28f" alt="CORS Domains" width="1346" height="644" data-path="images/guides/embed/ui-elements/box-app-cors.png" />
3. Generate a <Link href="/guides/authentication/tokens/developer-tokens">developer token</Link>.

## Create a metadata template

The next step is to create a metadata template.

1. Use <Link href="/guides/metadata/templates/create">Metadata API</Link> or [Admin Console][creating-templates-ui] to create the template.
2. Apply an already created template to a Box folder. Make sure you enable the
   cascade policy. For detailed instructions, see
   [instructions on customizing and applying templates][apply-templates].

<Note>
  You can also apply a metadata template to a file.
</Note>

### Display name and key parameters

* The `displayName` parameter is the display name of the template visible
  in the Admin Console.
* The `templateKey` parameter is a unique identifier of the template. It needs
  to be unique across the enterprise for which you create the metadata template.
  If you don't provide the `templateKey` parameter, API creates a unique one
  based on the value in `displayName`.
* The `[fields].displayName` parameter is the display name of the field as it
  is shown to the user in the web and mobile apps.
* The `[fields].key` parameter is a unique identifier for a specific field in
  the template. The identifier must be unique within the template to which it
  belongs.

## Display metadata view

Proceed to fill in the necessary properties passed to the Content Explorer.
To make things easier, you can use a [sample project][metadata-project] based on a basic React app to launch metadata view.

1. Clone the metadata sample project.

2. Update the placeholders in [`App.js`][appjs] with actual values:

   | Parameter                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
   | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `DEVELOPER_TOKEN`        | <Link href="/guides/authentication/tokens/developer-tokens">Developer token</Link> generated in the the Developer Console.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
   | `ENTERPRISE_ID`          | Enterprise ID copied from the **General Settings** tab of your Box application.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
   | `METADATA_TEMPLATE_NAME` | `templateKey` of your already created metadata template. **Note**: To make sure you provided the proper name, use the <Link href="/reference/metadata/templates/get/#get-a-metadata-template-by-name">metadata API</Link> to retrieve the name, or copy it from the URL in the Admin Console. <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/embed/ui-elements/metadata-template-name.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=6e97a4db595636e965452ff3c0220b67" alt="Metadata name in Admin Console" width="1416" height="632" data-path="images/guides/embed/ui-elements/metadata-template-name.png" /> If you decide to change the template name in the UI, you change the display name only. The name to use in the component is always the one you provided at the beginning. |
   | `METADATA_SOURCE`        | Source of your <Link href="/guides/metadata/scopes">metadata</Link>. It's a string that combines the scope, enterprise ID, and metadata key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
   | `ROOTFOLDER_ID`          | ID of a Box folder to which you want to apply the metadata query and display filtered files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

   The `defaultView`, `fieldsToShow`, and `metadataQuery` parameters are already
   defined in the sample project. Examples of these parameters are available in the sample project.

   | Parameter       | Description                                                                                                                                                                                           |
   | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `defaultView`   | A required prop to paint the metadata view. If it's not provided, you get the regular file view.                                                                                                      |
   | `fieldsToShow`  | Add or hide specific metadata columns to display in the Content Explorer.                                                                                                                             |
   | `metadataQuery` | Provides a way to find files and folders by searching for the metadata attached to them. For additional information on metadata queries, see <Link href="/guides/metadata/queries">this guide</Link>. |

3. Pass the required parameters to the Content Explorer component.

A sample code for a React component including the Content Explorer metadata view would look as follows:

```js theme={null}
function App() {
    const token = "<DEVELOPER_TOKEN>";
    const rootFolderID = "<ROOTFOLDER_ID>";
    const EID = "<ENTERPRISE_ID>";
    const templateName = "<METADATA_TEMPLATE_NAME>";
    const metadataSource = `enterprise_${EID}.${templateName}`;
    const metadataSourceFieldName = `metadata.${metadataSource}`;
    const metadataQuery = {
    	from: metadataSource,
    	query: "key = :arg1",
    	query_params: { arg1: "value" },
    	ancestor_folder_id: 0,
    	fields: [
        `${metadataSourceFieldName}.name`,
        `${metadataSourceFieldName}.last_contacted_at`,
        `${metadataSourceFieldName}.industry`,
        `${metadataSourceFieldName}.role`,
        ],
    };

    const fieldsToShow = [
    // canEdit propetry determines if the user can edit the metadata directly from Content Explorer component
    { key: `${metadataSourceFieldName}.name`, canEdit: false },
    // displayName alows to change the label on metadata column
    { key: `${metadataSourceFieldName}.industry`, canEdit: false, displayName: "alias" },
    { key: `${metadataSourceFieldName}.last_contacted_at`, canEdit: true },
    { key: `${metadataSourceFieldName}.role`, canEdit: true },
    ];

const defaultView = "metadata";
return (
    <IntlProvider locale="en">
        <div className="App">
            <header className="App-header">
                <h2>Metadata view in Content Explorer</h2>
            </header>
            <section>
                <div className="metadata-based-view">
                    <ContentExplorer
                        rootFolderId={rootFolderID}
                        token={token}
                        metadataQuery={metadataQuery}
                        fieldsToShow={fieldsToShow}
                        defaultView={defaultView}
                    />
                </div>
            </section>
        </div>
    </IntlProvider>
);
}

export default App;
```

## Metadata keys

To decide which fields to show, the Content Explorer uses metadata
<Link href="/reference/post-metadata-templates-schema/#param-fields-key">field keys</Link>, not the <Link href="/reference/post-metadata-templates-schema/#param-fields-displayName">display names</Link>. You can see the
display names in the Admin Console and user view, but you can obtain the field
keys through the API.

The field keys are not changing, even if you change the metadata display name.
This ensures that the functionality works properly, despite any changes to the
metadata in UI view.

### Metadata keys sanitization

<Link href="/reference/post-metadata-templates-schema/#param-fields-key">Keys</Link> are restricted to alphanumeric characters only:

* No hyphens `-` or underscores `_` are permitted.
* Only letters (`a-z, A-Z`) and numbers (`0-9`) are allowed.

**Non-Latin characters:**

If keys contain characters from non-Latin alphabets (such as Cyrillic, Arabic,
Chinese, etc.) they are automatically renamed to generic identifiers:

* `field` for the first occurrence
* `field1`, `field2`, and so on for subsequent occurrences

Keys are based on the display names.

<Note>
  **TIP**: For a detailed flow, see [Metadata view blog post][blogpost].
</Note>

[blogpost]: https://medium.com/box-developer-blog/metadata-view-in-box-content-explorer-4978e47e97e9

[creating-templates-ui]: https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates

[appjs]: https://github.com/box-community/content-explorer-metadata/blob/main/src/App.js

[apply-templates]: https://support.box.com/hc/en-us/articles/360044196173-Using-Metadata

[metadata-project]: https://github.com/box-community/content-explorer-metadata/tree/main

[get-id]: /reference/get-metadata-templates-id-id-schema/

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("Get metadata template by ID"), href: "/reference/get-metadata-templates-id", badge: "GET" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("UI Elements"), href: "/guides/embed/ui-elements/index", badge: "GUIDE" }
]}
/>
