Skip to content

Instantly share code, notes, and snippets.

@juanpasolano
Created November 4, 2018 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpasolano/03d9fb37049a41e9d0f992a799cd5547 to your computer and use it in GitHub Desktop.
Save juanpasolano/03d9fb37049a41e9d0f992a799cd5547 to your computer and use it in GitHub Desktop.
Add custom url to sage 9
<php
add_filter('template_include', function ($template) {
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
return apply_filters("sage/template/{$class}/data", $data, $template);
}, []);
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
if(strpos($url_path, "inventory/category/") !== false){
$template = get_stylesheet_directory().'/views/virtual-category.blade.php';
echo template($template, $data);
return get_stylesheet_directory().'/index.php';
exit();
}
if ($template) {
echo template($template, $data);
return get_stylesheet_directory().'/index.php';
}
return $template;
}, PHP_INT_MAX);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment