本文整理汇总了PHP中Get::tag方法的典型用法代码示例。如果您正苦于以下问题:PHP Get::tag方法的具体用法?PHP Get::tag怎么用?PHP Get::tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Get
的用法示例。
在下文中一共展示了Get::tag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
* RETURN SPECIFIC PAGE/ARTICLE TAG ITEM FILTERED BY ITS AVAILABLE DATA
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* $tag = Get::pageTag('lorem-ipsum');
* $tag = Get::articleTag('lorem-ipsum');
*
* --------------------------------------------------------------------------
*
*/
Get::plug('pageTag', function ($filter, $output = null, $fallback = false) {
return Get::tag($filter, $output = null, $fallback = false, 'page');
});
Get::plug('articleTag', function ($filter, $output = null, $fallback = false) {
return Get::tag($filter, $output = null, $fallback = false, 'article');
});
/**
* ==========================================================================
* GET PAGE/ARTICLE PATH
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* var_dump(Get::pagePath('lorem-ipsum'));
* var_dump(Get::articlePath('lorem-ipsum'));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
示例2: sprintf
Shield::abort('404-archive');
}
$time = $config->widget_year_first ? $year . ', ' . $months[(int) $month - 1] : $months[(int) $month - 1] . ' ' . $year;
Config::set(array('page_title' => (strpos($config->archive->title, '%s') !== false ? sprintf($config->archive->title, $time) : $config->archive->title . ' ' . $time) . $config->title_separator . $config->title, 'offset' => $offset, 'archive_query' => $slug, 'articles' => $articles, 'pagination' => Navigator::extract(Get::articles('DESC', 'time:' . $slug), $offset, $config->archive->per_page, $config->archive->slug . '/' . $slug)));
Shield::attach('index-archive');
}, 41);
/**
* Tag Page
* --------
*
* [1]. tagged/tag-slug
* [2]. tagged/tag-slug/1
*
*/
Route::accept(array($config->tag->slug . '/(:any)', $config->tag->slug . '/(:any)/(:num)'), function ($slug = "", $offset = 1) use($config) {
if (!($tag = Get::tag($slug))) {
Shield::abort('404-tag');
}
$articles = array();
$offset = (int) $offset;
if ($files = Mecha::eat(Get::articles('DESC', 'kind:' . $tag->id))->chunk($offset, $config->tag->per_page)->vomit()) {
foreach ($files as $file) {
$articles[] = Get::article($file, array('content', 'tags', 'css', 'js', 'comments'));
}
unset($files);
} else {
Shield::abort('404-tag');
}
Config::set(array('page_title' => (strpos($config->tag->title, '%s') !== false ? sprintf($config->tag->title, $tag->name) : $config->tag->title . ' ' . $tag->name) . $config->title_separator . $config->title, 'offset' => $offset, 'tag_query' => $slug, 'articles' => $articles, 'pagination' => Navigator::extract(Get::articles('DESC', 'kind:' . $tag->id), $offset, $config->tag->per_page, $config->tag->slug . '/' . $slug)));
Shield::attach('index-tag');
}, 50);