Custom search form

sage9

#1

Using Sage 9, is there a way to create a replacement for the search form with Blade? Right now I just have a new file, searchform.php, in the base directory of the theme. I’d like to move it from there to /templates/searchform.blade.php, but I’m not sure what other changes I need to make in order to do that.


#2

Have you tried exactly that? Does it not work?


#3

I should have mentioned, I did try exactly that. It did not work.


#4

I did it like this

https://github.com/kaisermann/selene/blob/master/src/filters.php#L170

Edit: I’m not sure about using config('view.paths')[0] or config('dir.stylesheet') . '/views/' ... (I use ‘views’ instead of ‘template’)


#5

@kaisermann Thanks, that did the trick. I ended up doing this:

add_filter('get_search_form', function(){  
  $form = '';  
  echo template(realpath(config('dir.template') . '/templates/partials/searchform.blade.php'), []);  
  return $form;  
});

#6

on version 9 beta 3

add_filter('get_search_form', function(){  
  $form = '';  
    echo template(realpath(get_template_directory() . '/views/partials/searchform.blade.php'), []);  
  return $form;  
});

an create the searchform.blade.php on views/partials/searchform.blade.php


#7

In Sage 9 beta 4 I do like this

add_filter('get_search_form', function () {
  $form = '';
  echo template('partials.site-search-form');
  return $form;
});

My search form file is called site-seach-form.blade.php located in views/partials/


#8

site-search-form.blade.php * :grin: