• Resolved gbambury

    (@gbambury)


    What I want to do, is on a list page after you have returned search results simply access the “search_field” and “value” values to construct a filter URL

    I’ve modified a list template to add a URL link which will be displayed after a search has been submitted the link will contain two values the “search_field” value and the “value” field value.

    I thought Id work this out but I just cant seem to get the $_POST array

    I cant even dump the array

    how should I access the “search_field” value and the “value” field value please?
    $_POST[‘search_field’]; returns nothing.

    Regards Guy

    • This topic was modified 6 years, 7 months ago by gbambury.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter gbambury

    (@gbambury)

    Even if I access the $_POST search_field and value I don’t think this method will give me what I want when constructing a URL.

    I tested it by just making a URL with filter results in

    http://www.testpage.com/my_page_with_pdb_list_short_code_on/?search_field=my_lists&value=blue

    on following the URL it works but the results page is the full list of records filtered by the search box on the page filled in with the URL params.

    What I need is the results page to only be the matching records at top level and then use the search box to filter them.

    If I use the shortcode and pass filter options i.e.

    [pdb_list filter=my_lists=blue]

    it works the result page only pulls back the relevant records not (all records) and then you can filter and sort this set of records.

    Ive tried passing URL params and then building the shortcode

    [pdb_list filter=my_lists=$_GET(list_name)] but I cant work out if this is even possible, I’m on trial and error at the moment.

    Hop this makes sense

    Thread Starter gbambury

    (@gbambury)

    Getting somewhere, it seems if I use the function do_shortcode I can build the correct pdb_list shortcode with the correct filter.

    echo do_shortcode( ‘ [pdb_list template=x_detailed sort=true search=true list_limit=15 filter=my_lists=’ . $_GET[‘list_name’] .’] ‘ );

    Still struggling to access the $_POST array after search values have been submitted.

    Plugin Author xnau webdesign

    (@xnau)

    One possibility here is if you’ve got AJAX searches enabled (plugin settings, advanced tab), then you might not see what you’re expecting on the screen. The template is called in the AJAX handler, but only the list part of the display is updated, so that could make it look like you’re not getting your values from the post array.

    So, on the search results page, you need to set up your dynamic link so that it is displayed inside of the “list-container” div, so that it will be refreshed when the search results are returned.

    Thread Starter gbambury

    (@gbambury)

    Hi Roland,

    Quote”
    So, on the search results page, you need to set up your dynamic link so that it is displayed inside of the “list-container” div, so that it will be refreshed when the search results are returned.”

    hummm I messed about with template, Im sure I put it in the list-container as I think this is commented in the template (although I been very busy rushing about today).

    Ill try again making double sure its in the correct container, and Ill play with turning off ajax to check things.

    fantastic plugin by the way, ive a few more add ons to buy as I work through my code, do you have a donate button anywhere?

    Regards Guy

    Thread Starter gbambury

    (@gbambury)

    Hi Roland

    So I’ve gone back to trying to access the $_POST array, it works with AJAX search turned off, but when I turn AJAX search back on I cant see the $_POST array, I’m assuming as the form doesn’t actually submit and passes through AJAX is why a $_POST array isn’t returned.

    Do you have any pointers how I can grab the FORM fields values on a template page an AJAX search is returned.

    What Im trying to do is generate a link at the bottom of my search results with the search_field and value attached. Its so I can pass just the results to an external page to be manipulated.

    As I said it works with normal search I just grab my variables from the $_POST array but when AJAX is on no $_POST array.

    Guy

    Plugin Author xnau webdesign

    (@xnau)

    The whole template is processed by the AJAX handler, and the values in the POST array (all the form values that were submitted) are available in the template.

    If you want to present content that is based on the submitted data, you have to place the content (not necessarily the code that generates it) inside of the DIV with the class “list-container”

    If you try to place the dynamic content outside of that DIV, it won’t be updated when the AJAX call displays the new list.

    Thread Starter gbambury

    (@gbambury)

    Roland
    Finally got this working, thank you for your input.

    When I was testing it first I was just using <?php var_dump($_POST); ?> to see if the POST array was full and I had it positioned inside a table row data cell as the correct class is in the table tag like below

    <table class=”wp-list-table widefat fixed pages list-container” >
    <tr><td>
    <?php var_dump($_POST); ?>
    </td></tr>

    As it happens this does not work, as soon as i just var dumped in its own div it worked like below

    <div class=”list-container”>
    <?php var_dump($_POST); ?>
    </div>

    Once again Thanks

    Thread Starter gbambury

    (@gbambury)

    Just closing thread

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Accessing the $_POST array’ is closed to new replies.