Page 1 of 1

Static Pages in Navigation Bar

Posted: Fri Dec 18, 2020 8:11 pm
by vela025
Hi,

Following my previous post i decided to forego the testing stage and just put bludit on my paid host, which is working great.

I'm struggling with the navigation bar in the blog X, andy and alternative themes. I only want to be able to see top level pages in the navigation bar (I think I'm having the same issue as this user viewtopic.php?t=1756 . Unlike that user I don't need levels 3+ just Parent and Child.

For example if I have the following pages and structure:

---Reviews
+book1
+book2
+book3
---Camping
+trip1
+trip2
+trip3

I only want the navigation bar to show Reviews and Camping, not all the other Child pages.

I have a semi solution of changing Reviews and Camping to default (rather than static), setting all there related pages as children, and then going back to the reviews and camping pages and changing the page type back to static, but this seems a bit impractical to do each time I add more content.

I can't see a plugin that achieves this, I do have the more levels plugin installed but do not think that it is currently working. However did find something in the documentation about this (but now have lost the page :? , would I need to edit the php file?).

The theme I would like to use is Blog X, but I am willing to use any that solve this problem is anyone has any recommendations? Is this achievable using Bludit pro?

Cheers!

Re: Static Pages in Navigation Bar

Posted: Sat Dec 19, 2020 2:20 am
by Jay
Blogx generates menu using $staticPage variable, thus all nested static pages will be shown in menu.
Check the print navigation bar section in docs
https://docs.bludit.com/en/dev-snippets ... d-subpages

and use the snippet without the children part in conditional code

Re: Static Pages in Navigation Bar

Posted: Sat Dec 19, 2020 12:33 pm
by quicklyweb
in navbar.php of BLOGX theme

Below code shows the static pages and child as dropdown

Code: Select all

foreach ($staticContent as $staticPage) {
	$children = $staticPage->children();
	if (!$staticPage->isChild())
	{
		

			if ($staticPage->hasChildren())
			{
			    echo '<li class="nav-item dropdown">';
		         echo '<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="'. $staticPage->permalink().'">'.$staticPage->title().'</a>';

				echo PHP_EOL.'<div class="dropdown-menu" aria-labelledby="navbarDropdown">'.PHP_EOL;
				foreach ($children as $child) 
				{
					echo '<a class="dropdown-item" href="'.$child->permalink().'">'.$child->title().'</a>'.PHP_EOL;
				}
				echo '</div>'.PHP_EOL;
			} else {
			    echo '<li class="nav-item">';
	        	echo '<a class="nav-link" href="'. $staticPage->permalink().'">'.$staticPage->title().'</a>';
	}
		echo '</li>'.PHP_EOL;
	}
}
But if you don't want to show childs in dropdown just modify the code as below as below

in navbar.php of BLOGX theme

Below code shows the static pages and child as dropdown

Code: Select all

foreach ($staticContent as $staticPage) {
	$children = $staticPage->children();
	if (!$staticPage->isChild())
	{
			if ($staticPage->hasChildren())
			{
			    echo '<li class="nav-item dropdown">';
		         echo '<a class="nav-link"" href="'. $staticPage->permalink().'">'.$staticPage->title().'</a>';
			} else {
			    echo '<li class="nav-item">';
	        	echo '<a class="nav-link" href="'. $staticPage->permalink().'">'.$staticPage->title().'</a>';
	}
		echo '</li>'.PHP_EOL;
	}
}

Re: Static Pages in Navigation Bar

Posted: Sun Jan 03, 2021 11:18 am
by RalfKerkhoff
Hi Guys,

any hints/tips how to get this working in the Bluma Template?

The code works fine with the BlogX template, but I can not get it working with the Bluma theme.

Any hints are welcome.

cheers
ralf

Re: Static Pages in Navigation Bar

Posted: Sun Jan 03, 2021 3:23 pm
by Jay
RalfKerkhoff wrote: Sun Jan 03, 2021 11:18 am Hi Guys,

any hints/tips how to get this working in the Bluma Template?

The code works fine with the BlogX template, but I can not get it working with the Bluma theme.
This is basically a snippet I prepared, and posted some time ago, as the default menu snippet shown in docs stopped working in latest bludit version. At least for me.
Check the thread here: viewtopic.php?f=6&t=1894&p=9039

I won't be even able to reproduce your problem as you'd need to provide more information about errors you are experiencing.
First step is always towards showing php errors. You can find in docs how to do it.
I suppose that developer of template you mentioned used different variables to get pages data.

Re: Static Pages in Navigation Bar

Posted: Mon Jan 04, 2021 7:50 am
by RalfKerkhoff
Hi,
thanks for the snippets. The css part will be helpful.

Cheers
Ralf