We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Ability to pass post data through pagination links / dynamic parameters issue

Development and Programming

heaversm's avatar
heaversm
197 posts
15 years ago
heaversm's avatar heaversm

Hi - I have a tough issue I’ve been struggling with for some time. A few of the makers of the plugins which I use to accomplish I have flat out told me they won’t support this, so I’m looking for another way:I have a form in one template which collects data in the form of dynamic parameters. For example:

<form action="{site_url}index.php/affiliates/affiliates_search_results/" method="post">
<select name="search:affiliate_region">                
    {exp:weblog:entries weblog="geography" dynamic="off"}
        <option>{title}</option>
    {/exp:weblog:entries}
</select>
</form>

Then the receiving template displays the results, and paginate themI use the search_fields plugin to simplify the process:

{exp:search_fields weblog="affiliate_network" dynamic_parameters="search:affiliate_regionparse="inward"}
{exp:weblog:entries entry_id="{search_results}" dynamic="off" operator="OR" orderby="url_title" sort="asc" limit="10" paginate="bottom"}
DISPLAY RESULTS HERE

{paginate}
Page {current_page} of {total_pages} pages {pagination_links}
{/paginate}

{/exp:weblog:entries}
{/exp:search_fields}

The pagination accurately detects the total number of entries, but when I go to the second page of results, all that post data is lost, so I end up getting all the results from all weblogs. I’m wondering if there is a way to store the post data in some variables that I can pass to an embed, with some sort of dynamic offset, or create a dummy form with a bunch of hidden fields that mimic the search form’s selections, or something. I’d love to hear any solutions or suggestions. Thanks in advance!

Oh, and this is the search plugins link:

http://ellislab.com/forums/viewthread/130518/

       
the3mus1can's avatar
the3mus1can
426 posts
15 years ago
the3mus1can's avatar the3mus1can

Dynamic parameters are a great idea, but their reliance on $_POST data is frustrating and stupid because it breaks pagination.

You will need to modify the core.paginate.php file. Add the following at the top of the show_links method:

if ($this->path !== '') 
{
    $this->suffix = '?' . http_build_query(array_merge($_GET, $_POST));
}

This will get the search data into the pagination links.

And at the top of the search results template add this:

<?php
$_POST = array_merge($_POST, $_GET);
?>

Make sure you also turn ‘on’ PHP on input for this template. This should work, but if not post your results to the forum and we can go from there.

       
Rob Sanchez's avatar
Rob Sanchez
335 posts
15 years ago
Rob Sanchez's avatar Rob Sanchez

If you’re on EE2, this module will help: http://devot-ee.com/add-ons/dynamo/

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.