[SOLVED] Search module - specific folder search?

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
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

[SOLVED] Search module - specific folder search?

Post by manuel »

I've set up 2 templates for 2 different languages.
Each template has a localized search

Dutch template: {search lang="nl_NL"}
French template: {search lang="fr_FR"}

It would be great if I could specify what folder the individual search entries should search with a tag like  {search lang="nl_NL" index="Dutch"} ("Dutch" being the page name or section header name of the parent page containing all dutch sub-pages...)
Currently, both the dutch and french pages are shown in the search results.

My current folder structure is something like this:
- Dutch (Section Header)
- - Page 1 (regular content page with the dutch template containing only dutch content)
- French (Section Header)
- - Page 1 (regular content page with the french template containing only french content)

Alternative Solution?
If this isn't possible, could it be possible to get the individual search results to show an image based on their parent page? (like a little flag icon)
This way, the user could clearly see if a page is in french or dutch before visiting the page and getting all confused because it's in a foreign language...     ;)
For this to work, we would have to pass the title of the section header or parent page to the search result template with a tag like {$parentpagetitle} or something like that...

Alternative solution 2?
As I'm using the {page_class} tag to fill out the body class, maybe this can be used to somehow help to show a custom image for the individual search result?
The generated html output looks like this () and contains the relevant information about the parent pages...

Original thread concerning the page_class tag: http://forum.cmsmadesimple.org/index.ph ... l#msg84973

Alternative solution 3?
A different possibility might be to use the CustomContent module and use some of the tags described by Callguy1000 in the thread below?

The problem is that this will pass the values of the parent pages of the search result page, not the values of the parent pages of the individual search results... (If i'm correct)

http://forum.cmsmadesimple.org/index.ph ... l#msg87374

In the head:

Code: Select all

{capture assign='root_alias'}{$ccuser->get_root_alias()}{/capture}
{capture assign='root_title'}{$ccuser->get_page_title($root_alias)}{/capture}
{capture assign='parent_alias'}{$ccuser->get_parent_alias()}{/capture}
{capture assign='parent_title'}{$ccuser->get_page_title($parent_alias)}{/capture}

in the result template:

Code: Select all

  {foreach from=$results item=entry}
  <li class="{$root_alias}">{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
(where root_alias returns the root parent's alias if I'm correct)

Greetings,
Manuel
Last edited by manuel on Fri Apr 15, 2011 4:04 pm, edited 1 time in total.
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Search module - specific folder search?

Post by manuel »

Found a different possibility!

By using the passthru value, one can limit search results.

The tag below is working perfectly for limiting the search to all Dutch news items.
{search lang="nl_NL" modules='News' passthru_News_category='Dutch'}

I would like to add the regular content to this search.
If possible, I would pass the "template" value to "passthru" because I have separate templates set up for each language.
The problem is that I don't know if a "module" can be specified that contains the regular content and the template value...

The ideal would be: (supposing the TinyMCE module contains all regular content and the template values)
{search lang="nl_NL" modules='News,TinyMCE' passthru_News_category='Dutch' passthru_TinyMCE_template='Dutch'}

I feel this is pretty close to a real solution for a specific language search in a multi language website! If only I knew what to fill out for the module...  :-\
Please send me your feedback...

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
moonie
Forum Members
Forum Members
Posts: 81
Joined: Tue Feb 13, 2007 3:08 pm

Re: Search module - specific folder search?

Post by moonie »

Hello manuel

Sorry for digging out an old topic, but I have the exact same question atm and would like to know if you have found a solution for this?

My site is structured the same way as yours:
- FR (section header)
- - all the french pages
- DE (section header)
- - all the german pages

Naturally the contents from both sections share some keywords (names of the team members etc.), and thus they show up twice in a search, once the french result and once the german result. Have you found a way to only display french pages in the search result when the search is performed under the FR tree (maybe with the help of the parent alias)?
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Search module - specific folder search?

Post by manuel »

Hi Moonie,

I haven't found a solution for this issue yet...  :-\
I see you posted a link to this thread on the great multilingual site thread from Rolf (http://forum.cmsmadesimple.org/http://p ... 10#p237810), let's hope someone wanders over and finds a solution for this issue which is imho the last missing link to creating a perfect multi-language site...

It has been a while since i first looked at this so I'll try to give it an other go but any help is greatly appreciated!

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
seneca
New Member
New Member
Posts: 2
Joined: Thu Apr 14, 2011 11:20 pm

Re: Search module - specific folder search?

Post by seneca »

A very non elegant solution i found is:

Given that you store the current language in a variable, the site is structured like this

- FR (section header)
- - all the french pages
- DE (section header)
- - all the german pages

and the url will be something like "yourwebsite.com/fr/page1" or "yourwebsite.com/de/page2", you could modify the search result template to explode the url of each item returned by the search module, and test for known languages.

For example:

Code: Select all

{foreach from=$results item=entry}
{assign var="url_lang" value="/"|explode:$entry->url}
{if (($url_lang[3]=="en") || ($url_lang[3]=="fr"))}
   {if ($url_lang[3]==$page_lang)}
     <li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
   {/if}
{else}
  <li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{/if}
{/foreach}
A much more elegant solution would be for the search module to also return the alias of every result page, so you can check the root with get_root_alias().

Of course the best way is to add a "start_search" parameter to the search module.

All that i written does not account for News and other modules. I guess you could write some ugly hacks for those too, but i only replied because i saw nobody answered until now, and i have recently had this problem too.
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: Search module - specific folder search?

Post by manuel »

Thanks for sharing this Seneca!!
Great first post ;)

Code: Select all

{assign var="url_lang" value="/"|explode:$entry->url}
If i understand correctly, the value in the assign is used as the delimiter for the explode?
Sorry for asking such a basic question but the usage of explode modifier in smarty was new for me.

I didn't find any reference to the explode modifier in the "plugins" or "lib/smarty/plugins" folder (where you can find the other modifiers) or in the official smarty manual.

Do you happen to know how can i find out what modifiers are available for cmsms or did you add this one yourself?
(haven't tested your code yet to verify if the explode modifier is readily available in cmsms)

Greetings,
Manuel
seneca
New Member
New Member
Posts: 2
Joined: Thu Apr 14, 2011 11:20 pm

Re: Search module - specific folder search?

Post by seneca »

Manuel, all functions from php can be used as modifiers unless they are disabled in the distribution. Until now CMSMS didnt enable the security for smarty, so is a safe bet they wouldn't enable it in the future.
See http://www.smarty.net/docsv2/en/language.modifiers.tpl
Because the explode function takes the delimiter as the first parameter, you must write the modifier that way, or you could write a plugin for it to make it look standard.
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: [SOLVED] Search module - specific folder search?

Post by manuel »

Thx for the follow-up, i've marked this topic as solved :)

Greetings,
Manuel
Post Reply

Return to “CMSMS Core”