Author: carlb613
Description:
Moving this issue from [[voy:Wikivoyage talk:Breadcrumb navigation#Remove parenthesis at display]]...
In [[voy:Hamilton (Ohio)]], the GeoCrumb trail looks like:
North America > United States of America > Midwest (United States of America) > Ohio > Southwest Ohio > Butler County (Ohio) > Hamilton (Ohio)
This is redundantly redundant; the same path could be expressed succinctly as:
North America > United States of America > Midwest > Ohio > Southwest Ohio > Butler County > Hamilton
We already _know_ this is in Ohio because " > Ohio > " is in the trail, so any " (Ohio)" disambiguators in the town and county names can be hidden from the user without losing anything useful.
The breadcrumb trail is generated in GeoCrumbs.class.php in function makeTrail().
Adding code to this function to keep a $nameStack of place names already in the path and then hiding these where they appear in (brackets) elsewhere in the same trail would give:
public function makeTrail( Title $title ) { $breadcrumbs = array(); // avoid cyclic trails & define emergency break $nameStack = array(); $idStack = array(); $cnt = 20; while ( $title && $cnt-- ) { $link = Linker::link( $title, $title->getSubpageText() ); // mark redirects with italics. if ( $title->isRedirect() ) { $link = Html::rawElement( 'i', array(), $link ); } array_unshift( $breadcrumbs, $link ); if ( in_array( $title->getArticleID(), $idStack ) ) { $breadcrumbs[0] = Html::rawElement( 'strike', array(), $breadcrumbs[0] ); break; } $nameStack[] = $title->getText(); $idStack[] = $title->getArticleID(); $title = $this->getParentRegion( $title ); } // hide (disambiguator) in displayed titles if already in path foreach ($nameStack as $bname) { foreach ($breadcrumbs as &$crumb) $crumb = str_replace(" (" . $bname . ")</a>","</a>",$crumb); } return $breadcrumbs; }
Version: master
Severity: normal
URL: http://en.wikivoyage.org/wiki/Wikivoyage_talk:Breadcrumb_navigation#Remove_parenthesis_at_display