diff --git a/code/BlogEntry.php b/code/BlogEntry.php index a7596c0..25065f2 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -79,7 +79,7 @@ class BlogEntry extends Page { foreach($theseTags as $tag) { $output->push(new ArrayData(array( "Tag" => $tag, - "Link" => $this->getParent()->Link() . '?tag=' . urlencode($tag) + "Link" => $this->getParent()->Link() . 'tag/' . urlencode($tag) ))); } if($this->Tags){ @@ -153,4 +153,4 @@ class BlogEntry_Controller extends Page_Controller { } -?> \ No newline at end of file +?> diff --git a/code/BlogHolder.php b/code/BlogHolder.php index 43ca703..3f58b17 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -47,15 +47,20 @@ class BlogHolder extends Page { if(Director::urlParams()){ - - $year = Director::urlParam('Action'); - $month = Director::urlParam('ID'); + if(Director::urlParam('Action') == 'tag') { + $tag = addslashes(Director::urlParam('ID')); + $tag = str_replace(array("\\",'_','%',"'"), array("\\\\","\\_","\\%","\\'"), $tag); + $tagCheck = "AND `BlogEntry`.Tags LIKE '%$tag%'"; + } else { + $year = Director::urlParam('Action'); + $month = Director::urlParam('ID'); - if(is_numeric($month) && is_numeric($month)){ - $dateCheck = "AND Date BETWEEN '$year-$month-1' AND '$year-$month-31'"; - } - else if(isset($year)){ - $dateCheck = "AND Date BETWEEN '$year-1-1' AND '$year-12-31'"; + if(is_numeric($month) && is_numeric($month)){ + $dateCheck = "AND Date BETWEEN '$year-$month-1' AND '$year-$month-31'"; + } + else if(isset($year)){ + $dateCheck = "AND Date BETWEEN '$year-1-1' AND '$year-12-31'"; + } } }