Recent update changed breadcrumbs

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Grantovich

Recent update changed breadcrumbs

Post by Grantovich »

After upgrading from 1.0.2 to 1.0.3 and then soon afterwards to 1.0.4, the appearance of my breadcrumbs has changed. It seems like the "root" attribute for the breadcrumbs tag is now being ignored. They used to look like this:

Home » Some Page » Some Other Page

After the updates, they look like this:

Some Page » Some Other Page

Aside from the updates themselves, I didn't change anything on the site. The tag in my template looks like this:

Code: Select all

{breadcrumbs starttext='You are here' root='Home' delimiter='»'}
I thought it might be a case issue and changed "Home" to "home", but that didn't have any effect. I noticed in the changelog for 1.0.4 that something was changed/fixed with breadcrumbs, anybody know more about that?
Grantovich

Re: Recent update changed breadcrumbs

Post by Grantovich »

Anyone? I found this post that seems to be talking about a similar issue, but apparently the problem was fixed in 1.0.4 (which I have, but the breadcrumbs still act strangely).
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Recent update changed breadcrumbs

Post by Ted »

Sounds like it's still broken...  It's quite frustrating.  That code is a bit fragile... apparently a little too fragile.
cenzo
New Member
New Member
Posts: 3
Joined: Sat Feb 10, 2007 12:59 pm

Re: Recent update changed breadcrumbs

Post by cenzo »

Maybe i'm too late, but i've made some change in function.breadcrumbs.php trying to solve this problem. I hope this is the right way (works for me).


from line 61 to line 96 replace

Code: Select all

	        $content =& $endNode->getContent();
		$path=array($endNode);
		$currentNode = &$endNode->getParentNode();
		while (isset($currentNode) && $currentNode->getLevel() >= 0)
		{
			$content = &$currentNode->getContent();
			if (isset($content))
			{
			  //Add current node to the path and then check to see if
			  //current node is the set root
			  //as long as it's not hidden
			  if( $content->ShowInMenu() && $content->Active() )
			    {
				$path[] = $currentNode;
			    }
			  if (strtolower($content->Alias())!=strtolower($root))
			    {
			      //Get the parent node and loop
			      $currentNode = &$currentNode->getParentNode();
			    }
			  else
			    {
			      //No need to get the parent node -- we're the set root already
			      break;
			    }
			}
			else
			{
			  //There are more serious problems here, dump out while we can
			  break;
			}
		}

		if ($root!='##ROOT_NODE##') {
	# check if the last added is root. if not, add id
                    $currentNode = &$manager->sureGetNodeByAlias($root);
with

Code: Select all

		$content = &$endNode->getContent();
		$path=array($endNode);
		//if $thispage is the root page no need to add parent node to path[]
		if(strtolower($content->Alias()) != strtolower($root)){
			$currentNode = &$endNode->getParentNode();
			while (isset($currentNode) && $currentNode->getLevel() >= 0)
			{
				$content = &$currentNode->getContent();
				if (isset($content))
				{
				//Add current node to the path and then checkHome to see if
				//current node is the set root
				//as long as it's not hidden
				if( $content->ShowInMenu() && $content->Active() )
				{
					$path[] = $currentNode;
				}
					if (strtolower($content->Alias())!=strtolower($root))
					{
						//Get the parent node and loop
						$currentNode = &$currentNode->getParentNode();
					}
					else
					{
						//No need to get the parent node -- we're the set root already
					break;
					}
				}
				else
				{
				//There are more serious problems here, dump out while we can
				break;
				}
			}
		}
		//if $endNode is at the first level $currentNode = null so i set it to $endNode
		if(!isset($currentNode))
			$currentNode=$endNode;
		if ($root!='##ROOT_NODE##') {
	# check if the last added is root. if not, add id
			//$currentNode = &$manager->sureGetNodeByAlias($root);



Now breadcrumbs works for me.  8) 
P.s. sorry for my english 
Last edited by cenzo on Sun Feb 18, 2007 9:46 pm, edited 1 time in total.
miss_d_bus
Forum Members
Forum Members
Posts: 121
Joined: Sun May 01, 2005 4:27 pm

Re: Recent update changed breadcrumbs

Post by miss_d_bus »

I tried this and it did not work for me. :(

Thanks for trying though.

Catherine
cenzo
New Member
New Member
Posts: 3
Joined: Sat Feb 10, 2007 12:59 pm

Re: Recent update changed breadcrumbs

Post by cenzo »

miss_d_bus wrote: I tried this and it did not work for me. :(

Thanks for trying though.

Catherine
Can you explain your problem? give me some info:
version of CMSMS you are using, breadcrumbs behavior, your page tree and wich is your root page.
I really need to see breadcrumbs work, so you can help me to fix it. Thanks. 

This is my complete function.breadcrumbs.php file, try to replace the entire file (remeber to backup the original), maybe i miss something in the previous post or you had a cut and paste problem :) so please try.

Code: Select all

<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

function smarty_cms_function_breadcrumbs($params, &$smarty)
{

	global $gCms; 
	$manager = &$gCms->GetHierarchyManager();

	$thispage = $gCms->variables['content_id'];

	$trail = "";

#Check if user has specified a delimiter, otherwise use default
	if (isset($params['delimiter'])) {
		$delimiter = $params['delimiter'];
	}	else {
		$delimiter = ">>";
	}

#Check if user has requested an initial delimiter
	if (isset($params['initial'])) {
		if ($params['initial'] == "1") {
			$trail .= $delimiter . " ";
		}
	}

	$root='##ROOT_NODE##';
	
#Check if user has requested the list to start with a specific page
	if (isset($params['root']))	{
		$root = $params['root'];
	}
	$root_url='';
#Check if user has requested to overrided the root URL
	if (isset($params['root_url']))	{
		$root_url = $params['root_url'];
	}


	$endNode = &$manager->sureGetNodeById($thispage);

# build path
	if (isset($endNode))
	{
		$content = &$endNode->getContent();
		$path=array($endNode);
		//if $thispage is the root page no need to add parent node to path[]
		if(strtolower($content->Alias()) != strtolower($root)){
			$currentNode = &$endNode->getParentNode();
			while (isset($currentNode) && $currentNode->getLevel() >= 0)
			{
				$content = &$currentNode->getContent();
				if (isset($content))
				{
				//Add current node to the path and then checkHome to see if
				//current node is the set root
				//as long as it's not hidden
				if( $content->ShowInMenu() && $content->Active() )
				{
					$path[] = $currentNode;
				}
					if (strtolower($content->Alias())!=strtolower($root))
					{
						//Get the parent node and loop
						$currentNode = &$currentNode->getParentNode();
					}
					else
					{
						//No need to get the parent node -- we're the set root already
					break;
					}
				}
				else
				{
				//There are more serious problems here, dump out while we can
				break;
				}
			}
		}
		//if $endNode is at the first level $currentNode = null so i set it to $endNode
		if(!isset($currentNode))
			$currentNode=$endNode;
		if ($root!='##ROOT_NODE##') {
	# check if the last added is root. if not, add id
			//$currentNode = &$manager->sureGetNodeByAlias($root);
			
			if (isset($currentNode))
			{
				$content = &$currentNode->getContent();
				
				if (isset($content) && (strtolower($content->Alias()) != strtolower($root)))
				{
					$node = &$manager->sureGetNodeByAlias($root);
					if (isset($node)) {
						$content = &$node->getContent();
						if ($content->Id()!=$thispage) 
                                                      $path[] = $node; # do not add if this is the current page
					}
				}
			}
		}
		$classid=isset($params['classid'])?(' class="' . $params['classid'] . '"'):'';
		$currentclassid=isset($params['currentclassid'])?(' class="' . $params['currentclassid'] . '"'):'';
	# now create the trail (by iterating through the path we built, backwards)
		for ($i=count($path)-1;$i>=0;$i--) {
			$node = &$path[$i];
			if (isset($node))
			{
				$onecontent = &$node->getContent();
				if ($onecontent->Id() != $thispage && $onecontent->Type() != 'seperator') {
					if (($onecontent->getURL() != "") && ($onecontent->Type() != 'sectionheader')) {
					  if ($onecontent->DefaultContent() && false == empty($root_url))
					    {
					      $trail .= '<a href="' . $root_url . '"';     
					    }
					      else
						{
						  $trail .= '<a href="' . $onecontent->getURL() . '"';
						}
						$trail .= $classid;
						$trail .= '>';
						$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
						$trail .= '</a> ';
					} else {
						$trail .= "<span $classid>";
						$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
						$trail .= '</span>';
						$trail .= ' ';
					}
					$trail .= $delimiter . ' ';
				} else {
					if (isset($params['currentclassid'])) {
						$trail .= "<span $currentclassid>";
					} else {
						$trail .= '<strong>';
					}
					$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
					if (isset($params['currentclassid'])) {
						$trail .= '</span>';
					} else {
						$trail .= '</strong>';
					}
				}
			}
		}
	}

	if (isset($params['starttext']) && $params['starttext'] != '')
	{
		$trail = $params['starttext'] . ': ' . $trail;
	}

	return $trail;  

}
	
function smarty_cms_help_function_breadcrumbs() {
// tdh added the classid help text
?>
<h3>What does this do?</h3>
<p>Prints a breadcrumb trail .</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{breadcrumbs}</code></p>
<h3>What parameters does it take?</h3>
<p>
<ul>
<li><em>(optional)</em> <tt>delimiter</tt> - Text to seperate entries in the list (default ">>").</li>
<li><em>(optional)</em> <tt>initial</tt> - 1/0 If set to 1 start the breadcrumbs with a delimiter (default 0).</li>
<li><em>(optional)</em> <tt>root</tt> - Page alias of a page you want to always appear as the first page in
    the list. Can be used to make a page (e.g. the front page) appear to be the root of everything even though it is not.</li>
<li><em>(optional)</em> <tt>root_url</tt> - Override the URL of the root page. Useful for making link be to '/' instead of '/home/'. This requires that the root page be set as the default page.</li>

<li><em>(optional)</em> <tt>classid</tt> - The CSS class for the non current page names, i.e. the first n-1 pages in the list. If the name is a link it is added to the <a href> tags, otherwise it is added to the <span> tags.</li>
<li><em>(optional)</em> <tt>currentclassid</tt> - The CSS class for the <span> tag surrounding the current page name.</li>
<li><em>(optional)</em> <tt>starttext</tt> - Text to append to the front of the breadcrumbs list, something like "You are here".</li>
</ul>
</p>
<?php
}

function smarty_cms_about_function_breadcrumbs() {
?>
<p>Author: Marcus Deglos <<a href="mailto:md@zioncore.com">md@zioncore.com</a>></p>
<p>Version: 1.7</p>
<p>
Change History:<br/>
1.1 - Modified to use new content rewrite (wishy)<br />
1.2 - Added parameters: delimiter, initial, and root (arl)<br />
1.3 - Added parameter: classid (tdh / perl4ever)<br />
1.4 - Added parameter currentclassid and fixed some bugs (arl)<br />
1.5 - Modified to use new hierarchy manager<br />
1.6 - Modified to skip any parents that are marked to be "not shown in menu" except for root<br />
1.7 - Added root_url parameter (elijahlofgren)<br />
</p>
<?php
}
# vim:ts=4 sw=4 noet
?>

miss_d_bus
Forum Members
Forum Members
Posts: 121
Joined: Sun May 01, 2005 4:27 pm

Re: Recent update changed breadcrumbs

Post by miss_d_bus »

Sorry for the delay in replying.

I have tried the version you pasted here but it has the same problem so we can rule out copy and pasting errors.

I am using CMS Made Simple 1.0.4 "Lanai"

The code I am using for the breadcrumbs is the following:
{breadcrumbs root="home"}

home is index.php. (I am using Apache mod-rewrite)

There are 8 pages at root in the main menu and when accessing each menu item, it has its own menu display.
These 8 menu items are at the same level as index (home), but its the breadcrumb code that makes it appear as if it is above in a 'virtual hierachy'.

So for example, i am now not getting the 'home >>' at the beginning of the breadcrumbs.
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Recent update changed breadcrumbs

Post by kermit »

i dunno where i been the last few weeks...  ???  but i just noticed breadcrumbs aren't right on four sites running 1.02 or 1.04.

using optional parameter root='home' does NOT display that page before others (other than itself) in the trail.

and if we can root_url override the site default page's url here... why not in menu and cms_selflink? just wondering... ;)


cenzo: your updated file worked... [glow=yellow,2,300]thanks![/glow]
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
miss_d_bus
Forum Members
Forum Members
Posts: 121
Joined: Sun May 01, 2005 4:27 pm

Re: Recent update changed breadcrumbs

Post by miss_d_bus »

i tried the new version again to double check but it does not work still properly.

Some of the pages it just does not work at all with 'home >>' not appearing.
Where the breadcrumb does work, the top part of the page loads but i get the following error message where the page menu should be:

Fatal error:  Maximum execution time of 30 seconds exceeded in /home/stedmund/public_html/lib/Tree/Tree.php on line 645

Under this error, the rest of the page does not load.


I hope this helps,
Catherine
tntstudio

Re: Recent update changed breadcrumbs

Post by tntstudio »

Cenzo: Thank you for posting the code. I tried your fix however I too ran into a problem - root & root_url worked again for the top level & one level below, but as soon as I hit 2 levels below root, my pages stopped displaying altogether.

I swapped your version out with the original and I was back up and running again. Not sure what was at issue, no error logs to report.
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Recent update changed breadcrumbs

Post by kermit »

tntstudio wrote: Cenzo: Thank you for posting the code. I tried your fix however I too ran into a problem - root & root_url worked again for the top level & one level below, but as soon as I hit 2 levels below root, my pages stopped displaying altogether.

I swapped your version out with the original and I was back up and running again. Not sure what was at issue, no error logs to report.
maybe that's why it works here... i only have a 'main level' and one underneath that.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
ostricized

Re: Recent update changed breadcrumbs

Post by ostricized »

Have the breadcrumbs been intentionally broken here or?
liquid
Forum Members
Forum Members
Posts: 59
Joined: Sun Aug 07, 2005 10:20 pm

Re: Recent update changed breadcrumbs

Post by liquid »

Do we have a verdict on this? I have a site that's several levels deep and I'm still looking for a fix.
cyberman

Re: Recent update changed breadcrumbs

Post by cyberman »

liquid wrote: I have a site that's several levels deep and I'm still looking for a fix.
There's IMHO a bugfix inside 1.05 ...
alby

Re: Recent update changed breadcrumbs

Post by alby »

Serialthunder wrote:
cyberman wrote:
liquid wrote: I have a site that's several levels deep and I'm still looking for a fix.
There's IMHO a bugfix inside 1.05 ...
Hey @ all!

I just had to update my CMSMS-Install from 0.13 to 1.06 and had the same problem as described above.

I have the following page-structure:

1. Home
1.1 News
1.1.1 Archiv
1.2 Agentur
1.3 ...
2. Projekte
2.1 Skripte
2.2 Lizenz...

The following Breadcrumbs appear on the several pages:

1. -> Home (no link)
1.1 -> Home >> Home >> News (2x home linked)
1.2 -> Home >> Home >> Agentur (2x homelinked)
2. -> Home >> Projekte (Home linked - correct)
2.1 -> Home >> Projekte >> Skripte (Home, Projekte linked - correct)



Before Update the Breadcrumbs appear like this:
1. -> Home (no link)
1.1 -> Home >> News (home linked)
1.2 -> Home >> Agentur (home llinked)
2. -> Home >> Projekte (Home linked - correct)
2.1 -> Home >> Projekte >> Skripte (Home & Projekte linked - correct)

Code: Select all

{breadcrumbs starttext='Sie sind hier' root='home' delimiter='»'}
Does anybody has an idea or bugfix?  ???
try to substitute (in function.breadcrumbs.php) the row:

Code: Select all

if (strtolower($content->Alias())==strtolower($root))
with:

Code: Select all

if (strtolower($content->Alias())!=strtolower($root))    <----  == with !=
Alby
Locked

Return to “CMSMS Core”