WBCE CMS Forum

WBCE CMS – Way Better Content Editing.

You are not logged in.

Announcement

#1 06.10.2019 13:50:53

gawi
Member

show_menu2 breadcrumb

Hi

I have problem with breadcrumb displaing (WBCE1.4)

In the template I use following code for beradcrumb:

<p class="breadcrumb">
                    <a href="<?php echo WB_URL; ?>">
                      <i class="icon-home" aria-hidden="true"></i></a> /
                    <?php show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_CRUMB, '<span class="[class]"> / [a][menu_title]</a></span>', '', '', '', '<span class="[class]">[a][menu_title]</a></span>');?>
</p>

As a result the following html code is created:

    <p class="breadcrumb">
      <a href="http://localhost:3000/mysite">
        <i class="icon-home" aria-hidden="true"></i></a> /
      <span class="menu-expand menu-parent menu-first">
        <a href="http://localhost:3000/mysite/pl/page.php" target="_top" title="Page">Page</a>
      </span>
      <span class="menu-current"> /
        <a href="http://localhost:3000/mysite/pl/page/subpage.php" target="_top" title="Subpage">Subpage</a>
      </span>
      </span>
    </p>

At the end of breadcrumb additional </span> closing tag is added and HTML validator shows error.

Can you help me to find what what is wrong with the breadcrumb code?

Best Regards
Gawi

Offline

#2 06.10.2019 15:17:05

bernd
Developer

Re: show_menu2 breadcrumb

Not sure if this is the reason, but in your SM2 call the last parameter is missing, try it this way:

show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_CRUMB, '<span class="[class]"> / [a][menu_title]</a></span>', '', '', '', '<span class="[class]">[a][menu_title]</a></span>',false);

... nein in Europa verwenden wir beim Programmieren nicht € statt $ ...

Offline

#3 06.10.2019 15:45:27

gawi
Member

Re: show_menu2 breadcrumb

Thank you for answer. Unfortunately it did not helped. Still additional </span> is added at the and.

Regards Gawi

Offline

#4 06.10.2019 16:12:44

colinax
Member

Re: show_menu2 breadcrumb

Hi gawi,

i have checked bernds code and there are no too many span elements, so the span element must be in your template.

Offline

#5 06.10.2019 17:22:39

gawi
Member

Re: show_menu2 breadcrumb

ok. Thank you. I will for fault.
Regards
Gawi

Offline

#6 06.10.2019 17:32:18

colinax
Member

Re: show_menu2 breadcrumb

Can you display the whole code from the index.php of your template?

Offline

#7 06.10.2019 18:36:46

gawi
Member

Re: show_menu2 breadcrumb

I found my error.
I use breadcrumb code in two places in my template. When I corrected code in both places according to you suggestion everything it is ok.

<?php show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_CRUMB, '<span class="[class]"> / [a][menu_title]</a></span>', '', '', '', '<span class="[class]">[a][menu_title]</a></span>',false);?>

Thank you for help.

Best Regards
Gawi

Offline

#8 12.02.2025 09:25:54

benvo
Member

Re: show_menu2 breadcrumb

How do I also display the subpages of NWI entries with this structure?

<?php show_menu2(SM2_ALLMENU, SM2_ROOT, SM2_ALL, SM2_CRUMB, '<span class="[class]"> > <a href="[ url ]" title="[menu_title]">[menu_title]</a>', '</span>', '', '', '<strong>Your are here:</strong> <span class="[class]"><a href="[ url ]" title="[menu_title]">[menu_title]</a>' ); ?>

Offline

#9 13.02.2025 07:53:14

florian
Administrator

Re: show_menu2 breadcrumb

It's not that easy. The data of a news item is not available in the show_menu2 output. You would need to buffer the output, replace the menu-current flag, execute a database query to fetch the post details and finally attach them to the output.
So here's the code:

<?php 
$bcrmb = show_menu2(SM2_ALLMENU, SM2_ROOT, SM2_ALL, SM2_CRUMB|SM2_BUFFER, '<span class="[class]"> > <a href="[url]" title="[menu_title]">[menu_title]</a>', '</span>', '', '', '<strong>Your are here:</strong> <span class="[class]"><a href="[url]" title="[menu_title]">[menu_title]</a>' ); 
if (isset($post_id)) {				
	$bcrmb = str_replace('class="menu-current"','',$bcrmb);
	$news_table = TABLE_PREFIX . 'mod_news_img_posts';
	$sql = 'SELECT * FROM '.$news_table.' WHERE `post_id` = '.$post_id;
	$res = $database->query($sql);
	while ($row = $res->fetchRow()) {
		$bcrmb.='<span class="menu-current"> > <a href="">'.$row['title'].'</a></span>';
	}
}
echo $bcrmb;
?>

Last edited by florian (13.02.2025 07:56:11)


Sorgen sind wie Nudeln: man macht sich meist zu viele.

Offline

#10 01.03.2025 20:57:19

mobade
Member

Re: show_menu2 breadcrumb

und in welcher datei wird der Code eingefügt?


bei mir dreht sich vieles um die Modelleisenbahn in der Spurweite TT 
Webseite: mobade.de

Offline

#11 01.03.2025 20:59:34

florian
Administrator

Re: show_menu2 breadcrumb

This is the international support section, please write in english.

The code has to be placed in the index.php of your template. It depends on the template structure whether you can copy & paste it or further customizing is needed.


Sorgen sind wie Nudeln: man macht sich meist zu viele.

Offline

Board footer

up