Site logo

Archived topic

custom search

9 replies · Started by frederic on December 6, 2018

Viewing posts 1–10 of 10

Hi,

i customize search file (in a child theme) using this : justified image grid search
Point is there's no padding to the grid image and no content background color. What did i miss in the file ?

	 <?php
			/**
			 * generate_before_main_content hook.
			 *
			 * @since 0.1
			 */
			do_action( 'generate_before_main_content' );

			//if ( have_posts() ) : ?>

				<header class="page-header">
					<h1 class="page-title">
						<?php
						printf( // WPCS: XSS ok.
							/* translators: 1: Search query name */
							__( 'Search Results for: %s', 'generatepress' ),
							'<span>' . get_search_query() . '</span>'
						);
						?>
					</h1>
				</header><!-- .page-header -->

<!-- .start JIG search -->

<?php
    global $wp_query, $query_string;
    
    if(!empty($wp_query->query_vars['jig_custom_search'])){
        $jig_custom_search = $wp_query->query_vars['jig_custom_search'];
        $search_value = $wp_query->query_vars['s'];
        // echo do_shortcode("If you didn't find what you were looking for, try a new search!<br/><br/>[jig_custom_search_form source=".$jig_custom_search."]<br/><br/>");
        switch ($jig_custom_search) {
            case 'nextgen':
                get_jig(array('preset' => 'c2', 'lightbox' => 'magnific', 'mobile_lightbox' => 'magnific', 'ng_search_query' => $search_value));
                break;

            
            default:
                break;
        }

        echo '<style type="text/css">
                .post-content {
                    display: none;
                }
            </style>
            <script type="text/javascript">
                jQuery(".jigErrorMessage").text("No content found.")
            </script>';

        $wp_query = new WP_Query();
        $query_string = '';
    }
?>	
<!-- .end JIG search -->
<?php
do_action( 'generate_after_main_content' );
			?>
		</main><!-- #main -->
	</div><!-- #primary -->

	<?php
	/**
	 * generate_after_primary_content_area hook.
	 *
	 * @since 2.0
	 */
	 do_action( 'generate_after_primary_content_area' );

	 generate_construct_sidebars();

get_footer();

Thnaks for your help

Hi there,

You can add a background color to it like this:

.jig-imageContainer {
    background: #fff;
}

Are you wanting padding around the image as well?

Let me know :)

Thanks for the reply.

I wasn't thinking of a specific css hook, but to be in the right content/div of the theme.
Apparently, it'll be the same as a shortcode ([justified_image_grid preset=c2 lightbox=magnific ng_search_query="search value" ng_intersect_tags=yes ng_lightbox_gallery=yes nextgen_cf_link=Link])
in a page or article?

thanks

frederic

If you add the shortcode into an existing page, it should use the theme element by default.

Unless you can adjust the output of their archives to include the necessary theme elements, you'll likely have to use CSS.

Hi,

i kind of made it thru for the gallery result to display like the way it does in page.
How can i replace the default search in the primary navigation menu by my function image search ?
i try the hook/elements with the image search shortcode but without any result

function jig_custom_search_form($atts, $content = "") {
    if(empty($atts['source'])){
        return "Please specify the source.";
    }
    $form = get_search_form(false);
    $form = preg_replace( "/placeholder=\"(.\S)*\"/", 'placeholder="Search mags ..."', $form );
    $form = str_replace( '</form>', '<input type="hidden" name="jig_custom_search" value="'.$atts['source'].'" /></form>', $form );
    return $form;
}
add_shortcode( 'jig_custom_search_form', 'jig_custom_search_form' );
 
function add_jig_custom_search_query_var($vars) {
    $vars[] = 'jig_custom_search';
    return $vars;
}
add_filter('query_vars', 'add_jig_custom_search_query_var');

Thanks

Hi there,

We can add a hidden input to the navigation search, but I'm not sure where the "source" would come from since it's not using a shortcode. Is the source value necessary?

Hi,
i don't use it.
it is use as you can search either nextgen or Flickr with the plugin.
But in the switch statement i delete the flickr case in the file search.php and add my galleries preset to the nextgen case :
`get_jig(array('preset' => 'c2', 'lightbox' => 'magnific', 'mobile_lightbox' => 'magnific', 'ng_search_query' => $search_value));
So source will always be nextgen :
'<input type="hidden" name="jig_custom_search" value="'.$atts['source'].'"/>
works same way as :
'<input type="hidden" name="jig_custom_search" value="nextgen"/>

thanks

Cool, give this function a shot:

add_filter( 'generate_navigation_search_output', function() {
    printf(  
        '<form method="get" class="search-form navigation-search" action="%1$s">
            <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
            <input type="hidden" name="jig_custom_search" value="nextgen" />
        </form>', 
        esc_url( home_url( '/' ) ), 
        esc_attr( get_search_query() ),   
        esc_attr_x( 'Search', 'label', 'generatepress' ) 
    ); 
} );

Let me know :)

Hey,

it just did fine!

thanks a lot !

You're welcome :)

This archived topic is closed to new replies.