Thank you so much! I've got it to work now, I'll show you what I did. I still need to change so that the database doesn't search for partial matches but I'll figure something out for that. But here is what it is doing:
This is my controller, ArticleHolder.php
class ArticleHolder extends Page {
private static $allowed_children = array('ArticlePage');
private static $db = array(
'Filters' => 'Text'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new TextField('Filters'), 'Content');
return $fields;
}
}
class ArticleHolder_Controller extends Page_Controller {
public function ValidateType(){
if($this->request->getVar('tag')){
$filter = $this::get()->filter('Filters:PartialMatch', $this->request->getVar('tag'))->First();
if ($filter == NULL){
return NULL;
}
else{
return $this->PaginatedPages();
}
}
else{
return $this->PaginatedPages();
}
}
public function PaginatedPages(){
if($this->request->getVar('tag')){
$tag = $this->request->getVar('tag');
}
else{
$tag = 'News';
}
$paginatedItems = new PaginatedList($this->filterArticles($tag), $this->request);
$paginatedItems->setPageLength(3);
return $paginatedItems;
}
public function filterArticles($tag){
return ArticlePage::get()->filter('category:PartialMatch', $tag)->sort('Date DESC');
}
}
This is my View ArticleHolder.ss
<% require themedCSS('ArticleHolder') %>
<% require themedCSS('SideBar') %>
<div>
<div>
<ul>
<li id="testFilter"><a href="news/?tag=Other"><img src="assets/other/bagzli_logo.png" alt="image"/></a></li>
</ul>
</div>
<div id="news">
<% if ValidateType() %>
<ul>
<% loop $PaginatedPages %>
<li>
<div class="article">
<h2><a href="$Link" title="Read more on "{$Title}"">$Title</a></h2>
<h3>$Date</h3>
<img class="indent" src="$Photo.link" alt="image"/>
<p class="indent">$Teaser</p>
</div>
</li>
<% end_loop %>
</ul>
<% include Pagination %>
<% else %>
<p>SORRY NO RESULTS WERE FOUND</p>
<% end_if %>
</div>
<div id="sidebar">
</div>
<div class="clear"></div>
</div>
In the controller I'm checking if the passed variable belongs to the approved variable list. I'm hoping to stop any kind of SQL Injection with this.
So i'm just clicking on an image and then i refresh the page with the new variable and new results appear. Now I don't understand what you were talking about if it is destructible, I have not heard of that before. Could you please elaborate a bit more on that?