-
AuthorSearch Results
-
October 17, 2016 at 8:26 pm #64634
In reply to: drop down filter(auto count) not working properly?
AnonymousInactiveWhat’s proper way to get query parameter in sf_input_object_pre?
October 17, 2016 at 6:13 pm #64614In reply to: drop down filter(auto count) not working properly?
TrevorParticipantThis:
sf_input_object_pre
will allow you to modify the html elements, yes. My bad. I am not sure how you would use it in this context though.
October 17, 2016 at 6:07 pm #64610In reply to: drop down filter(auto count) not working properly?
AnonymousInactiveI understand.
BTW, Can’t I use these hook to filter dropdown?
sf_edit_query_args or sf_input_object_prehttps://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/
August 16, 2016 at 5:48 pm #54735In reply to: Any way to pre-populate search field?
AnonymousInactiveAwesome! That was a huge help, thanks. In case anyone else is reading this to solve the same problem, here’s how I solved it:
We happen to have a page-search.php template in our child theme. So, I just added this to the very top:
$searchFilterID = 44867; add_filter('sf_input_object_pre', 'insert_search_term_into_advanced_search', 10, 2); function insert_search_term_into_advanced_search ($input_object, $searchFilterID) { $q = isset($_GET['q']) ? htmlspecialchars($_GET['q']) : ''; if($input_object['name']=='_sf_search') $input_object['attributes']['value'] = $q; return $input_object; }August 16, 2016 at 12:21 pm #54695Topic: Checkboxes default checked attribute
in forum Search & Filter Pro
AnonymousInactiveHi,
I would like to have the checkboxes’ checked attribute automatically set to ‘checked’, when opening the form. I use the following filter function :function catcheck($input_object, $sfid)
{
if($input_object[‘attributes’][‘type’]==’checkbox’)
{
$input_object[‘attributes’][‘checked’]=’checked’;
}return $input_object;
}
add_filter(‘sf_input_object_pre’, ‘catcheck’, 10, 2);It does not work. In my various tests, I manage to act on the
- element that contains the input elements, but not on the input elements themselves.
Thanks for your help.
Olivier
August 1, 2016 at 8:51 am #52893In reply to: Translate ACF Labels with Wp Globus / Qtranslate
AnonymousInactiveThanks Ross!
With this filter it’s possible to access to ‘heading’ label? I’ll need something like this:
function filter_function_name($input_object, $sfid) { $input_object['heading'] = apply_filters( 'the_title', $input_object['heading'] ); return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);July 21, 2016 at 2:29 pm #51817In reply to: Getting value from url
AnonymousInactiveHello Trevor,
This looks like a script that would work, I guess.
How do I use this?function filter_function_name($input_object, $sfid) { if($input_object['name']=='_my_field_name') { //udpate this field before rendering } return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);July 8, 2016 at 1:05 pm #50568In reply to: Use meta field for taxonomy value display
AnonymousInactiveHey Davide!
Sorry for the delay – hectic couple of weeks.
Try this:
// Relabel Co-Authors in Search & Filter function filter_function_name($input_object, $sfid) { if ($input_object['name'] == '_sft_author') { global $coauthors_plus; // Update option labels before rendering foreach($input_object['options'] as $key => $option) { // Rename "all items" label - this is always the option with no value if($option->value=="") { $option->label = "All Authors"; } else { $user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value ); $input_object['options'][$key]->label = $user->last_name . ', ' . $user->first_name . ' ' . ' (' . $option->count . ')'; } } $sortArray = array(); foreach($input_object['options'] as $option) { foreach($option as $key => $value) { if(!isset($sortArray[$key])) { $sortArray[$key] = array(); } $sortArray[$key][] = $value; } } $orderby = "label"; array_multisort($sortArray[$orderby],SORT_ASC,$input_object['options']); } // Return return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);June 27, 2016 at 2:13 pm #49503In reply to: Use meta field for taxonomy value display
AnonymousInactiveThanks, Ross! 🙂
Sorry, Davide! I haven’t had a chance to look at this yet. Work got kinda busy. Bleurrrrgh!
As far as putting the last name first bit goes, that’s easy. All you have to do is change display_name to a combination of last_name, first_name. The code would look something like this:
// Relabel Co-Authors in Search & Filter function filter_function_name($input_object, $sfid) { if ($input_object['name'] == '_sft_author') { global $coauthors_plus; // Update option labels before rendering foreach($input_object['options'] as $key => $option) { // Rename "all items" label - this is always the option with no value if($option->value=="") { $option->label = "All Authors"; } else { $user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value ); $input_object['options'][$key]->label = $user->last_name . ', ' . $user->first_name . ' ' . ' (' . $option->count . ')'; } } } return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);As for sorting, I think Ross is right and that the best way to go about it is using one of the standard PHP sorts.
I’ll have a look at doing that in the next couple of days. Would be a useful one to figure out! 🙂
June 19, 2016 at 11:45 pm #48864In reply to: Use meta field for taxonomy value display
AnonymousInactiveDone!
Added back the “All Authors” title and my post count. Final code:
// Trial by fire function filter_function_name($input_object, $sfid) { if ($input_object['name'] == '_sft_author') { global $coauthors_plus; //udpate this field before rendering foreach($input_object['options'] as $key => $option) { if($option->value=="") {//the option with no value is always the "all items" or unselected state $option->label = "All Authors"; } else { $user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option->value ); $input_object['options'][$key]->label = $user->display_name . ' (' . $option->count . ')'; } } } return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2); -
AuthorSearch Results
-
Search Results
-
Hi,
I would like to have the checkboxes’ checked attribute automatically set to ‘checked’, when opening the form. I use the following filter function :function catcheck($input_object, $sfid)
{
if($input_object[‘attributes’][‘type’]==’checkbox’)
{
$input_object[‘attributes’][‘checked’]=’checked’;
}return $input_object;
}
add_filter(‘sf_input_object_pre’, ‘catcheck’, 10, 2);It does not work. In my various tests, I manage to act on the
- element that contains the input elements, but not on the input elements themselves.
Thanks for your help.
Olivier