Jump to content

_uikit.php by Ryan


MateThemes
 Share

Recommended Posts

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

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

<?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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...