ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using Dynamic Parameters with search: - Display no entries by default until the form is submitted

September 16, 2010 1:39am

Subscribe [1]
  • #1 / Sep 16, 2010 1:39am

    aerometric

    9 posts

    I’m using a form to filter weblog entries in the sidebar of a page. The form is setup like this:

    <form method="post" name="" id="contact-search" action="{path='contact'}">
    <select class="dropdown" name="search:salesrep_region" id="salesrep_region">
        <option value="">Select Your State</option>
        <option value="Alaska">Alaska</option>
        <option value="Alabama">Alabama</option>
        ...
    </select>
    <input type="submit" class="submit" id="btn-filter" value="Search" />
    </form>

    The “salesrep_region” is a custom field with a field type of FF Checkbox Group (using the FieldFrame add-on).

    Here’s the code where I have the filtered entries displayed:

    {exp:weblog:entries weblog="regional_sales_reps" dynamic="off" disable="categories|category_fields|member_data|pagination|trackbacks" dynamic_parameters="search:salesrep_region"}
    <h3>{title}</h3>
    <p><strong>Phone:</strong> {salesrep_phone}<br />
    <strong>Fax:</strong> {salesrep_fax}<br />
    <strong>Email:</strong> <a href="mailto:{salesrep_email}">{salesrep_email}</a><br />
    {/exp:weblog:entries}

    The form filters exactly as expected. There’s only one problem:

    How can I have nothing displayed by default (on page load)? I only want to display entries AFTER the form is submitted.

    Thanks for your help,
    Dave

  • #2 / Sep 16, 2010 12:18pm

    Rob Allen

    3114 posts

    You could use a segment to do this.

    If your search form is on the contact/index template set the path to contact/results

    Then use a conditional to only display stuff if the segment = “results”.

    <form method="post" name="" id="contact-search" action="{path='contact/results'}">
    <select class="dropdown" name="search:salesrep_region" id="salesrep_region">
        <option value="">Select Your State</option>
        <option value="Alaska">Alaska</option>
        <option value="Alabama">Alabama</option>
        ...
    </select>
    <input type="submit" class="submit" id="btn-filter" value="Search" />
    </form>  
    
    {if segment_2 == "results"}
    {exp:weblog:entries weblog="regional_sales_reps" dynamic="off" disable="categories|category_fields|member_data|pagination|trackbacks" dynamic_parameters="search:salesrep_region"}
    <h3>{title}</h3>
    <p><strong>Phone:</strong> {salesrep_phone}<br />
    <strong>Fax:</strong> {salesrep_fax}<br />
    <strong>Email:</strong> <a href="mailto:{salesrep_email}">{salesrep_email}</a><br />
    {/exp:weblog:entries} <br />
    {/if}

  • #3 / Sep 16, 2010 7:05pm

    Sue Crocker

    26054 posts

    Thanks for the assist, bluedreamer!

    areometric, does that bit of code help?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases