本文整理汇总了PHP中Grav\Common\Page\Page::taxonomy方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::taxonomy方法的具体用法?PHP Page::taxonomy怎么用?PHP Page::taxonomy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Page\Page
的用法示例。
在下文中一共展示了Page::taxonomy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTaxonomy
/**
* Takes an individual page and processes the taxonomies configured in its header. It
* then adds those taxonomies to the map
*
* @param Page $page the page to process
* @param array $page_taxonomy
*/
public function addTaxonomy(Page $page, $page_taxonomy = null)
{
if (!$page_taxonomy) {
$page_taxonomy = $page->taxonomy();
}
/** @var Config $config */
$config = $this->grav['config'];
if ($config->get('site.taxonomies') && count($page_taxonomy) > 0) {
foreach ((array) $config->get('site.taxonomies') as $taxonomy) {
if (isset($page_taxonomy[$taxonomy])) {
foreach ((array) $page_taxonomy[$taxonomy] as $item) {
// TODO: move to pages class?
$this->taxonomy_map[$taxonomy][(string) $item][$page->path()] = array('slug' => $page->slug());
}
}
}
}
}
示例2: addTaxonomy
/**
* Takes an individual page and processes the taxonomies configured in its header. It
* then adds those taxonomies to the map
*
* @param Page $page the page to process
* @param array $page_taxonomy
*/
public function addTaxonomy(Page $page, $page_taxonomy = null)
{
if (!$page_taxonomy) {
$page_taxonomy = $page->taxonomy();
}
if (!$page->published() || empty($page_taxonomy)) {
return;
}
/** @var Config $config */
$config = $this->grav['config'];
if ($config->get('site.taxonomies')) {
foreach ((array) $config->get('site.taxonomies') as $taxonomy) {
if (isset($page_taxonomy[$taxonomy])) {
foreach ((array) $page_taxonomy[$taxonomy] as $item) {
$this->taxonomy_map[$taxonomy][(string) $item][$page->path()] = ['slug' => $page->slug()];
}
}
}
}
}