Of course I have the code : <?php else: // show latest articles ?> later
This works for one type of parameter. I want to extend this to work with multiple filters. How can I achieve the same result if I click on the “color” tag, the “client” tag, or “service” tag - individually?
Hm, I’m not quite sure where the problem is and how I could best help to solve it. You code above does not really make sense.
What I posted above is the code for a controller which return the $projects variable, that you can then use to iterate through the projects in your template.
@texnixe that’s right, I understand the controller. How you layer in tags under one request is what I’m trying to learn and extend. For example, with Baseblog (re: http://baseblog.sashtown.de/demo/) clicking on a tag ($tag) will bring you to a page showing the title of the active $tag. I want to do something similar using multiple custom tag fields. So, whether I click on client, service, projects, color …etc, I will see the title on the page change to Client, Service, Projects, etc. depending on which tag was selected.
The following code is from Baseblog’s ‘blog’ template:
I tried something different and included the following code in the controller for each if statement: echo '<h1 class="result"> Articles tagged with “<mark>' , $tag , '</mark>”</h1>';
replacing $tag with color, service, etc.
This will display the title of the active tag but in markup it sits above my ‘head’ elements in the body. Yucky.
If you want get something only with tags “tag1” and “tag2”, like a yoururl.com/page/tag:tag1,tag2 you’re can use this code, (change $products whatever you want) :
if(param('tag')){
$tags = explode(",", param('tag'));
$products = $products->filter(function($product) use ($tags) {
$inTags = true;
foreach ($tags as $tag) {
$pTags = explode(",", $product->tags()); //get tags field from page
if(!in_array($tag,$pTags)){
$inTags = false;
}
}
return $inTags;
});
}