Big thanks, that piece of code work like a charm and did exactly what
i wanted it to do.
I wouldn't have been able to figure that out on my own.

On 1 Juni, 15:43, rick c <[email protected]> wrote:
> The easiest thing to do would be to override the act_search() method
> in your theme. Try this code in your theme.php file:
>
>         public function act_search( $user_filters = array() )
>         {
>                 $paramarray['fallback'] = array(
>                         'search',
>                         'multiple',
>                 );
>
>                 $types = Post::list_active_post_types();
>                 $types = array_keys( $types );
>                 $types = array_diff( $types, array( 'page' ) );
>                 $default_filters = array(
>                         'content_type' => $types,
>                 );
>
>                 $paramarray['user_filters'] = array_merge( $default_filters,
> $user_filters );
>
>                 $this->assign( 'criteria', htmlentities( Controller::get_var
> ('criteria'), ENT_QUOTES, 'UTF-8' ) );
>                 return $this->act_display( $paramarray );
>         }
>
> That will override the built-in act_search, and should remove the page
> content type from the search criteria, yet still allow all other
> content types to be used (including those not yet added. You won't
> need a special tag, and pagination will work properly. Caveat: the
> code is totally untested.
>
> Rick
>
> On Jun 1, 3:02 am, eternal243 <[email protected]> wrote:
>
> > Hello everyone, I've been trying to modify the search function on my
> > site to only show my blog entries instead of both entries and pages,
> > I've figured that the problem most probably is that somewhere in
> > system/classes where the search results are retrieved there is a
> > function looking for content-type any instead of content-type entry.
>
> > My problem is that i'm not very good at coding and I don't know where
> > to find it or if it is safe to modify this option without changing
> > other parts of the site where content is retrieved. Even if I
> > definitely would use an override in the users/classes directory.
>
> > So my question is if it is possible to do this or if it is hard coded.
> > Any help would be very appreciated.
>
> > Right now i'm using a workaround with this code before and after the
> > output of the search results in my theme search.php and then assigning
> > a nosearch tag on all my pages.
>
> > <?php if (!in_array('nosearch', $post->tags)): ?>
> > ...
> > <?php endif; ?>
>
> > This workaround does work, however it creates a new problem with the
> > page-selector below all the results on the search page. What happens
> > is that the page-selector still see the pages as a part of the search
> > results even if they are hidden from output.
>
> > An example, my search results would normally show 10 entries on every
> > page and i make a search for the word "test" and i get 9 results that
> > will be shown, but since i also have two pages with the word "test"
> > written on them although those pages have the "nosearch" tag. Those
> > two pages are hidden from output, but the page-selector see them as a
> > part of the results and say there are two pages of search results
> > instead of just 1.
>
> > The reason I want to change the search function to only show entries
> > instead of both entries and pages is mostly because I have moved the
> > search function to it's own page instead of having it on the sidebar,
> > which means my custom search page would show up in the results. I also
> > have a few other custom pages like an archive page that shouldn't be
> > output among normal search-results either.
>
> > If there is a way to actually make the page-selector understand that
> > i've hidden the nosearch-tag from output then that would be an even
> > better solution than to change the content-type, since it would allow
> > other content-types to be created later and still let them be
> > searchable. But i think that might be very hard to do.
>
> > Please tell me if i've got something wrong, I'm not very good at
> > coding, but I'm trying my best.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/habari-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to