Keeping pages from being listed as search results Dynamicly [SOLVED]

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Keeping pages from being listed as search results Dynamicly [SOLVED]

Post by isaacd »

Hello.

I was wondering if it is possible to prevent pages from being listed within the page template (for instance, a parameter in the search tag??). I am running cmsms 1.6.6. Mainly, I want to say something along these lines (note position refers to the hierarchical position, ex 1.3.2):

If the page position is >= 2 && < 3
    Only show results for pages with a position between 2 and 3
Else if the page position is not between 2 and 3
    Only show results for pages that are not between 2 and 3.
End if

I know how to use the {if} tag to show different code based on the current position, so the 1st, 3rd and 5th lines of my abstract above are no problem for me. It is the 2nd and 4th that I am wondering about.

Isaac.
Last edited by isaacd on Thu Mar 04, 2010 5:03 am, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Keeping pages from being listed as search results

Post by RonnyK »

There is a checkbox on every option-tab of a page, which sets the page to be searchable or not....

Ronny
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: Keeping pages from being listed as search results

Post by isaacd »

Hi Ronny. I know that it is a strange request, but I would like to be able to index all content, but only let it be seen as search results if the search has been done from certain pages. My navigation structure is something along these lines:

Home
Auxillary Inside (section header)
--Inside Home
--Another page
-----child page
---------third level page
Other pages
Other pages...

I have set my site up to function as if all the children of the "Auxillary Inside" (don't ask why I named it that) function as a different website than the rest of the site (though with the same template). This means that when you are in the non inside pages, or main site, that is all you will see from the navigation (you won't see any children of the Auxillary Inside). But when you navigate your browser to /inside, you will only see pages in the navigation that are children of "Auxillary Inside." To see what I mean, go to http://www.trilliumcharterschool.org for the main site, and http://www.trilliumcharterschool.org/inside for the inside site. Notice that the navigation structures are different.

Since as far as I know, cmsms has no official support for multiple sites, this is what I need to do. However, there is the problem that if I search for pages from /inside, there will be many results that are not from child pages of Auxillary Inside, and therefore, results that are not from the inside site. And vice versa. If I search from the "Main site," or non Inside pages, I will get results from the inside website when I am not actually on the inside website.

To see what I mean, go to http://www.trilliumcharterschool.org/inside (there is no useful content on this yet) look through all the navigation. Notice there is nothing called Trillium info. Then search for trillium info. Click the link, and notice how the navigation structure has changed. This is because trillium info is part of the main site, not the inside site.

Thanks.
Isaac
Last edited by isaacd on Wed Dec 23, 2009 6:21 am, edited 1 time in total.
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: Keeping pages from being listed as search results

Post by isaacd »

In order to make this work, I would need to be able to edit the result template. What I need is a way to find out the hierarchical position (page alias might work too) for every entry. In the result template, I see the variable
$entry, and I have seen it used like $entry->url or $entry->title, is there a way to do something like $enty->position? At this point, that is all I need.
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: Keeping pages from being listed as search results

Post by isaacd »

I have figured this out. Check out this page:

Code: Select all

http://forum.cmsmadesimple.org/index.php/topic,41537.0.html
. This is almost everything that you need to do. However, I have also figured out how to make it so that the allowed results will change depending on the hierarchical position of the page where the search was submitted from. Here are the steps:

Examples using this hieararchy:

1
---1.1
2
---2.1
3

This assumes that you want searches from page 1 and children to only show results from pages 1 and children, searches submitted from pages that are not page 1 or its children to only show results from pages that are not page 1 or its children.

1. If you are using a separate results page, create two: one as a child of 1, and one as a child of 2. In your content template, create an if statement like this (assuming the new pages are 1.2 and 2.2):

{if $position >= 1 && $position = 1 && $position = 1 && $position = 2)}

Now excluded results can be dynamic, depending on where the search was submitted from.
Post Reply

Return to “CMSMS Core”