public static function getTagFeed($slug = null) { $tag = Tag::where('slug', '=', $slug)->first(); if ($tag) { return Post::isPublished()->where('categories_id', '=', $category->id)->orderBy('published_at', 'desc'); } }
protected function getOrCreateTag($tagname) { $tag = TagModel::where('name', 'like', $tagname)->first(); if ($tag == null) { $slug = strtolower(str_replace(' ', '-', $tagname)); $tag = TagModel::create(array('name' => $tagname, 'slug' => $slug)); } return $tag; }
protected function loadTags() { $tags = BlogTag::orderBy('name'); if ($this->property('parent') == '') { $tags->whereExists(function ($query) { $query->select(DB::raw(1))->from('radiantweb_blog_post_tags')->join('radiantweb_blog_posts', 'radiantweb_blog_posts.id', '=', 'radiantweb_blog_post_tags.post_id')->where('radiantweb_blog_posts.published', 1)->whereRaw('radiantweb_blog_tags.id = radiantweb_blog_post_tags.tag_id'); }); } else { $tags->whereExists(function ($query) { $parent = $this->property('parent'); $query->select(DB::raw(1))->from('radiantweb_blog_post_tags')->join('radiantweb_blog_posts', 'radiantweb_blog_posts.id', '=', 'radiantweb_blog_post_tags.post_id')->where('radiantweb_blog_posts.published', 1)->where('radiantweb_blog_posts.parent', $parent)->whereRaw('radiantweb_blog_tags.id = radiantweb_blog_post_tags.tag_id'); }); } return $tags->get(); }
public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { $plural = null; if (count($checkedIds) > 1) { $plural = 's'; } foreach ($checkedIds as $tagId) { if (!($tag = Tag::find($tagId))) { continue; } $tag->delete(); } Flash::success('Tag' . $plural . ' Successfully Deleted.'); } return $this->listRefresh(); }
public function boot() { Event::listen('pages.menuitem.listTypes', function () { return ['problog-category' => 'ProBlog Category', 'all-problog-categories' => 'All ProBlog Categories', 'problog-tag' => 'ProBlog Tag', 'all-problog-tags' => 'All ProBlog Tags']; }); Event::listen('pages.menuitem.getTypeInfo', function ($type) { if ($type == 'problog-category' || $type == 'all-problog-categories') { return Category::getMenuTypeInfo($type); } if ($type == 'problog-tag' || $type == 'all-problog-tags') { return Tag::getMenuTypeInfo($type); } }); Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) { if ($type == 'problog-category' || $type == 'all-problog-categories') { return Category::resolveMenuItem($item, $url, $theme); } if ($type == 'problog-tag' || $type == 'all-problog-tags') { return Tag::resolveMenuItem($item, $url, $theme); } }); }
protected function loadPosts() { //\Log::info($this->parentPage); if ($this->parentPage != '') { $parent = $this->parentPage; $BlogPosts = BlogPost::where('parent', $parent); } else { $BlogPosts = new BlogPost(); } $BlogPosts = $BlogPosts->isPublished(); /* * Preset Fitlers * First we cycle through all possible preset filtering * @type - category,tag,author,date-time */ if ($this->property('filter_type') == 'category') { $category_name = $this->property('filter_value'); $category = CategoryModel::whereRaw("LOWER(name) = '{$category_name}'")->first(); if ($category) { $catID = $category->id; } else { $catID = '#'; } $BlogPosts->filterByCategory($catID); } if ($this->property('filter_type') == 'tag') { $tag = TagModel::where('name', '=', $this->property('filter_value'))->first(); return $tag->posts()->paginate($this->property('postsPerPage')); } if ($this->property('filter_type') == 'author') { $author = BackendUserModel::findUserByLogin($this->property('filter_value')); if ($author) { $author_id = $author->id; } else { $author_id = '#'; } $BlogPosts->filterByAuthor($author_id); } /* * Filter Request * Next we cycle through all possible request filters * @type - category,tag,author,canonical * (canonical requires additional different page vars /:year?/:month?/) */ if ($this->param('filter')) { if ($this->param('filter') !== 'category' && !$this->param('slug')) { $slug = $this->param('filter'); $type = 'category'; } else { $type = $this->param('filter'); $slug = $this->param('slug'); } $slug = $slug; $slug = strtolower($slug); $slug = str_replace('-', ' ', $slug); $slug = str_replace('%20', ' ', $slug); if ($type == 'category') { $this->page['blogCurrentCategorySlug'] = $slug; $category = CategoryModel::whereRaw("LOWER(name) = '{$slug}'")->first(); if ($category) { $catID = $category->id; } else { $catID = '#'; } $BlogPosts->filterByCategory($catID); } elseif ($type == 'tag') { $this->page['blogCurrentTagSlug'] = $slug; $tag = TagModel::where('name', '=', $slug)->first(); if ($tag) { return $tag->posts()->paginate($this->property('postsPerPage')); } return false; } elseif ($type == 'author') { $author = BackendUserModel::findUserByLogin($slug); if ($author) { $author_id = $author->id; } else { $author_id = '#'; } $BlogPosts->filterByAuthor($author_id); } elseif ($type == 'search') { $this->page['search_slug'] = $slug; $BlogPosts->filterBySearch($slug); } elseif ($type == 'cannonical') { $y = $this->param('year'); $m = $this->param('month'); $BlogPosts->filterByDate($y, $m); } else { $component = $this->addComponent('Radiantweb\\Problog\\Components\\Post', 'proBlogPost', array('slug' => $slug)); $component->onRun(); $this->render_post = $this->page['render_post'] = $slug; return $this->render_post; } } /* * no filters, we go get all */ $posts = $BlogPosts->orderBy('published_at', 'desc')->paginate($this->property('postsPerPage'), $this->currentPage); //$queries = DB::getQueryLog(); //$last_query = end($queries); //\Log::info($last_query); return $posts; }
private static function getBlogTagRenderUrls($theme, $item, $alltags = false) { $page = CmsPage::loadCached($theme, $item->cmsPage); $result = []; $tags = Tag::lists('slug', 'name'); $pages = []; if ($item->nesting > 0) { foreach ($tags as $slug => $name) { if ($alltags) { $url = CmsPage::url($page->getBaseFileName(), ['filter' => 'tag', 'slug' => $slug], false); $url = URL::to(Str::lower($url)) . '/'; $pages[] = array('title' => $name, 'url' => $url); } else { $category = Tag::whereRaw("LOWER(slug) = '{$slug}'")->first(); $tagPages = Post::filterByCategory($category->id)->get(); $pageUrl = CmsPage::url($page->getBaseFileName(), ['slug' => $slug], false); $pageUrl = str_replace('/default', '', Str::lower($pageUrl) . '/'); foreach ($tagPages as $cpage) { $pages[] = array('title' => $cpage->title, 'url' => Str::lower($pageUrl) . $cpage->slug . '/'); } } } } return $pages; }