Jump to content


Photo
- - - - -
Open

Search Results Don't Use Sections from Search Template



Best Answer Simon_P , 14 March 2013 - 08:07 PM

You should never have to edit files. Unless you want to edit every time you update.

 

if you follow page_type_breaker() you will see there is a filter at the bottom: 

 

return apply_filters('pagelines_page_type', $type, $post);

 

You should use this to override. 

Go to the full post


  • Please log in to reply
13 replies to this topic

#1 AngelosTzelepis

AngelosTzelepis

    Member

  • Members
  • 11 posts
  • Framework Version:2.3.2
  • Country: Country Flag

Posted 07 October 2012 - 05:15 PM

My search results page seems to be igonring the sections that I've included in the Search template (the default search template in the drag and drop section). I can't figure out where it's pulling the sections from. To test, I removed everything from the default search template and carried out another search, but the search results are still displayed on the page along with the sidebar etc. I would've expected an empty content area.

I've attached a screenshot of my drag and drop area. The search results still show even though I've removed everything from it. Probably worth mentioning that I don't have a custom search template in my child theme (i.e. a search.php file).

Any help would be appreciated,

John

Attached Files



#2 Simon_P

Simon_P

    Messer

  • Administrators
  • 8388607 posts
  • LocationDevon
  • Framework Version:2.0
  • Country: Country Flag

Posted 07 October 2012 - 05:21 PM

Add content area, then add sections to the content area.

#3 AngelosTzelepis

AngelosTzelepis

    Member

  • Members
  • 11 posts
  • Framework Version:2.3.2
  • Country: Country Flag

Posted 07 October 2012 - 05:40 PM

Yes, I did that originally but it wasn't displaying the correct sections on the front end. So i've moved everything from the content area as a test. What happens is that the search results still show, despite there being nothing in the content area! How can this be possible? I've cleared cache etc, so it's not that.

It's almost ike the wrong template is being used for my search results.

#4 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 07 October 2012 - 09:46 PM

First, in your Page Template for Search you must have Content present. Then, in Content Area, the Search template must have Posts Info and PostLoop present in order to display results.

It's possible because you may have PostLoop in the Content Area.

#5 AngelosTzelepis

AngelosTzelepis

    Member

  • Members
  • 11 posts
  • Framework Version:2.3.2
  • Country: Country Flag

Posted 07 October 2012 - 10:30 PM

Thanks for getting back to me Rob. There's nothing in the content area either, yet it still pulls in results. Is there any way to use a template other than the default search template to display the search results? It seems like that's what is happening - there is a different template hooked up the the search results.

#6 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 07 October 2012 - 11:07 PM

It's possible Wordpress is delivering the results within the generic or default PageLines template. Since I cannot see your site to try it, there's no way for me to tell.

#7 AngelosTzelepis

AngelosTzelepis

    Member

  • Members
  • 11 posts
  • Framework Version:2.3.2
  • Country: Country Flag

Posted 08 October 2012 - 06:31 PM

I've carried out a template by template test and discovered that the search results are being pulled into a template called 'Tribe Events'. I am using a plugin called 'The Events Calendar' by modern tribe, which uses that template to display event listings. I suspect it's because there are events in the search results that it's defaulting to that template. That leaves a problem because I don't want my search results and events listing to have the same template.

Is there any way to create a custom search template in Pagelines? One that can pull in sections?

I'll also contact the plugin authors to see if they know of a solution.

#8 Danny

Danny

    Is Awesome!

  • Moderators
  • 13192 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 10 October 2012 - 09:57 AM

Well we already provide a search template, if the plugin is also using this template and causing issue. Therefore, the best course of action would be to contact the plugin author and ask them to investigate, as I added several sections to my search page template and these sections were visible and working as intended.

#9 miramax

miramax

    Member

  • Members
  • 19 posts
  • Framework Version:DMS
  • Country: Country Flag

Posted 13 March 2013 - 10:48 PM

I've seen the same thing happening when search results include custom post types.  Somehow, the template for the Search Results Page is being switched to the template for the custom post type...so the sections defined for the Search template in drag/drop don't display...instead, you get the sections from the custom post type template.  

 

Question is, how could this possibly happen, and how to fix?



#10 James B

James B

    Advocate

  • Moderators
  • 4984 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 14 March 2013 - 04:06 AM

Hi, just to check are you using Platform Pro or Pagelines Framework at the moment?

 

Would you be able to show us an example of this working so we can check it with a developer.

 

So if have a custom post type come up in the search results, the template for the page the search results display on, switch from what you've set up for the search template to that of the custom post type template?



#11 miramax

miramax

    Member

  • Members
  • 19 posts
  • Framework Version:DMS
  • Country: Country Flag

Posted 14 March 2013 - 07:11 PM

MHC, I figured out how to resolve the issue...

 

The problem is in the Pagelines template class...it's incorrectly assigning the template for the search results page when custom post types are include in search results.  To be fair, this may be the fault of a plugin that is overriding the filters that Pagelines tries to apply, but it's pretty easy to fix if you're comfortable modifying PHP code.  It's only one line.

 

Here's what I did:

 

1. Open /wp-content/themes/pagelines/includes/class.template.php

2. Look for this code (around line 60 in my case)

Please Login or Register to see this Hidden Content

 

 

3. Update as follows

Please Login or Register to see this Hidden Content

 

You're basically forcing the template type to be 'search' if the is_search() is true.  This is definitely a workaround, but it solved the problem for me and took 5 minutes to do.



#12 Simon_P

Simon_P

    Messer

  • Administrators
  • 8388607 posts
  • LocationDevon
  • Framework Version:2.0
  • Country: Country Flag

Posted 14 March 2013 - 08:07 PM   Best Answer

You should never have to edit files. Unless you want to edit every time you update.

 

if you follow page_type_breaker() you will see there is a filter at the bottom: 

 

return apply_filters('pagelines_page_type', $type, $post);

 

You should use this to override. 



#13 AngelosTzelepis

AngelosTzelepis

    Member

  • Members
  • 11 posts
  • Framework Version:2.3.2
  • Country: Country Flag

Posted 14 March 2013 - 08:24 PM

This issue has been resolved. The issue only occurred in a local development copy of the site and could not be reproduced on the production site. 



#14 thomlaw

thomlaw

    Newbie

  • Members
  • 3 posts
  • Country: Country Flag

Posted 25 March 2013 - 07:42 PM

You should never have to edit files. Unless you want to edit every time you update.

 

if you follow page_type_breaker() you will see there is a filter at the bottom: 

 

return apply_filters('pagelines_page_type', $type, $post);

 

You should use this to override. 

 

Can you shed a little light on how to use the filters for this.  I'd like to achieve the same results but definitely don't want to this to be lost or impact updates.

 

@miramax:  cool find thanks

 

thanks much

 

-T