Aktives Menüelement

User avatar
planlos
Jr. Bludit
Posts: 3
Joined: Thu Nov 21, 2019 9:31 am

Das funktioniert für statische Links prima! Vielen Dank @kohbarg!

Fehlt noch die normale Navigation. Ich habe geschaut und versucht es selbst zu lösen. Editiert habe ich:
/bl-plugins/navigation/plugin.php
Zeile 76 ORIGINAL

Code: Select all

		// Pages order by position
		if (ORDER_BY=='position') {
			// Get parents
			$parents = buildParentPages();
			foreach ($parents as $parent) {
				$html .= '<li class="parent">';
				$html .= '<a href="' . $parent->permalink() . '">' . $parent->title() . '</a>';
Mein Versuch:

Code: Select all

		// Pages order by position
		if (ORDER_BY=='position') {
			// Get parents
			$parents = buildParentPages();
			$active = ($parent->key() == $url->slug())? 'active': '';
			foreach ($parents as $parent) {
				$html .= '<li class="parent ' . $active . '">';
				$html .= '<a href="' . $parent->permalink() . '">' . $parent->title() . '</a>';

Leider ohne Erfolg.

Ein schönes Wochenende allerseits!
kohbarg
Sr. Bludit
Posts: 33
Joined: Tue Jun 11, 2019 11:36 am
Has thanked: 2 times
Been thanked: 2 times

So auf die schnelle:

Code: Select all

// Pages order by position
		if (ORDER_BY=='position') {
			// Get parents
			$parents = buildParentPages();
			//Hier gibts noch kein $parent nur $parents (mit s)
			//$active = ($parent->key() == $url->slug())? 'active': '';
			foreach ($parents as $parent) {
				//Vielleicht sollte die Abfrage hier hin
			$active = ($parent->key() == $url->slug())? 'active': '';
			
				$html .= '<li class="parent ' . $active . '">';
				$html .= '<a href="' . $parent->permalink() . '">' . $parent->title() . '</a>';
				
User avatar
planlos
Jr. Bludit
Posts: 3
Joined: Thu Nov 21, 2019 9:31 am

Guten Morgen!
Vielen Dank für den Hinweis @kohbarg, an der Stelle funktioniert die Codezeile prima!
Für child auch noch eingebaut. Nun zeigt Bludit das Verhalten, was ich haben möchte. :)

Viele Grüße
planlos
Post Reply