Help req please with filter issue
2 posts by 2 authors in: Forums > CMS Builder
Last Post: August 2, 2018 (RSS)
By willydoit - August 2, 2018
Hi all,
I have a page that loads from a menu and uses two tables, table 1 is "information_section_headers" and provides a heading that goes at the top of a listing page and table 2 "information_pages" which creates a list filtered according to the menu link.
So a link to the page with ?category=beach pulls the correct header information from table 1 and the correct lists from table 2
All that at the moment seems to work fine.
My problem is if the page is called without a filter ie no ?category=
when that occurs it shows all the listings which is fine, however it also shows all the headers which I do not want.
Is there a way to code it so that if there is no filter value at the end of the link table 1 defaults to a specified category header while table 2 continues to list all listings.
something such as if no filter present then the value for the information table category = "full list header" so that it displays the record called full list header.
I have copied my current header code below so you can see what I have so far:
Thanks in advance for any help provided.
// load records from 'information_section_headers'
list($information_section_headersRecords, $information_section_headersMetaData) = getRecords(array(
'tableName' => 'information_section_headers',
'loadUploads' => false,
'allowSearch' => true,
));
// load records from 'information_pages'
list($information_pagesRecords, $information_pagesMetaData) = getRecords(array(
'tableName' => 'information_pages',
'orderBy' => 'RAND()',
'loadUploads' => true,
'allowSearch' => true,
));
?>
By daniel - August 2, 2018
Hello,
One way to accomplish this would be to modify the section where you output the header to something like this:
if( empty( $_REQUEST['category'] )) {
echo 'All Listings';
} else {
** your existing header output code **
}
Let me know how this works for you, and if you have any further questions.
Thanks,
Technical Lead
interactivetools.com