support for rel-tag microformat

This commit is contained in:
Andrew O'Neil 2007-11-23 08:35:49 +00:00
parent 4adb7674b9
commit 9daebb0fb0
2 changed files with 15 additions and 10 deletions

View File

@ -79,7 +79,7 @@ class BlogEntry extends Page {
foreach($theseTags as $tag) { foreach($theseTags as $tag) {
$output->push(new ArrayData(array( $output->push(new ArrayData(array(
"Tag" => $tag, "Tag" => $tag,
"Link" => $this->getParent()->Link() . '?tag=' . urlencode($tag) "Link" => $this->getParent()->Link() . 'tag/' . urlencode($tag)
))); )));
} }
if($this->Tags){ if($this->Tags){

View File

@ -47,7 +47,11 @@ class BlogHolder extends Page {
if(Director::urlParams()){ if(Director::urlParams()){
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'); $year = Director::urlParam('Action');
$month = Director::urlParam('ID'); $month = Director::urlParam('ID');
@ -58,6 +62,7 @@ class BlogHolder extends Page {
$dateCheck = "AND Date BETWEEN '$year-1-1' AND '$year-12-31'"; $dateCheck = "AND Date BETWEEN '$year-1-1' AND '$year-12-31'";
} }
} }
}
return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$start, $limit"); return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$start, $limit");
} }