Masked the page 404

Post Reply
User avatar
LRAM
Master Bludit
Posts: 122
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Contact:

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
User avatar
diego
Site Admin
Posts: 703
Joined: Sat May 16, 2015 2:53 pm
Contact:

Fri Jul 05, 2019 8:43 pm

Hi,
I going to check, maybe some bug.
But the page selected for 404 should not appear.
User avatar
Jay
Master Bludit
Posts: 69
Joined: Mon Feb 11, 2019 8:41 pm

Sat Jul 06, 2019 12:02 am

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
User avatar
LRAM
Master Bludit
Posts: 122
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Contact:

Sat Jul 06, 2019 9:21 am

Thank Jay
In the waiting of the correction of the bug, i will try to insert your code
User avatar
LRAM
Master Bludit
Posts: 122
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Contact:

Sat Jul 06, 2019 10:07 am

Well I can't find the right way to do it
i'll wait to Diego's correction
have a good day
User avatar
Jay
Master Bludit
Posts: 69
Joined: Mon Feb 11, 2019 8:41 pm

Sat Jul 06, 2019 3:53 pm

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-)
User avatar
LRAM
Master Bludit
Posts: 122
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Contact:

Sat Jul 06, 2019 9:26 pm

It works like a charm, thank a lot
Post Reply