Page 1 of 1

Masked the page 404

Posted: Wed Jul 03, 2019 10:15 am
by LRAM
Hi
on this website
https://sucrepop.com/bludit-3-9-2

I made my own page 404
but it appears on the home page or in the menu if static. I want to hide it, it should only be visible when there's a wrong adress, or a moved page but I can't find how to do it

Re: Masked the page 404

Posted: Fri Jul 05, 2019 8:43 pm
by diego
Hi,
I going to check, maybe some bug.
But the page selected for 404 should not appear.

Re: Masked the page 404

Posted: Sat Jul 06, 2019 12:02 am
by Jay
LRAM wrote:
Wed Jul 03, 2019 10:15 am
Hi
on this website
https://sucrepop.com/bludit-3-9-2

I made my own page 404
but it appears on the home page or in the menu if static. I want to hide it, it should only be visible when there's a wrong adress, or a moved page but I can't find how to do it
For 404 as a static page (404 as URI) you can find the place where menu is generated, and just add a condidtional statement like:

Code: Select all

if ($staticPage->slug() != "404") {
 // list menu items
}
diego wrote:
Fri Jul 05, 2019 8:43 pm
But the page selected for 404 should not appear.
For B 3.8.0 custom 404 page was never hidden.
Since I use above mentioned conditional in template I have no idea if this was a bug and does occur from this version until newest 3.9.2

Re: Masked the page 404

Posted: Sat Jul 06, 2019 9:21 am
by LRAM
Thank Jay
In the waiting of the correction of the bug, i will try to insert your code

Re: Masked the page 404

Posted: Sat Jul 06, 2019 10:07 am
by LRAM
Well I can't find the right way to do it
i'll wait to Diego's correction
have a good day

Re: Masked the page 404

Posted: Sat Jul 06, 2019 3:53 pm
by Jay
LRAM wrote:
Sat Jul 06, 2019 10:07 am
Well I can't find the right way to do it
Set the url of 404 page as "404" if you haven't already done upon page creation.
Edit the navbar.php file located in themes/portfolio/php/ directory
Look for below code:

Code: Select all

<!-- Static pages -->
<?php foreach ($staticContent as $staticPage): ?><li>
	<a href="<?php echo $staticPage->permalink() ?>"><?php echo $staticPage->title() ?></a>
</li>
<?php endforeach ?>
Change it to

Code: Select all

<?php foreach ($staticContent as $staticPage): ?>
<?php if ($staticPage->slug() != "404") { // hide 404 error page from menu ?>
<li>
	<a href="<?php echo $staticPage->permalink() ?>"><?php echo $staticPage->title() ?></a>
</li>
<?php } ?>
<?php endforeach ?>
continue to have a great day 8-)

Re: Masked the page 404

Posted: Sat Jul 06, 2019 9:26 pm
by LRAM
It works like a charm, thank a lot