In case you haven't noticed, the internet isn't going anywhere--or is it? The web is constantly changing and evolving. Is your online presence up to snuff with the times we live in? We can get you there.
I want to be able to have a search bar where the user can search specific entries from the form to search.
For example, I would like them to be able to search only "last name" or only by "city".
Also, on the search page it is currently showing all of the entries from the form. I can limit this to a certain number, but if I specify zero the search no longer displays any results. Is it possible for zero entries to be displayed by default until after a search has occurred?
Can you help me set this up properly…I am a total novice by the way. :)
Thank you!
Luke
10:35 pm October 18, 2010
Steph
2
This would take a fair amount of custom PHP. For starters, you can add the search without selecting a field along with it with just:
[ frm-search ]
To hide the entries until a search has been submitted, you can install a plugin like PHPExec and add:
<?php if(isset($_POST['frm_search'])){ ?>
[ formidable id=x ]
<?php } ?>
If you'd like to set up the advanced search, you would need to create your own search form, and then add code to filter the entries. This would probably require making some changes to the plugin code. Do you have anyone who might be able to help you troubleshoot?
6:52 am October 19, 2010
Luke Gierach
3
First off…thank you. I will impliment what you have shown so far and see where I get with that.
At the moment I do not have someone to help, but will be stopping by the library for some php books to see what I can learn…I have gotten this far just by being a good code borower :)
Hopefully not being too ignorant, when you say creating my own search form, are you referring to a form that I make in formidable? or from scratch?
Also, would you be able to point me in a direction or two for learning what changes might be necessary to the plugin?
Thank you!
Luke
11:08 pm October 20, 2010
Steph
4
There is a decent amount of code you will need, but I think it will work to copy my code for the admin search and make your modifications.
The search form can't really be a Formidable form since the values need to be the field ids. So the code for the search form can be found in formidable/pro/classes/helpers/FrmProAppHelper.php at line 84 (search_form function)
Then the next step is processing the search.
But before we get into that part, I just had a thought. Would it work to have a different field in the search form for each field instead of putting them all in a drop-down? If so, the processing would be much easier. In fact, so would the search form creation. If you were to do it this way, you could create a Formidable form, and then we'd need to throw in a couple lines of code to prevent the search submissions from getting saved. Then, in your custom display, you can add a "Where" option for each field in the form you are collecting data with. You can set these to either be equal to or like [get-item_meta[30]], replacing 30 with the id of the corresponding field in the search form.
So, before I start into the code for either of these options, which one would you prefer?
9:15 am October 21, 2010
Luke Gierach
5
Your second suggestion would actually work perfectly…if I am interpreting you correctly :)
I would essentially have a second form (looking nearly identical to my existing form), but instead of it inserting data into mysql it would instead search based upon whichever values were typed in.
Could this then still be displayed in the "real estate" style where a small subset of info is shown with it being a hyperlink to a more detailed list?
Thank you!
Luke
8:41 am October 22, 2010
Steph
6
Yes, that is correct. Basically two identical forms, other than styling I'm guessing.
In your custom display, you can truncate any field with [30 truncate=100] where 30 is the field id and 100 is the number of characters. Are you using the "Both (Dynamic)" option?
To keep the entry from being saved, add this to a new plugin or your theme functions.php:
add_filter('frm_continue_to_create', 'stop_entry_save', 20, 2); function stop_entry_save($save, $form_id){ if($form_id == 3) //replace 3 with the id of your search form $save = false; return $save; }
10:43 am October 22, 2010
Luke Gierach
7
I am using the Both/dynamic option and it works great so far.
I will impliment the custom display change and add the code to the end of my functions.php file tonight and let you know how it works.
Thank you again for the help!
Luke
7:59 pm October 22, 2010
Luke Gierach
8
I think I am missing something. Any chance you can be very literal and explain just what I need, where.
I inserted the code above into my functions.php with the form ID # from the custom search form I made.
I am having trouble with what I put in the custom display area's. I want to have the detail link.
Do I have the custom display pull information from my form that submits the data to the tables, or does it pull from the form that does the searching
Luke
9:02 pm October 25, 2010
Steph
9
Your custom display will need to pull from the form that submits the data since that's where it is saved. There won't be anything to display if you use the search form since the entries into that form are not saved.
Would it be helpful at all to look at a couple examples with sample code for the custom display? If so, here's a demo site. You can see the code for each page at the bottom.
7:05 pm October 26, 2010
Luke Gierach
10
Here is some specifics first…
My search form ID=2
My submit form ID=6
This is the code on my webpage:
<?php if(isset($_POST['frm-search id=2'])){ ?>
[ formidable id=6 ]
<?php } ?>
I have also tried substituting ['display-frm-data id=2'] in place of the 'frm-search id=2'
This is what I have placed in the custom display "content" section
I have also attempted adding two "where" items at the bottom of the custom display settings. They were to link the First Name and Last Name of my submit form to be equal to [get-item_meta[93]] for first name, and 94 for last name. (those are the id's for the values in my search form)
I also tried using "like" instead of "equal"
So far, when I enter any search the result is the page refreshing with no form and zero results…a blank page essentially
Any chance there is something basic and simple I am missing?
Thanks,
Luke
12:47 pm October 27, 2010
Steph
11
Your custom display sounds right, but you're not inserting it into your page. Your page needs to look something this this:
Well…that sort of helps. It gets me a search bar with a search button, as well as all of my entries show below the search bar. Basically it gets me the same thing as the real estate example.
However, it does not display my search form. When I do display my search form I have not found a way to get the "submit" button of that form to actually retrieve any results.
2:29 pm October 29, 2010
Steph
13
I guess it would help if we inserted your search form instead of the default one.
I changed the text, and my form displays on my page, however when I click search I still end up with nothing listed.
Also, I believe that php code was supposed to keep me from having my entries displayed until after clicking submit, but my entries still display below the submit button. After I click submit the form dissapears, but the entries stay there with no changes.
I can email you a link to the page if you would like.
Do I need to upgrade to the unlimited license to get this to work?
Thank you,
Luke
9:54 pm November 1, 2010
Steph
15
If you want the search form to show after submitting, make sure you click the box to include the form with the success message.
Can you post a screenshot of your custom display settings?
4:15 pm November 2, 2010
Luke Gierach
16
I have that checkbox selected, however the form still dissapears after clicking submit. And there aren't any results from the search, simply the list of all entries that was there before doing the search.
I sent an email to the support email address with a link to the web page I am talking about.
Here is a screenshot of the custom display settings.