AnonymousInactive
Hi,
I’m using Timber to render Twig templates to format my search results via results.php. I’ve added a conditional tag to load a new twig template if a specific page is calling the search results.
results.php:
<?php
if (is_page(ID)) {
$templates = array(‘special-template.twig’);
} else {
$templates = array(‘general-template.twig’);
}
….
This works fine on “Special Page” — i.e. the special-template results are loaded. However, I want to use AJAX to filter the results. When I try an AJAX filter, is_page returns FALSE and the “general-template.twig” is loaded for my search results.
Any advice? Or is this the wrong approach for what I want to accomplish?
Thanks!
Hi Vikki
I got slightly confused, but if you are using the results.php template provided (but copied in your theme folder) you will notice the line:
Found <?php echo $query->found_posts; ?> Results<br />
So this is already being displayed in your results – the variable you need is $query->found_posts
Thanks
I can see that your <p> tags around the image are not properly opened and closed
You open the <p> inside the <a> but the close it outside the </a>
This is not really a S&F issue anymore, if you default to the supplied results.php in the S&F template folder (of the plugin) do you see any out of place <p> tags?
AnonymousInactive
Hi Ross
Thanks I have copied results.php into my new search-filter folder as requested. Please can I have the code?
Thanks
Vikki
AnonymousInactive
But I can’t find the page that the S&F is using as results.
If I put the flag on use custom template (with the field url blank) works without not.
Whatever change I make to this file: search-filter-pro/templates/results.php nothing happens
AnonymousInactive
To sum it up my search result page is this: framework/global/_index.php
I can’t use that URL on your plugin. So I suppose yours is taking results from your file results.php
AnonymousInactive
Hi Ross I am using a custom template for my results for display purpose. It seems to work now so I hope nothing else will change. It seems to get my results.php template from my theme directory. Maybe because that is already in the database from before this upgrade? I’m not sure.
AnonymousInactive
Hello,
I am getting an error now Call to a member function have_posts() on a non-object in /home/domain/public_html/wp-content/themes/mytheme/search-filter/results.php on line 25
This is the page: http://wfsaustralia.com/clients/
Your help is appreciated. Thank you.
AnonymousInactive
Thanks for the feedback Ross,
2 – I have all your recommendations on. you can see the image with the general panel http://imgur.com/xWt2XPs
3 – i tried costumize the results.php to reach my point: i put that code:if ( $_GET["_sft_portfolio_category"] && $query->have_posts() ) instead of the original one: if ( $query->have_posts() )
This can generate any problem?
I really need the field relationship working.
Thanks a lot once again
Jamie
I’m really surprised at your reaction.
I logged in to your site. Created a basic search form, and set it up on a page working.
Now, when I try to access the page I created for you its all messed up.
If since me creating it for you it stopped working, then YOU must have changed something in your environment/setup without realising it has affected the work I have done.
Actually, I just logged in to your site, to check the settings of the form I created for you, and guess what – I can see you have changed the settings – and clearly broken it.
If you are a developer I’m sure you will know the difference between a Results URL and a template filename?
Well, in the “Results URL” box, you keep changing this to results.php – you do not specify the template name here, you paste the URL of a page with the Results shortcode (this can be found in the “shortcode” metabox)…
Again, I have created ANOTHER demo for you, it is completely working, cross browser and everything (I even tested).
So please, try to actually read what the various fields in the settings do before getting angry.
Thanks
Link in the following private message.