Hi!
I have a template showing all entries from a channel and I wish to add a filtering form by category something like this.
<form method="post" action="">
<input type="checkbox" name="category" value="3"> Category 1
<input type="checkbox" name="category" value="4"> Category 2
<input type="checkbox" name="category" value="5"> Category 3
<input type="submit" name="submit" value="submit">
</form>Is this possible to implement this idea. Once a user will click submit then the choosen categories will only show in the Template?
I tried this but no luck..
This is on top of the template
$cat1 = $this->EE->input->post('cat1');
$cat2 = $this->EE->input->post('cat2');
$cat3 = $this->EE->input->post('cat3');
$categories = "";
if ( $cat1 == "1" ) {
$categories = $categories . "1";
}
if ( $cat2 == "2" ) {
$categories == "" ? $categories = $categories . "2" : $categories = $categories . "|2";
}
if ( $cat3 == "3" ) {
$categories == "" ? $categories = $categories . "3" : $categories = $categories . "|3";
}In the end of the PHP code $categories will be “1|3” if the 1st and 2nd checkboxes are checked.
I am trying to to this in the channe tag, somthing like this but this won’t work..
{exp:channel:entries channel="{preload_channel}" category="<?php echo $categories?>"}I tried this as well
{preload_replace:pre_categories="<?php echo $categories?>"}
{exp:channel:entries channel="{preload_channel}" category="{pre_categories}"}My preload_channel is working but my preload_categories wont but I can view it by just simply calling the tag {pre_categories}
Can anyone help me?
Thanks…
[Mod Edit: Moved to the Community Help forum]