Skip to content

feat(templates): Expose row flags for menu, page, crumbs - #29

Merged
Ibochkarev merged 3 commits into
masterfrom
feat/template-item-flags
Sep 2, 2026
Merged

feat(templates): Expose row flags for menu, page, crumbs#29
Ibochkarev merged 3 commits into
masterfrom
feat/template-item-flags

Conversation

@Ibochkarev

Copy link
Copy Markdown
Member

What

pdoMenu, pdoPage, and pdoCrumbs put boolean placeholders on each template row so one chunk can replace a stack of specialized tpl* files.

Values are 1 or 0 for Fenom {if $isActive} and MODX [[+isActive]].

Shared: isFirst, isLast, isActive. Menu also: hasChildren / hasChilds, isHere, isStart, isCategory, isInner. Page also: isSkip. Crumbs also: isHome.

Existing tplHere, tplParentRowActive, tplPageActive, tplCurrent, and the rest still win when set. Flags are always present either way.

Menu example:

<li {$classes}>
{if $isFirst}
    <i class="fas fa-home"></i>
{else}
    {if $isActive}
        <span>{$menutitle}</span>
    {else}
        <a class="nav__link" href="{$id|url}">{$menutitle}</a>
    {/if}
    {if $hasChilds}{$wrapper}{/if}
{/if}
</li>

Why

Without these flags you need separate chunks for current, parent, first, empty first/last page, and so on. The state was already computed for CSS classes and tpl selection; it was not exposed to the template.

Fixes #11

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.04575% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.66%. Comparing base (2ab402d) to head (9c73f19).

Files with missing lines Patch % Lines
core/components/pdotools/src/Support/Paginator.php 50.00% 17 Missing ⚠️
.../components/pdotools/src/Support/MenuItemState.php 86.58% 11 Missing ⚠️
.../components/pdotools/src/Support/PageItemState.php 94.44% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #29      +/-   ##
============================================
+ Coverage     20.74%   26.66%   +5.91%     
+ Complexity     1171     1165       -6     
============================================
  Files            15       18       +3     
  Lines          2964     3011      +47     
============================================
+ Hits            615      803     +188     
+ Misses         2349     2208     -141     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ibochkarev Ibochkarev self-assigned this Sep 2, 2026
@Ibochkarev Ibochkarev added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 2, 2026
One tpl can branch on isActive/hasChildren instead of many tpl*
chunks. Specialized templates stay. Menu state drives classes, tpl
pick, and placeholders from the same facts.

Fixes #11
Drop CrumbItemState and pageItemTplAndFlags; keep flags in Paginator and
snippet layers; freeze menu config on MenuItemState; fix category-at-0.
Harnesses capture getChunk so makePageLink/renderPageItem and
templateBranch flag merges are asserted without a live MODX install.
@Ibochkarev
Ibochkarev force-pushed the feat/template-item-flags branch from e5ced08 to 9c73f19 Compare September 2, 2026 07:02
@Ibochkarev
Ibochkarev merged commit 4fb22e6 into master Sep 2, 2026
15 checks passed
@Ibochkarev
Ibochkarev deleted the feat/template-item-flags branch September 2, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Добавить в шаблон переменные

1 participant