Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro 2 forms work together in one archive.php?

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • mhair
    #104843

    I have two forms that I’d like to work together. The search form sits in the header and is only a search input (sfid 5729). The Filter form sits in the sidebar and has dropdowns for 3 custom taxonomies plus a from and to date (sfid 5727). They both are set to display in archive.php. The search form will use a url such as this, https://boardofednew.webdev.idaho.gov/search/?_sf_s=test.

    The archive.php sidebar is implemented with content aware sidebars plugin and the sf widget for this filter form is set to display in it (5727).

    So when I access the current press releases from the menu using url https://domainnamehere/resources/?_sft_resourcetype=press-releases and archive.php the filter form (5727) displays properly along with the filtered results for press releases. However, when I use the search form from the header (5729), it displays search results properly using archive.php, but it does not display the filter form (5757) in the sidebar. My intent is to return the search results for the term, then filter it further with the form in the sidebar. Code for archive.php follows:


    <?php
    /**
    *
    * Description: Generic Index Page
    *
    * Used to display archive-type pages if nothing more specific matches a query.
    * For example, puts together date-based pages if no date.php file exists.
    *
    * If you’d like to further customize these archive views, you may create a
    * new template file for each one. For example, tag.php (Tag archives),
    * category.php (Category archives), author.php (Author archives), etc.
    *
    * @link https://codex.wordpress.org/Template_Hierarchy
    *
    * @package FoundationPress
    * @since FoundationPress 1.0.0
    */
    ?>
    <?php get_header(); ?>

    <main id=”main” class=”body-content row column” role=”main”>
    <?php get_template_part(‘template-parts/breadcrumbs’); ?>
    <div class=”medium-8 columns”>
    <header class=”page-header”>
    <?php
    global $searchandfilter;
    $sf_current_query_1 = $searchandfilter->get(5279)->current_query(); // 5279 is search input only
    $search_term = $sf_current_query_1->get_search_term();
    $sf_current_query_2 = $searchandfilter->get(5277)->current_query(); // 5277 is custom taxonomy filter input only
    $sarr = $sf_current_query_2->get_array();
    $fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
    $toDate = $sarr[_sf_post_date][active_terms][1][value];
    $type = $sf_current_query_2->get_field_string(“_sft_resourcetype”);
    if ($type) {
    $type = substr($type, strpos($type, “:”) + 1);
    }
    $topic = $sf_current_query_2->get_field_string(“_sft_primarytopic”);
    if ($topic) {
    $topic = substr($topic, strpos($topic, “:”) + 1);
    }
    $audience = $sf_current_query_2->get_field_string(“_sft_audience”);
    if ($audience) {
    $audience = substr($audience, strpos($audience, “:”) + 1);
    }
    if ($search_term) {
    $type = “Search Results”;
    }
    echo ‘<h1>’ . $type . ‘</h1>’;
    echo ‘<h2 class=”subheader”>’ . $topic . ” / “. $audience . ‘</h2>’;
    echo ‘<p class=”small”>Note: Select date range or change resource, topic or audience as needed.</p>’;
    ?>
    </header><!– .page-header –>
    <?php if (have_posts()) : ?>
    <section <?php post_class(); ?> >
    <?php while (have_posts()) : the_post(); ?>
    <?php get_template_part( ‘template-parts/content’, get_post_format() ); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php get_template_part( ‘template-parts/content’, ‘none’ ); ?>
    </section>
    <?php endif; // End have_posts() check. ?>
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ( function_exists( ‘foundationpress_pagination’ ) ) { foundationpress_pagination(); } else if ( is_paged() ) { ?>
    <nav id=”post-nav”>
    <div class=”post-previous”><?php next_posts_link( __( ‘← Older posts’, ‘foundationpress’ ) ); ?></div>
    <div class=”post-next”><?php previous_posts_link( __( ‘Newer posts →’, ‘foundationpress’ ) ); ?></div>
    </nav>
    <?php } ?>
    </div>
    <?php get_sidebar(); ?>
    </main>
    <?php get_footer(); ?>

    Trevor Moderator
    #104945

    To the form 5727, add a search field also, and use custom css to hide it. Then it will auto-populate with the value that was sent. Would that do it for you?

    mhair
    #105121

    Trevor,

    Thanks for your quick response. I’ve not responded yet as I’m trying to work with the content aware sidebars support since this may be more in their court. Just not sure yet. I appreciate your point of adding the search box to the second form and hiding it. That sounds like a good solution. Just need to get the second s&f form to show up in the sidebar. Will let you know if they provide any insights.

    Thx.

    Trevor Moderator
    #105173

    OK. I will leave it to you to get back to me if this becomes resolved or you require further help.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘2 forms work together in one archive.php?’ is closed to new replies.