Ana içeriğe geç

Introduction

Build navigation and faceted filtering from a single, localized content filter tree.

More information about the module's user interface https://doc.oneentry.cloud/docs/category/filters


🎯 What does this module do?

The Filters module lets you retrieve a content filter by its marker. A content filter is a curated, localized tree of items - it can mix pages, products, attributes, discounts, bonuses, payment methods and custom entries in a single structure.

Think of it as a configurable menu of "things to filter by" - you define the tree once in the OneEntry admin panel and pull it into your app to render navigation, faceted filters or curated lists. The SDK is read-only: filters are retrieved by marker.

🚀 Quickstart

Initialize the module from defineOneEntry:


const { Filters } = defineOneEntry(
"your-project-url", {
"token": "your-app-token"
}
);

Fetch a filter by marker and walk its items tree:

// Fetch the "main" content filter, localized to English.
const filter = await Filters.getFilterByMarker("main", "en_US");

console.log(filter.localizeInfos.title);

filter.items?.forEach((node) => {
console.log(node.type, node.marker ?? node.url, node.children?.length ?? 0);
});

✨ Key Concepts

Marker

Every filter has a unique marker (for example main). You request a filter by marker, and the response is localized to the requested langCode.

Items tree

The items array is a tree: regular and custom items live in the same array, and each node can have nested children. Walk the tree to render your UI.

Each node has a type that points to something in your project:

  • page - a link to a page (exposes a url)
  • product - a product entry
  • attribute - an attribute to filter by
  • discount / personal-discount - a discount entry
  • bonus - a bonus entry
  • payment-method - a payment method
  • admin - an admin entry
  • custom - a custom entry you defined

Each node carries localized info (localizeInfos) and may contain nested children, so you can render multi-level filters and menus directly from the response.

📋 What You Need to Know

  • Pass a langCode to get the filter localized to a specific language (defaults to en_US).
  • Page nodes (type: "page") expose a url; other node types use marker to reference their entity.
  • The value field carries a unified node value (for example a discount value or an attribute title) when applicable, and is null otherwise.

📊 Quick Reference Table

MethodDescription
getFilterByMarker()Get a content filter by its marker

❓ Common Questions (FAQ)

Where do content filters come from?

Content filters are configured in the OneEntry admin panel. The SDK retrieves them read-only by marker.


How do I render a multi-level filter?

Recursively walk the items array - each node may contain a children array with the same node shape.


🎓 Best Practices

  • Reference filters by marker, never by a display title.
  • Request the filter in the user's current language via langCode.
  • Cache filters - they change rarely.