Forums › Forums › Search & Filter Pro › search-filter/results.php – to load from plugin dir
Tagged: extending plugin, results, search-filter-pro
- This topic has 8 replies, 2 voices, and was last updated 8 years, 10 months ago by Ross.
-
Anonymous(Private) January 27, 2016 at 11:21 am #35435
Hi Ross,
Love the plugin. Thanks for this.
I need to customise results.php, but I need to be able to do that from a plugin, NOT from the theme. Right now, the only way to do so, according to the docs, we can copy paste search-filter/results.php in our theme’s dir.
Can you please advise on how to maybe overwrite/extend Search_Filter_Query Class (the_results function), from a custom plugin, and define new location for search-filter/results.php?
Any help is much appreciated.
Thank you,
V.
Ross Moderator(Private) January 27, 2016 at 12:05 pm #35438Hi there
I guess the best way to do this would be to use the standard way of customising the results template via the theme..
However, you wouldn’t use all the standard loop code etc, you would just empty the results.php file in your theme, and load the file that you desire using PHP, something like:
results.php:
<?php include '/path/to/my/plugin/myresultstemplate.php'; ?>
Thanks
Anonymous(Private) January 27, 2016 at 12:12 pm #35440Hi Ross,
Thanks for the quick reply. Unfortunately, it didn’t resolved my issue here.
Example: I am not allowed to touch, nor access WP theme’s folders or files. I need to be able to load results.php file from within plugin.
Is there a way to define new results.php file path (/path/to/my/plugin/myresultstemplate.php)?
Many thanks,
V.
Ross Moderator(Private) January 27, 2016 at 12:21 pm #35444There is no way without hacking the plugin.
Let me have a think, I could add a filter on the template filenames to check where you could override it.
Like I mention, its not a feature, but I’ll consider adding it to the next version once I’ve had a chance to properly think about the implications.
Thanks
Ross Moderator(Private) January 27, 2016 at 12:27 pm #35446Are you developing a plugin that uses S&F Pro? I’d be interested to hear a bit more about it ๐
Anonymous(Private) January 27, 2016 at 12:32 pm #35449Nope ๐ Just need the ability to modify results.php without touching the WP theme’s files. So I figured the only way to do this would be trough the custom plugin.. but no ๐
Yeah, just give us a filter or something, so we can change the path to the results.php file without changing WP theme’s structure.
Cheers
Ross Moderator(Private) February 3, 2016 at 8:28 pm #36171Hey again, I’ve been thinking about this one.
I don’t want to unnecessarily add bloat to the code, so want to get a better understanding of why you would want to do this – can you describe to me your use case?
The way I see it, anyone implementing S&F should also have access to the theme, and the theme is the best place for layout customisations like this.
Look forward to your response.
Thanks
-
AuthorPosts