-
- 137 Posts
I am using blogit for one of my project, and i had a problem creating breadcrumbs based based on tagger. I created some custom breadcrumbs based on url, i know it is not perfect but its working great, it can be used for some other project to create breadcrumbs based on url. Here is how it is done
Blogit:
https://modx.com/extras/package/blogit
Fastfield :
https://modx.com/extras/package/fastfield
<?php
$decomposedURL = parse_url($_SERVER["REQUEST_URI"]);
$crumbs = explode("/", $decomposedURL['path']);
$input = array();
foreach ($crumbs as $value) {
if ($value != ''){
array_push($input,$value);
}
}
$output = array();
$previous = '';
foreach ($input as $entry) {
$output[] = $previous . $entry . '/';
$previous = end($output);
}
$breadcrumbs = array_combine($input, $output);
$n = 0;
$len = count($breadcrumbs);
echo '<div class="section-breadcrumb">
<div class="breadcrumb">
<a href="'.$start.'">'.$home.'</a>';
foreach ($breadcrumbs as $k => $v) {
if ($n == $len - 1) {
echo '<span>'.$k.'</span>';
}
else{
echo '<a href="'.$start.$v.'">'.$k.'</a>';
}
$n++;
}
echo' </div>
</div>';
Call in template like this
[[!CustomBreadcrumbsUrl? &start=`[[~[[++site_start]]]]` &home=`[[#[[++site_start]].pagetitle]]`]]
<a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
-
- 137 Posts
Quote from: miomir.dancevic at Mar 05, 2017, 11:39 AMI am using blogit for one of my project, and i had a problem creating breadcrumbs based based on tagger. I created some custom breadcrumbs based on url, i know it is not perfect but its working great, it can be used for some other project to create breadcrumbs based on url. Here is how it is done
Blogit: https://modx.com/extras/package/blogit
Fastfield : https://modx.com/extras/package/fastfield
<!--?php
$decomposedURL = parse_url($_SERVER["REQUEST_URI"]);
$crumbs = explode("/", $decomposedURL['path']);
$input = array();
foreach ($crumbs as $value) {
if ($value != ''){
array_push($input,$value);
}
}
$output = array();
$previous = '';
foreach ($input as $entry) {
$output[] = $previous . $entry . '/';
$previous = end($output);
}
$breadcrumbs = array_combine($input, $output);
$n = 0;
$len = count($breadcrumbs);
echo '<div class="section-breadcrumb"-->
<div class="breadcrumb">
<a href="'.$start.'">'.$home.'</a>';
foreach ($breadcrumbs as $k => $v) {
if ($n == $len - 1) {
echo '<span>'.$k.'</span>';
}
else{
echo '<a href="'.$start.$v.'">'.$k.'</a>';
}
$n++;
}
echo' </div>
';
Call in template like this
[[!CustomBreadcrumbsUrl? &start=`[[~[[++site_start]]]]` &home=`[[#[[++site_start]].pagetitle]]`]]
Can somebody help me to extend it to template, because now HTML is not in template, txanks
<a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>