Active Class on Blog-Menu and Blog-Posts URL

woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

Hello,

i am working on my own Theme with this Navigation:

<?php foreach ($staticContent as $staticPage): ?>
<?php $active = ($staticPage->key() == $url->slug())? 'active': ''; ?>
<a class="<?php echo $active; ?>" href="<?php echo $staticPage->permalink(); ?>"><?php echo $staticPage->title(); ?></a>
<?php endforeach ?>


In my backend i set the static page "home" as my homepage and "/blog/" as my Blog-Page (Setting: URL-Filter).

When i Click "Blog" on my Navbar, the "active"-class is not showing up.
i guess it is because the slug() has a problem with the "/" at the end of the url "domain.com/blog/" is this correct? Is There a way to fix this?

Also i am confused with how my blog-posts show up in the URL.
I thought a Blogpost should have the URL "domain.com/blog/post-name" but instead it is "domain.com/postname" - is there a way to change it?

Thanks in advanced.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

woods wrote: Tue May 26, 2020 12:17 pm In my backend i set the static page "home" as my homepage and "/blog/" as my Blog-Page (Setting: URL-Filter).
There is a bug, this does not work at the moment. But there is a fix:

viewtopic.php?p=8106#p8106
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

i made the changes in the functions.php:

Code: Select all

	if (empty($args['homepage'])) {
		$args['homepage'] = '';
		$args['uriBlog'] = '';
	}
	
	if (empty($args['pageNotFound'])) {
		$args['pageNotFound'] = '';
	}

	if (isset($args['uriPage'])) {
		$args['uriPage'] = Text::addSlashes($args['uriPage']);
	}

	if (isset($args['uriTag'])) {
		$args['uriTag'] = Text::addSlashes($args['uriTag']);
	}

	if (isset($args['uriCategory'])) {
		$args['uriCategory'] = Text::addSlashes($args['uriCategory']);
	}

	if (!empty($args['uriBlog'])) {
		$args['uriBlog'] = Text::addSlashes($args['uriBlog']);
	} else {
		if (!empty($args['homepage']) && empty($args['uriBlog'])) {
			$args['uriBlog'] = '/blog/';
		} else {
			$args['uriBlog'] = '';
		}
	}
but it doesnt changed anything for me with the "active" class "problem".
maybe i misunderstood something?
i didn't had a problem to set the blog loop on a different page than home, that was possible without the changes above.

but thanks for the fast and helpful answers edi
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

woods wrote: Tue May 26, 2020 2:18 pm i didn't had a problem to set the blog loop on a different page than home, that was possible without the changes above.
Which version of Bludit do you use?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

3.12.0
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Strange... Have you updated the configuration from an earlier version?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

nope, i just started with this version 2 days ago.


do you maybe have a solution tipp for my firstquestion:

my navigation in my template:

<?php foreach ($staticContent as $staticPage): ?>
<?php $active = ($staticPage->key() == $url->slug())? 'active': ''; ?>
<a class="<?php echo $active; ?>" href="<?php echo $staticPage->permalink(); ?>"><?php echo $staticPage->title(); ?></a>
<?php endforeach ?>

When i Click "Blog" on my Navbar, the "active"-class is not showing up.
i guess it is because the slug() has a problem with the "/" at the end of the url "domain.com/blog/" is this correct? Is There a way to fix this?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Can you please give the address of the installation.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

Yep, its:
http://sebastian-stiebel.de/bludit/blog/
Please note that i'am just testing things out ;-)
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Could be the missing slash.

I will test it tomorrow.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply