U
U
uhogorlonos2022-03-04 15:09:51
MODX
uhogorlonos, 2022-03-04 15:09:51

Is it possible to make Bootstrap tabs on Pdomenu in one call?

Bootstrap has a handy tab element. It consists of 2 parts: the tabs themselves (switches) and the content area, which changes depending on the pressed tab.

<nav>
  <div class="nav nav-tabs" id="nav-tab" role="tablist">
    <button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>
    <button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>
    <button class="nav-link" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</button>
  </div>
</nav>
<div class="tab-content" id="nav-tabContent">
  <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">...</div>
  <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
  <div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>

Since in the first and second blocks you need to wrap all the items of the generated menu with the appropriate code, I did this using 2 calls to Pdomenu - for the top and bottom. Is it possible to do it in one call and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Lunegov, 2022-03-05
@alelunegov

Through pdoMenu only two calls. If you use the Fenom template engine, then you can make 1 query to the database through it. Example:

{var $resources = $_modx->getResources(
    ['published' => 1, 'deleted' => 0],
    ['sortby' => 'id', 'sortdir' => 'ASC', 'limit' => 50]
)}

And then iterate over the array twice. Approximately like this:
{foreach $resources as $resource}
    {$_modx->getChunk('@INLINE <p>{$id} {$pagetitle}</p>', $resource)}
{/foreach}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question