Пример #1
0
function article_category_id()
{
    if ($category = Registry::prop('article', 'category')) {
        $categories = Registry::get('all_categories');
        return $categories[$category]->id;
    }
}
Пример #2
0
function page_custom_field($key, $default = '')
{
    $id = Registry::prop('page', 'id');
    if ($extend = Extend::field('page', $key, $id)) {
        return Extend::value($extend, $default);
    }
    return $default;
}
Пример #3
0
function my_get_description($len = 500)
{
    if (!Registry::get('article')) {
        $description = site_description();
    } else {
        $description = trim(Registry::prop('article', 'description'));
        if (empty($description)) {
            $description = parse(Registry::prop('article', 'html'));
        }
        $description = trim(preg_replace('#<[^>]+>#', ' ', $description));
    }
    if (strlen($description) > $len) {
        $description = substr($description, 0, $len - 3) . '...';
    }
    return preg_replace('/[\\n\\r\\t]+/', ' ', preg_replace('/\\s+/', ' ', $description));
}
 public function active()
 {
     if (Registry::prop('page', 'slug') == $this->slug || Registry::prop('page', 'parent') == $this->id) {
         return true;
     }
 }
Пример #5
0
/**
* Get the url to an adjacent article
* @param string		prev || previous || next
* @return string
*/
function article_adjacent_url($side = 'next')
{
    $comparison = '>';
    $order = 'asc';
    if (strtolower($side) == 'prev' || strtolower($side) == 'previous') {
        $comparison = '<';
        $order = 'desc';
    }
    $page = Registry::get('posts_page');
    $query = Post::where('created', $comparison, Registry::prop('article', 'created'))->where('status', '!=', 'draft');
    if ($query->count()) {
        $article = $query->sort('created', $order)->fetch();
        $page = Registry::get('posts_page');
        return base_url($page->slug . '/' . $article->slug);
    }
}
Пример #6
0
function comments_open()
{
    return Registry::prop('article', 'comments') ? true : false;
}
Пример #7
0
function is_postspage()
{
    return Registry::prop('page', 'id') == Config::meta('posts_page');
}
Пример #8
0
function menu_parent()
{
    return Registry::prop('menu_item', 'parent');
}
Пример #9
0
function search_item_slug()
{
    return Registry::prop('search_item', 'slug');
}
Пример #10
0
function article_author_bio()
{
    return Registry::prop('article', 'author_bio');
}
function category_description()
{
    return Registry::prop('category', 'description');
}
Пример #12
0
function menu_parent($menu_item = null)
{
    if (is_array($menu_item)) {
        return $menu_item['parent'];
    }
    return $menu_item ? $menu_item->parent : Registry::prop('menu_item', 'parent');
}