Which one is DB content search file
Permalink
Could anyone please tell me where I can find the database content search file so that I can modify the DB query to suit my custom search form? Thank you.
I know I can override some blocks and codes, but I'm trying to find out how to override the database search query. At the moment it only searches based on a single argument called 'query' which takes its value from the input field. I need to search the database based on options selected in select drop down boxes. How do I do that? If I can't override the existing search form to search by select values I have no choice but to modify the core search query which I couldn't find either.
I've seen those 3 posts. The first one is just tells you how to search in additional areas. The other two tell you how to make a search form completely from scratch. Before I start inventing the wheel, I'd like to know if I can simply override the existing search form, especially the database query part of it.
I've seen those 3 posts. The first one is just tells you how to search in additional areas. The other two tell you how to make a search form completely from scratch. Before I start inventing the wheel, I'd like to know if I can simply override the existing search form, especially the database query part of it.
Ok, I see what you're asking. Can you say what your specific options (drop-downs, select lists, etc.) are for? Like are they for searching a date or an author name or a store location, etc.? Because if you're searching page content, you can use the filterByKeywords() method on the PageList object (as outlined here:http://www.concrete5.org/documentation/developers/pages/searching-a... ), and so you could just have your block controller retrieve the various options from the querystring ($_GET) and put them together for a content search (or call filterByKeywords() multiple times -- once for each option) to narrow it down.
Not sure though as I haven't done this myself. But if you can provide more details about what specifically you want to search on, that would help a lot.
Thanks.
-Jordan
Not sure though as I haven't done this myself. But if you can provide more details about what specifically you want to search on, that would help a lot.
Thanks.
-Jordan
Thank you for your help. Here's my view.php file below. At the moment I'm trying to build a 'query' value with javascript. It works but it doesn't look nice (the solution I mean). I'd rather have it all implemented in PHP if I could.
If you could tell me how to do this in PHP C5 way, I very very very much appreciate it. Thank you.
<?php $form = Loader::helper('form'); defined('C5_EXECUTE') or die(_("Access Denied.")); ?> <form method="post" action="<?php echo $this->url('search', 'search-results'); ?>" onSubmit="return temp();"> <?php print $form->label('text', 'Search: ') . '<br />'; print $form->text('text', '') . '<br />'; print $form->label('length', 'Trip Length: '); print $form->select('length', array('travel' => 'travel', '3 days' => '3 days', '1 week' => '1 week', '2 weeks' => '2 weeks', '4 weeks' => '4 weeks'), '', array('style' => 'width: 150px')) . '<br />'; print $form->label('continent', 'Continent: '); print $form->select('continent', array('press' => 'press', 'Australia' => 'Australia', 'Europe' => 'Europe', 'Asia' => 'Asia', 'North America' => 'North America', 'South America' => 'South America', 'Antarctica' => 'Antarctica'), '', array('style' => 'width: 150px')) . '<br />'; print $form->label('adventure', 'Adventure Level: '); print $form->select('adventure', array('' => '', 'Low' => 'Low', 'Medium' => 'Medium', 'High' => 'High', 'Extreme' => 'Extreme'), '', array('style' => 'width: 150px')) . '<br />'; print $form->label('interest', 'Interests: ');
Viewing 15 lines of 48 lines. View entire code block.
If you could tell me how to do this in PHP C5 way, I very very very much appreciate it. Thank you.
I'm still not sure exactly what you're trying to search. Where specifically in your database is the trip length, travel, continent, adventure level, interests, etc. stored? Is it in the page content itself, or in page attributes, or in a custom database table you made for this block?
In other words, how does that information get into the system in the first place -- by just typing it into a content area or by setting attributes on the page properties, or from the custom block you're making?
Thanks.
In other words, how does that information get into the system in the first place -- by just typing it into a content area or by setting attributes on the page properties, or from the custom block you're making?
Thanks.
Sorry, should have been more clear. As I'm new to C5, I thought searching in content was the way to go. Finally in one of the forum posts I found that it's actually the 'search' block controller which does the page content search. So I was overriding the C5 'search' block. I changed the view.php by inserting the above code into the form and the controller did the rest and it worked! But it only works with JavaScript (building a string of values from select boxes and passing it to a hidden 'query' element). The controller line which takes the 'query' is
If I change the 'query' to 'continent' for example, it doesn't work. ???
Then I stumbled on page attributes and realised that's that's exactly what I need. Instead of searching by page content I need to search by custom page attributes. So I set them up: 'length', 'continent' etc. attributes and corresponding values, then I tick the ones I need on the page, I've changed the search function to
but it doesn't work (I posted a question here:http://www.concrete5.org/community/forums/customizing_c5/how-to-fil...
I'm sure searching by attributes is the way to go. But now I'm stuck again because I don't even know what that error means.
function do_search() { $q = $_REQUEST['query'];
If I change the 'query' to 'continent' for example, it doesn't work. ???
Then I stumbled on page attributes and realised that's that's exactly what I need. Instead of searching by page content I need to search by custom page attributes. So I set them up: 'length', 'continent' etc. attributes and corresponding values, then I tick the ones I need on the page, I've changed the search function to
$ipl->filterByAttribute('continent', 'Europe', 'like');
but it doesn't work (I posted a question here:http://www.concrete5.org/community/forums/customizing_c5/how-to-fil...
I'm sure searching by attributes is the way to go. But now I'm stuck again because I don't even know what that error means.
http://www.concrete5.org/help/building_with_concrete5/developers/se...
http://www.concrete5.org/documentation/developers/system/searching-...
http://www.concrete5.org/documentation/developers/pages/searching-a...
In general, it is considered a bad idea to modify the core code -- instead you override it. For example, you would put your own searching code in your block as opposed to modifying the built-in search.
Hope that helps!
-Jordan Lev