From 7c8bd693f240465163409470a98cf8b6718617c2 Mon Sep 17 00:00:00 2001 From: Gordon Anderson Date: Fri, 15 May 2015 18:59:09 +0700 Subject: [PATCH] FIX: Fix to allow use of foreign text as tags and categories. Fixes #243 --- code/model/Blog.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/code/model/Blog.php b/code/model/Blog.php index d50a08b..d7c59cd 100644 --- a/code/model/Blog.php +++ b/code/model/Blog.php @@ -803,9 +803,14 @@ class Blog_Controller extends Page_Controller { */ $dataRecord = $this->dataRecord; - $tag = $this->request->param('Tag'); + // get the tag value and generate a URL Segment for it + // use the URL segment for searching + $tagvalue = $this->request->param('Tag'); + if($tagvalue) { + $tempTag = new BlogTag(); + $tempTag->Title = $tagvalue; + $tag = $tempTag->generateURLSegment(); - if($tag) { return $dataRecord->Tags() ->filter('URLSegment', $tag) ->first(); @@ -844,9 +849,12 @@ class Blog_Controller extends Page_Controller { */ $dataRecord = $this->dataRecord; - $category = $this->request->param('Category'); + $categoryValue = $this->request->param('Category'); - if($category) { + if($categoryValue) { + $tempCategory = new BlogCategory(); + $tempCategory->Title = $categoryValue; + $category = $tempCategory->generateURLSegment(); return $dataRecord->Categories() ->filter('URLSegment', $category) ->first();