Add filter for additional html in settings

Tagged:
  • localroutes
    Participant
    4 years, 5 months ago #14344

    Hello,

    to allow additional html, would it be possible to add a filter :

    wpsolr-pro/wpsolr/core/dashboard/dashboard_settings/inc.php
    line @686-689

    /**
    * Load additional setting html.
    */
    echo apply_filters(“wpsolr_content_after_label”, ”, $selected_val);

    wpsolr
    Keymaster
    4 years, 5 months ago #14345

    Can you give me an example of usage?

    localroutes
    Participant
    4 years, 5 months ago #14346

    The UI is quite complex and I would like to configure multiple searches

    Instead of recreating the whole UI for integration with some custom fields

    the filter makes it possible to add another setting for filters

    A filter for sort and search would also be helpful

    localroutes
    Participant
    4 years, 5 months ago #14347
    wpsolr
    Keymaster
    4 years, 5 months ago #14350

    I understand now. But you don’t need it, because obviously you already intercept the facets definition to do whatever you have to do.

    localroutes
    Participant
    4 years, 5 months ago #14351

    What I want is to use the UI you have made but add a couple options.

    If I don’t have a filter then I will have to rebuild the whole UI or modify core to add the filter myself as in the example above.

    wpsolr
    Keymaster
    4 years, 5 months ago #14352

    ok.

    Then please follow these instructions:
    1) Install the latest version 21.6
    2) Update wpsolr-pro/wpsolr/core/dashboard/dashboard_settings_inc.php with your new hook
    3) Send me a download link containing a zip with the updated file, and a separate file containing a code example of how you use the hook

    I’ll then check if it fits with WPSOLR’s design.

    localroutes
    Participant
    4 years, 5 months ago #14428

    Hello,

    I have added 2 filters

    Purpose:
    Add additional markup for includung fields in custom search
    File: wpsolr/core/dashboard/dashboard_settings.inc.php
    Filter added:
    Line no: 742
    echo apply_filters(“wpsolr_content_after_label”, ”, $selected_val);

    Screenshot:
    https://prntscr.com/pe8efw

    Purpose:
    Add additional field information on the search results page and in a map like latitude and custom fields.
    File: wpsolr/core/classes/engines/class-wpsolr-abstractsearchclient.php
    Filter added:
    Line no: 2903
    $data_result[‘additional_fields’] = apply_filters(‘wpsolr_filter_solr_results_additional_fields’, array(), $document, $wpsolr_query);

    Screenshot:
    https://prntscr.com/pe8g7h
    https://prntscr.com/pe8fsu
    https://prntscr.com/pe8f89

    Link to files

    https://drive.google.com/file/d/1jrIIRHeKqW2oAi4BXzTLCIgSNWpMTkuc/view?usp=sharing

    localroutes
    Participant
    4 years, 5 months ago #14474

    Hello,

    have you had a chance to take a look?

    wpsolr
    Keymaster
    4 years, 5 months ago #14476

    Yes.

    Add additional markup for including fields in custom search

    Your solution is to inject html in the facets admin page, to be able to add a custom option, here a checkbox.

    But your code needs to know the internals of the page options data structure (at least the options name for the page), which is bad if the plugins data structure must evolve (and it will soon in fact!).

    In your case, I do not think you need something as sophisticated. Just build an array in your code that associates the facet name with your option value.

    But I recognise it would be nice, even for the plugin’s extension, to be able to extend the facets.
    Something that would send the data, rather than the HTML, like:

    [ 'facet_name' => [
         'my-custom-field-name-1' => [
            'type' => 'checkbox',
            'default_value' => false
         ],
         'my-custom-field-name-2' => [
            'type' => 'edit',
            'default_value' => ''
         ]
       ]
    ]

    Add additional field information on the search results page and in a map like latitude and custom fields.

    – Already existing: https://www.wpsolr.com/guide/actions-and-filters/search-results-modify-posts/
    – Already existing: https://www.wpsolr.com/guide/actions-and-filters/search-results-append-html/

    • This reply was modified 4 years, 5 months ago by wpsolr.
Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.