function article_category_id() { if ($category = Registry::prop('article', 'category')) { $categories = Registry::get('all_categories'); return $categories[$category]->id; } }
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; }
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; } }
/** * 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); } }
function comments_open() { return Registry::prop('article', 'comments') ? true : false; }
function is_postspage() { return Registry::prop('page', 'id') == Config::meta('posts_page'); }
function menu_parent() { return Registry::prop('menu_item', 'parent'); }
function search_item_slug() { return Registry::prop('search_item', 'slug'); }
function article_author_bio() { return Registry::prop('article', 'author_bio'); }
function category_description() { return Registry::prop('category', 'description'); }
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'); }