id: 5 source: 1 name: pdoCrumbs category: pdoTools properties: "a:31:{s:7:\"showLog\";a:7:{s:4:\"name\";s:7:\"showLog\";s:4:\"desc\";s:21:\"pdotools_prop_showLog\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:8:\"fastMode\";a:7:{s:4:\"name\";s:8:\"fastMode\";s:4:\"desc\";s:22:\"pdotools_prop_fastMode\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:4:\"from\";a:7:{s:4:\"name\";s:4:\"from\";s:4:\"desc\";s:18:\"pdotools_prop_from\";s:4:\"type\";s:11:\"numberfield\";s:7:\"options\";a:0:{}s:5:\"value\";i:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:2:\"to\";a:7:{s:4:\"name\";s:2:\"to\";s:4:\"desc\";s:16:\"pdotools_prop_to\";s:4:\"type\";s:11:\"numberfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:13:\"customParents\";a:7:{s:4:\"name\";s:13:\"customParents\";s:4:\"desc\";s:27:\"pdotools_prop_customParents\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:5:\"limit\";a:7:{s:4:\"name\";s:5:\"limit\";s:4:\"desc\";s:19:\"pdotools_prop_limit\";s:4:\"type\";s:11:\"numberfield\";s:7:\"options\";a:0:{}s:5:\"value\";i:10;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:7:\"exclude\";a:7:{s:4:\"name\";s:7:\"exclude\";s:4:\"desc\";s:21:\"pdotools_prop_exclude\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:15:\"outputSeparator\";a:7:{s:4:\"name\";s:15:\"outputSeparator\";s:4:\"desc\";s:29:\"pdotools_prop_outputSeparator\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:1:\"\n\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:13:\"toPlaceholder\";a:7:{s:4:\"name\";s:13:\"toPlaceholder\";s:4:\"desc\";s:27:\"pdotools_prop_toPlaceholder\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"includeTVs\";a:7:{s:4:\"name\";s:10:\"includeTVs\";s:4:\"desc\";s:24:\"pdotools_prop_includeTVs\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"prepareTVs\";a:7:{s:4:\"name\";s:10:\"prepareTVs\";s:4:\"desc\";s:24:\"pdotools_prop_prepareTVs\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:1:\"1\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"processTVs\";a:7:{s:4:\"name\";s:10:\"processTVs\";s:4:\"desc\";s:24:\"pdotools_prop_processTVs\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:8:\"tvPrefix\";a:7:{s:4:\"name\";s:8:\"tvPrefix\";s:4:\"desc\";s:22:\"pdotools_prop_tvPrefix\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:3:\"tv.\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:5:\"where\";a:7:{s:4:\"name\";s:5:\"where\";s:4:\"desc\";s:19:\"pdotools_prop_where\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:15:\"showUnpublished\";a:7:{s:4:\"name\";s:15:\"showUnpublished\";s:4:\"desc\";s:29:\"pdotools_prop_showUnpublished\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:11:\"showDeleted\";a:7:{s:4:\"name\";s:11:\"showDeleted\";s:4:\"desc\";s:25:\"pdotools_prop_showDeleted\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"showHidden\";a:7:{s:4:\"name\";s:10:\"showHidden\";s:4:\"desc\";s:24:\"pdotools_prop_showHidden\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:1;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:14:\"hideContainers\";a:7:{s:4:\"name\";s:14:\"hideContainers\";s:4:\"desc\";s:28:\"pdotools_prop_hideContainers\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:3:\"tpl\";a:7:{s:4:\"name\";s:3:\"tpl\";s:4:\"desc\";s:17:\"pdotools_prop_tpl\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:79:\"@INLINE
  • [[+menutitle]]
  • \";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"tplCurrent\";a:7:{s:4:\"name\";s:10:\"tplCurrent\";s:4:\"desc\";s:24:\"pdotools_prop_tplCurrent\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:62:\"@INLINE
  • [[+menutitle]]
  • \";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:6:\"tplMax\";a:7:{s:4:\"name\";s:6:\"tplMax\";s:4:\"desc\";s:20:\"pdotools_prop_tplMax\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:65:\"@INLINE
  •  ... 
  • \";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:7:\"tplHome\";a:7:{s:4:\"name\";s:7:\"tplHome\";s:4:\"desc\";s:21:\"pdotools_prop_tplHome\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"tplWrapper\";a:7:{s:4:\"name\";s:10:\"tplWrapper\";s:4:\"desc\";s:24:\"pdotools_prop_tplWrapper\";s:4:\"type\";s:9:\"textfield\";s:7:\"options\";a:0:{}s:5:\"value\";s:47:\"@INLINE
      [[+output]]
    \";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:11:\"wrapIfEmpty\";a:7:{s:4:\"name\";s:11:\"wrapIfEmpty\";s:4:\"desc\";s:25:\"pdotools_prop_wrapIfEmpty\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:11:\"showCurrent\";a:7:{s:4:\"name\";s:11:\"showCurrent\";s:4:\"desc\";s:25:\"pdotools_prop_showCurrent\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:1;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:8:\"showHome\";a:7:{s:4:\"name\";s:8:\"showHome\";s:4:\"desc\";s:22:\"pdotools_prop_showHome\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"showAtHome\";a:7:{s:4:\"name\";s:10:\"showAtHome\";s:4:\"desc\";s:24:\"pdotools_prop_showAtHome\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:1;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:10:\"hideSingle\";a:7:{s:4:\"name\";s:10:\"hideSingle\";s:4:\"desc\";s:24:\"pdotools_prop_hideSingle\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:0;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:9:\"direction\";a:7:{s:4:\"name\";s:9:\"direction\";s:4:\"desc\";s:23:\"pdotools_prop_direction\";s:4:\"type\";s:4:\"list\";s:7:\"options\";a:2:{i:0;a:2:{s:5:\"value\";s:3:\"ltr\";s:4:\"text\";s:19:\"Left To Right (ltr)\";}i:1;a:2:{s:5:\"value\";s:3:\"rtl\";s:4:\"text\";s:19:\"Right To Left (rtl)\";}}s:5:\"value\";s:3:\"ltr\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:6:\"scheme\";a:7:{s:4:\"name\";s:6:\"scheme\";s:4:\"desc\";s:20:\"pdotools_prop_scheme\";s:4:\"type\";s:4:\"list\";s:7:\"options\";a:6:{i:0;a:2:{s:5:\"value\";s:0:\"\";s:4:\"text\";s:14:\"System default\";}i:1;a:2:{s:5:\"value\";i:-1;s:4:\"text\";s:25:\"-1 (relative to site_url)\";}i:2;a:2:{s:5:\"value\";s:4:\"full\";s:4:\"text\";s:40:\"full (absolute, prepended with site_url)\";}i:3;a:2:{s:5:\"value\";s:3:\"abs\";s:4:\"text\";s:39:\"abs (absolute, prepended with base_url)\";}i:4;a:2:{s:5:\"value\";s:4:\"http\";s:4:\"text\";s:38:\"http (absolute, forced to http scheme)\";}i:5;a:2:{s:5:\"value\";s:5:\"https\";s:4:\"text\";s:40:\"https (absolute, forced to https scheme)\";}}s:5:\"value\";s:0:\"\";s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}s:13:\"useWeblinkUrl\";a:7:{s:4:\"name\";s:13:\"useWeblinkUrl\";s:4:\"desc\";s:27:\"pdotools_prop_useWeblinkUrl\";s:4:\"type\";s:13:\"combo-boolean\";s:7:\"options\";a:0:{}s:5:\"value\";b:1;s:7:\"lexicon\";s:19:\"pdotools:properties\";s:4:\"area\";s:0:\"\";}}" static_file: core/components/pdotools/elements/snippets/snippet.pdocrumbs.php ----- /** @var array $scriptProperties */ /** @var pdoFetch $pdoFetch */ /** @var modX $modx */ $fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true); $path = $modx->getOption('pdofetch_class_path', null, MODX_CORE_PATH . 'components/pdotools/model/', true); if ($pdoClass = $modx->loadClass($fqn, $path, false, true)) { $pdoFetch = new $pdoClass($modx, $scriptProperties); } else { return false; } $pdoFetch->addTime('pdoTools loaded'); if (!isset($from) || $from == '') { $from = 0; } if (empty($to)) { $to = $modx->resource->id; } if (empty($direction)) { $direction = 'ltr'; } if ($outputSeparator == ' → ' && $direction == 'rtl') { $outputSeparator = ' ← '; } if ($limit == '') { $limit = 10; } // For compatibility with BreadCrumb if (!empty($maxCrumbs)) { $limit = $maxCrumbs; } if (!empty($containerTpl)) { $tplWrapper = $containerTpl; } if (!empty($currentCrumbTpl)) { $tplCurrent = $currentCrumbTpl; } if (!empty($linkCrumbTpl)) { $scriptProperties['tpl'] = $linkCrumbTpl; } if (!empty($maxCrumbTpl)) { $tplMax = $maxCrumbTpl; } if (isset($showBreadCrumbsAtHome)) { $showAtHome = $showBreadCrumbsAtHome; } if (isset($showHomeCrumb)) { $showHome = $showHomeCrumb; } if (isset($showCurrentCrumb)) { $showCurrent = $showCurrentCrumb; } // -- $fastMode = !empty($fastMode); $siteStart = $modx->getOption('siteStart', $scriptProperties, $modx->getOption('site_start')); if (empty($showAtHome) && $modx->resource->id == $siteStart) { return ''; } $class = $modx->getOption('class', $scriptProperties, 'modResource'); // Start building "Where" expression $where = array(); if (empty($showUnpublished) && empty($showUnPub)) { $where['published'] = 1; } if (empty($showHidden)) { $where['hidemenu'] = 0; } if (empty($showDeleted)) { $where['deleted'] = 0; } if (!empty($hideContainers) && empty($showContainer)) { $where['isfolder'] = 0; } $resource = ($to == $modx->resource->id) ? $modx->resource : $modx->getObject($class, $to); if (!$resource) { $message = 'Could not build breadcrumbs to resource "' . $to . '"'; return ''; } if (!empty($customParents)) { $customParents = is_array($customParents) ? $customParents : array_map('trim', explode(',', $customParents)); $parents = is_array($customParents) ? array_reverse($customParents) : array(); } if (empty($parents)) { $parents = $modx->getParentIds($resource->id, $limit, array('context' => $resource->get('context_key'))); } if (!empty($showHome)) { $parents[] = $siteStart; } $ids = array($resource->id); foreach ($parents as $parent) { if (!empty($parent)) { $ids[] = $parent; } if (!empty($from) && $parent == $from) { break; } } $where['id:IN'] = $ids; if (!empty($exclude)) { $where['id:NOT IN'] = array_map('trim', explode(',', $exclude)); } // Fields to select $resourceColumns = array_keys($modx->getFieldMeta($class)); $select = array($class => implode(',', $resourceColumns)); // Add custom parameters foreach (array('where', 'select') as $v) { if (!empty($scriptProperties[$v])) { $tmp = $scriptProperties[$v]; if (!is_array($tmp)) { $tmp = json_decode($tmp, true); } if (is_array($tmp)) { $$v = array_merge($$v, $tmp); } } unset($scriptProperties[$v]); } $pdoFetch->addTime('Conditions prepared'); // Default parameters $default = array( 'class' => $class, 'where' => json_encode($where), 'select' => json_encode($select), 'groupby' => $class . '.id', 'sortby' => "find_in_set(`$class`.`id`,'" . implode(',', $ids) . "')", 'sortdir' => '', 'return' => 'data', 'totalVar' => 'pdocrumbs.total', 'disableConditions' => true, ); // Merge all properties and run! $pdoFetch->addTime('Query parameters ready'); $pdoFetch->setConfig(array_merge($default, $scriptProperties), false); $rows = $pdoFetch->run(); $output = []; if (!empty($rows) && is_array($rows)) { if (strtolower($direction) == 'ltr') { $rows = array_reverse($rows); } foreach ($rows as $row) { if (!empty($useWeblinkUrl) && $row['class_key'] == 'modWebLink') { $row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $pdoFetch->makeUrl((int)trim($row['content'], '[]~ '), $row) : $row['content']; } else { $row['link'] = $pdoFetch->makeUrl($row['id'], $row); } $row = array_merge( $scriptProperties, $row, ['idx' => $pdoFetch->idx++] ); if (empty($row['menutitle'])) { $row['menutitle'] = $row['pagetitle']; } if (isset($return) && $return === 'data') { $output[] = $row; continue; } if ($row['id'] == $resource->id && empty($showCurrent)) { continue; } elseif ($row['id'] == $resource->id && !empty($tplCurrent)) { $tpl = $tplCurrent; } elseif ($row['id'] == $siteStart && !empty($tplHome)) { $tpl = $tplHome; } else { $tpl = $pdoFetch->defineChunk($row); } $output[] = empty($tpl) ? '
    ' . $pdoFetch->getChunk('', $row) . '
    ' : $pdoFetch->getChunk($tpl, $row, $fastMode); } } if (isset($return) && $return === 'data') { return $output; } $pdoFetch->addTime('Chunks processed'); if (count($output) == 1 && !empty($hideSingle)) { $pdoFetch->addTime('The only result was hidden, because the parameter "hideSingle" activated'); $output = array(); } $log = ''; if ($modx->user->hasSessionContext('mgr') && !empty($showLog)) { $log .= '
    ' . print_r($pdoFetch->getTime(), 1) . '
    '; } if (!empty($toSeparatePlaceholders)) { $output['log'] = $log; $modx->setPlaceholders($output, $toSeparatePlaceholders); } else { $output = implode($outputSeparator, $output); if ($pdoFetch->idx >= $limit && !empty($tplMax) && !empty($output)) { $output = ($direction == 'ltr') ? $pdoFetch->getChunk($tplMax, array(), $fastMode) . $output : $output . $pdoFetch->getChunk($tplMax, array(), $fastMode); } $output .= $log; if (!empty($tplWrapper) && (!empty($wrapIfEmpty) || !empty($output))) { $output = $pdoFetch->getChunk($tplWrapper, array('output' => $output, 'crumbs' => $output), $fastMode); } if (!empty($toPlaceholder)) { $modx->setPlaceholder($toPlaceholder, $output); } else { return $output; } }