- This topic has 9 replies, 2 voices, and was last updated 3 years, 7 months ago by
Tom.
-
AuthorPosts
-
December 6, 2018 at 9:43 am #749903
frederic
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
December 6, 2018 at 5:22 pm #750177Tom
Lead DeveloperLead DeveloperHi 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 π
December 7, 2018 at 9:34 am #750828frederic
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
December 7, 2018 at 6:07 pm #751119Tom
Lead DeveloperLead DeveloperIf 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.
October 26, 2019 at 10:08 am #1045354frederic
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 resultfunction 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
October 26, 2019 at 7:01 pm #1045597Tom
Lead DeveloperLead DeveloperHi 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?
October 27, 2019 at 9:41 am #1046118frederic
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
October 27, 2019 at 7:49 pm #1046335Tom
Lead DeveloperLead DeveloperCool, 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 π
October 28, 2019 at 12:26 am #1046424frederic
Hey,
it just did fine!
thanks a lot !
October 28, 2019 at 9:55 am #1046983Tom
Lead DeveloperLead DeveloperYou’re welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.