How to pass checkbox value to echo $pod->filters()
-
Hello! I’ve been looking for a solution for the past few days but I just couldn’t figure it out. Under
echo $pod->filters();
, I echoed some checkboxes from another pod page which will let visitors search my pods through any custom fields they want:<form action="" method="get"> <input type="checkbox" name="bookauthor" checked="checked"> <label for="bookauthor">Author</label> <input type="checkbox" name="bookyear"> <label for="bookyear">Year</label></form>
Then I set my
'where'
variables in php.$bookauthorfield = array( 'key' => 'book_author', 'value' => pods_var( 'search' ), 'compare' => 'LIKE' ); $bookyearfield = array( 'key' => 'book_year', 'value' => pods_var( 'search' ), 'compare' => 'LIKE' );
After this, I used
if
,else
, andisset
in an attempt to get the checkbox value and pass it to my$params
. If the checkbox is checked, it will search for the field. If not, then it will do nothing.if (isset($_GET['bookauthor'])) { $searchbookauthor = $bookauthorfield; } else { $searchbookauthor = NULL; }; if (isset($_GET['bookyear'])) { $searchbookyear = $bookyearfield; } else { $searchbookyear = NULL; };
Then I changed my
$params
into$params = array( 'orderby' => 'book_year DESC', 'limit' => 5, 'search' => false, 'where' => array( 'relation' => 'OR', $searchbookauthor, $searchbookyear ) );
But sadly, that didn’t work nor the dozen attempts I made during the past few days. =(
How do I connect these checkboxes toecho $pod->filters()
?
- The topic ‘How to pass checkbox value to echo $pod->filters()’ is closed to new replies.