/redaxo-structure:structure-categoriesfrom redaxo-structure
Builds REDAXO navigation menus, breadcrumbs, and sitemaps using rex_category tree traversal, parent/child relationships, and current path detection.
Ships in redaxo-structure. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
rex_category represents a node in the structure tree. Each category has a "start article" (the page shown when the category itself is requested) plus zero or more child articles and child categories.
Like articles, a category exists per language. The tree topology is shared across languages, but name and online status differ.
// By ID (current clang)
$cat = rex_category::get($id);
// By ID + specific clang
$cat = rex_category::get($id, $clangId);
// Current category (parent of the current article)
$cat = rex_category::getCurrent();
// All top-level (root) categories
$rootCats = rex_category::getRootCategories(true); // true = only online
$cat->getId();
$cat->getName();
$cat->getParentId(); // 0 for root categories
$cat->getParent(); // rex_category or null
$cat->getPath(); // pipe-separated ID path: "|2|7|"
$cat->getPathAsArray(); // [2, 7]
$cat->getLevel(); // depth (0 = root)
$cat->getStartArticleId(); // article shown when category is requested
$cat->getStartArticle(); // rex_article instance
$cat->getUrl(); // URL of the start article
$cat->getValue('cat_meta_X'); // category meta_info field
$cat->isOnline();
$cat->isPermitted(); // current user can see it (backend perms)
$cat->getChildren(true); // direct subcategories (true = only online)
$cat->getArticles(true); // direct articles in this category
For children of a category by ID without instantiating it first:
rex_category::getChildrenById($parentId, true); // root if $parentId === 0
Recursive simple example (top-2-level menu):
function renderNavigation(array $categories, int $maxLevel = 2): string
{
$html = '<ul class="nav">';
foreach ($categories as $cat) {
if (!$cat->isOnline()) {
continue;
}
$isCurrent = in_array($cat->getId(), rex_category::getCurrent()?->getPathAsArray() ?? [], true)
|| $cat->getId() === rex_category::getCurrent()?->getId();
$cls = $isCurrent ? ' class="active"' : '';
$html .= '<li' . $cls . '>';
$html .= '<a href="' . $cat->getUrl() . '">' . rex_escape($cat->getName()) . '</a>';
if ($cat->getLevel() < $maxLevel - 1 && ($children = $cat->getChildren(true))) {
$html .= renderNavigation($children, $maxLevel);
}
$html .= '</li>';
}
return $html . '</ul>';
}
echo renderNavigation(rex_category::getRootCategories(true));
$current = rex_category::getCurrent();
if ($current) {
$crumbs = [];
foreach ($current->getPathAsArray() as $id) {
$crumbs[] = rex_category::get($id);
}
$crumbs[] = $current; // include the current category itself
echo '<nav class="breadcrumb"><ol>';
foreach ($crumbs as $crumb) {
echo '<li><a href="' . $crumb->getUrl() . '">' . rex_escape($crumb->getName()) . '</a></li>';
}
// current article (if not the start article of the category)
$article = rex_article::getCurrent();
if ($article && !$article->isStartArticle()) {
echo '<li class="active">' . rex_escape($article->getName()) . '</li>';
}
echo '</ol></nav>';
}
Use rex_category_service, not direct SQL:
// addCategory() returns a status message, not the ID – capture the ID from CAT_ADDED
$id = null;
rex_extension::register('CAT_ADDED', static function (rex_extension_point $ep) use (&$id): void {
$id = (int) $ep->getParam('id');
});
rex_category_service::addCategory(
$parentId, // 0 for root
[
'catname' => 'New section', // required
'catpriority' => 1, // required
'status' => 1, // optional, defaults to 0 (offline)
]
);
// The category is created in all languages – there is no clang parameter.
if (null === $id) {
throw new RuntimeException('CAT_ADDED did not fire – addCategory() failed or capturing code changed');
}
rex_category_service::editCategory($id, rex_clang::getCurrentId(), [
'catname' => 'Renamed section',
]);
rex_category_service::deleteCategory($id);
Setting/changing the start article of a category:
// $articleId must be a normal article inside a (non-root) category.
// The article swaps places with the old start article and takes over the category,
// so afterwards the category has the ID $articleId. Returns false if not possible.
rex_article_service::article2startarticle($articleId);
In backend tools, always check before showing/manipulating:
$cat = rex_category::get($id);
if (!$cat || !rex_article_perm::has(rex::getUser(), $cat->getId())) {
return;
}
For frontend navigation, isOnline() is enough – the structure addon already filters by online status.
isOnline() on each level – offline parents whose children are online become reachable via direct URL but not from the menu.rex_yrewrite::getCurrentDomain()->getMountId() for "below this domain's root". On multi-domain sites see the yrewrite-domains skill for the full domain-rooted navigation pattern.CAT_ADDED listener inside a loop – rex_extension has no unregister, every registration stays active for the rest of the request. Register once, read the captured ID right after each addCategory() call.getChildren() without the $ignore_offlines = true flag in a public template, then leaking offline categories into navigation.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub friendsofredaxo/claude-marketplace --plugin redaxo-structure4 skills in this plugin
/structure-articlesWorking with REDAXO articles via rex_article – fetching, listing, status, dates, URLs, and the start/notfound/site articles. Use when the user reads or modifies article data, builds article lists for templates, queries the structure tree, or handles per-language article variants./structure-contentSlice management in REDAXO – the content blocks that make up an article. Use when the user creates/edits/deletes slices programmatically, lists slices of an article, copies content between articles, or syncs content between languages./structure-meta-infoOther plugins' skills for the same job