Ticket #2251 (closed idea: wontfix)
Breadcrumb amélioration avec balises de données structurées
Reported by: | iloveticket | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | module:core | Version: | 2.11.2 |
Severity: | normal | Keywords: | |
Cc: |
Description
plop Franck
suite a ce fil sur le forum contenant un peu plus de détails...
je te propose ceci
<?php # -- BEGIN LICENSE BLOCK ---------------------------------- # This file is part of breadcrumb, a plugin for Dotclear 2. # # Copyright (c) Franck Paul and contributors # carnet.franck.paul@gmail.com # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { return; } # Breadcrumb template functions $core->tpl->addValue('Breadcrumb',array('tplBreadcrumb','breadcrumb')); class tplBreadcrumb { # Template function public static function breadcrumb($attr) { $separator = isset($attr['separator']) ? $attr['separator'] : ''; return '<?php echo tplBreadcrumb::displayBreadcrumb('. "'".addslashes($separator)."'". '); ?>'; } public static function displayBreadcrumb($separator) { global $core,$_ctx; $ret = ''; # Check if breadcrumb enabled for the current blog $core->blog->settings->addNameSpace('breadcrumb'); if (!$core->blog->settings->breadcrumb->breadcrumb_enabled) { return $ret; } if ($separator == '') $separator = ' › '; // Get current page if set $page = isset($GLOBALS['_page_number']) ? (integer) $GLOBALS['_page_number'] : 0; switch ($core->url->type) { case 'default': // Home (first page only) $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">'.__('Home').'</span></div>'; break; case 'default-page': // Home`(page 2 to n) $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $ret .= $separator.sprintf(__('page %d'),$page); break; case 'category': // Category $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $categories = $core->blog->getCategoryParents($_ctx->categories->cat_id); while ($categories->fetch()) { $ret .= $separator.'<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.$core->url->getBase('category')."/".$categories->cat_url.'" itemprop="url"><div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemscope itemtype="http://data-vocabulary.org/Breadcrumb" itemprop="title">'.$categories->cat_title.'</span></div></a></div>'; } if ($page == 0) { $ret .= $separator.$_ctx->categories->cat_title; } else { $ret .= $separator.'<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.$core->url->getBase('category')."/".$_ctx->categories->cat_url.'" itemprop="url"><div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemscope itemtype="http://data-vocabulary.org/Breadcrumb" itemprop="title">'.$categories->cat_title.'</span></div></a></div>'; $ret .= $separator.sprintf(__('page %d'),$page); } break; case 'post': // Post $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; if ($_ctx->posts->cat_id) { // Parents cats of post's cat $categories = $core->blog->getCategoryParents($_ctx->posts->cat_id); while ($categories->fetch()) { $ret .= $separator.'<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.$core->url->getBase('category')."/".$categories->cat_url.'" itemprop="url"><span itemprop="title">'.$categories->cat_title.'</span></a></div>'; } // Post's cat $categories = $core->blog->getCategory($_ctx->posts->cat_id); $ret .= $separator.'<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.$core->url->getBase('category')."/".$categories->cat_url.'" itemprop="url"><span itemprop="title">'.$categories->cat_title.'</span></a></div>'; } $ret .= $separator.$_ctx->posts->post_title; break; case 'lang': // Lang $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $langs = l10n::getISOCodes(); $ret .= $separator.(isset($langs[$_ctx->cur_lang]) ? $langs[$_ctx->cur_lang] : $_ctx->cur_lang); break; case 'archive': // Archives $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; if (!$_ctx->archives) { // Global archives $ret .= $separator.__('Archives'); } else { // Month archive $ret .= $separator.'<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $ret .= $separator.dt::dt2str('%B %Y',$_ctx->archives->dt); } break; case 'pages': // Page $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>'; $ret .= $separator.$_ctx->posts->post_title; break; case 'tags': // All tags $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $ret .= $separator.__('All tags'); break; case 'tag': // Tag $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getBase("tags").'">'.__('All tags').'</a>'; if ($page == 0) { $ret .= $separator.$_ctx->meta->meta_id; } else { $ret .= $separator.'<a href="'.$core->blog->url.$core->url->getBase("tag").'/'.rawurlencode($_ctx->meta->meta_id).'">'.$_ctx->meta->meta_id.'</a>'; $ret .= $separator.sprintf(__('page %d'),$page); } break; case 'search': // Search $ret = '<div id="bc-home" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.$core->blog->url.'" itemprop="url"><span itemprop="title">'.__('Home').'</span></a></div>'; if ($page == 0) { $ret .= $separator.__('Search:').' '.$GLOBALS['_search']; } else { $ret .= $separator.'<a href="'.$core->blog->url.'?q='.rawurlencode($GLOBALS['_search']).'">'.__('Search:').' '.$GLOBALS['_search'].'</a>'; $ret .= $separator.sprintf(__('page %d'),$page); } break; case '404': // 404 $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>'; $ret .= $separator.__('404'); break; default: $ret = '<a id="bc-home" href="'.$core->blog->url.'">'.__('Home').'</a>'; # --BEHAVIOR-- publicBreadcrumb # Should specific breadcrumb if any, will be added after home page url $special = $core->callBehavior('publicBreadcrumb',$core->url->type,$separator); if ($special) { $ret .= $separator.$special; } break; } # Encapsulate breadcrumb in <p>…</p> if (!$core->blog->settings->breadcrumb->breadcrumb_alone) { $ret = '<p id="breadcrumb">'.$ret.'</p>'; } return $ret; } }
cela reste à paufiner notament pour les tag et tags ou je n'ai aps reussi à ajouter la balise <span itemprop="title"> ... </span> (bien que sur Pages, 404 ce ne soit pas nécessaire).
mais c'est valide et fonctionnel testé sur google testing tool
et pour la mise en forme .css un display:ruby suffit pour tout mettre en ligne horizontale.
plus de détails fil sur le forum
Change History
comment:2 Changed 7 years ago by franck
- Status changed from new to closed
- Type changed from defect to idea
- Resolution set to wontfix
C'est très marginal, à mon avis et de plus ajouter tout ce code juste pour du SEO, comment dire…
J'empêche personne de forker le plugin et d'en faire un spécial SEO, hein ? Au travail !
Note: See
TracTickets for help on using
tickets.