MateThemes Posted October 12, 2022 Share Posted October 12, 2022 Hello everyone. I need your help. I use in my template following code to render my uikit offcanvas. <div class="uk-offcanvas-bar uk-box-shadow-large"> <button class="uk-offcanvas-close" type="button" data-uk-close></button> <?php // example of caching generated markup (for 600 seconds/10 minutes) echo cache()->get('offcanvas-nav', 10, function() { return ukNav(pages('/')->children(), [ 'depth' => 2, 'accordion' => false, 'type' => 'default', 'class' => '', // 'blockParents' => [ 'blog' ], 'repeatParent' => true, 'noNavQty' => 20, 'maxItems' => 16, 'divider' => false, ]); }); ?> </div> In this code is the root page (home page) not render. I didn't find a solution to render the root page. May someone can help me! Thanks in advance. Link to comment Share on other sites More sharing options...
zoeck Posted October 12, 2022 Share Posted October 12, 2022 I'm not sure, but i think you can add the "header" with: 'header' => true, // - `header` (string|Page|bool): Nav header string, Page object, or boolean true to use Parent for header (default=''). Just have a look at the _uikit.php file: https://github.com/processwire/site-regular/blob/c2660b076b7413493b0c44d3057968066bd9236d/templates/_uikit.php#L50 Link to comment Share on other sites More sharing options...
MateThemes Posted October 12, 2022 Author Share Posted October 12, 2022 Thank you for your help @zoeck The only thing is that then the Home link is with uk-nav-header markup. Any ideas to render a normal nav item? Link to comment Share on other sites More sharing options...
zoeck Posted October 12, 2022 Share Posted October 12, 2022 I'm not sure... never used this profile ? But have a look at this line:https://github.com/processwire/site-regular/blob/c2660b076b7413493b0c44d3057968066bd9236d/templates/_uikit.php#L175 Just change it to the "normal nav item class"? Link to comment Share on other sites More sharing options...
fliwire Posted October 12, 2022 Share Posted October 12, 2022 <?php $home = pages("/"); echo cache()->get('offcanvas-nav', 10, function() { return ukNav($home->and($home->children), [ 'depth' => 2, 'accordion' => false, 'type' => 'default', 'class' => '', // 'blockParents' => [ 'blog' ], 'repeatParent' => true, 'noNavQty' => 20, 'maxItems' => 16, 'divider' => false, ]); }); ?> Link to comment Share on other sites More sharing options...
DaveP Posted October 12, 2022 Share Posted October 12, 2022 I tend to wrap more mark-up around than @fliwire, more like @MateThemes' original... <div id="offcanvas-nav" uk-offcanvas="overlay: true"> <div class="uk-offcanvas-bar"> <button class="uk-offcanvas-close" type="button" uk-close></button> <?= ukNav($home->and($home->children),array('depth' => 2,'blockParents' => array($home),'accordion' => true)); ?> </div> </div> $home is declared at the outset thus... <?php /* Declare PW namespace */ namespace ProcessWire; /* Initialise some variables */ $home = $pages->get('/'); As is always with PW there are limitless ways to 'flay a feline'. (Although there are strong similarities.) Link to comment Share on other sites More sharing options...
MateThemes Posted October 13, 2022 Author Share Posted October 13, 2022 Thank you very much for your help. Everything now works like a charm. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now