• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: How would you do semantic search with CMSMS?
PostPosted: Tue Apr 10, 2012 3:10 pm 
Offline
Forum Members
Forum Members

Joined: Thu Jul 08, 2010 1:11 pm
Posts: 32
I have set of pages, one section of the site, that I need to search in semantic way. Let's say it's sort of person index / list of biographies. There's need to find people who speak German, but it's not a good idea to simply search for string German as it would find the one where text says "her grandparents are German". Also it should be possible to search by profession, e.g. police, but not find him who got in trouble with the police in college. As said, it's one section of the side, side-wide search is out of question. I hope you got the picture.

The pages exist except for the metadata that would be used for searching so creating a real database is not the quickest way to go. At first I considered tags, but at least Simple Tagging module is too limited, it's not possible to classify tags. I think extra page attributes could work, but they're only three and we need 4-5 classes, so it wouldn't be a perfect solution.

Maybe some sort of product catalogue could be used? There's at least Products and Cataloger modules but I'm not sure can they be used with existing pages. I'm also pretty sure someone has already solved similar problem :)


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Tue Apr 10, 2012 3:37 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 426
Not sure if it fits your needs but I'm doing something similar, and using CompanyDirectory... still testing but, so far, with good results.

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."

* by the way: English is NOT my native language (sorry for any mistakes...).

My developer Page on the Forge.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Wed Apr 11, 2012 2:31 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Feb 07, 2007 2:36 pm
Posts: 102
Hi asdf,

Not sure if this helps, but if you are considering using the extra attributes, you could perhaps use the {content} tag in your page template, make it one line and apply a smarty parameter to it?

For example:

{content block="search_tag" label="Search Tag" oneline="true" assign=searchtag}

Then you could set a value, callable with $searchtag

There's full help info in 'Extensions > Tags > Content'

Regards,

Mikey


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Mon Apr 16, 2012 3:16 pm 
Offline
Forum Members
Forum Members

Joined: Thu Jul 08, 2010 1:11 pm
Posts: 32
Thanks for suggestions, I'll have a look at both.

In fact I tried content blocks already but was not able to restrict standard search module to look in those only. But maybe there's a way I'll figure out now that I can get back to this question.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Fri Jul 13, 2012 7:06 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
This seems to work if I understand the question correctly, ie you want to display only the results of a search based on a word/phrase contained in a user-defined content block.

Firstly, create a MenuManager template called 'getalias'. It doesn't need to contain anything, we only want the node list. Just to have something in the content area, you can leave {if $count > 0}{/if}.

Next, modify the Search result template as follows:

Code:
{cms_module module=MenuManager template=getalias}
<h3>{$searchresultsfor} &quot;{$phrase}&quot;</h3>
{if $itemcount > 0}
<ul>
    {foreach from=$results item=entry}
       {foreach from=$nodelist item=node}
          {if $entry->url eq  $node->url}
             {capture assign=blockcontent}{$cgsimple->get_page_content($node->alias,'name_of_your_content_block')}{/capture}
                {if $blockcontent|strpos:$phrase !== false}
                <li>
                    {$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
                    ({$entry->weight}%)
                </li>
            {/if}
          {/if}
       {/foreach}
    {/foreach}
</ul>
<p>
    {$timetaken}: {$timetook}
</p>
{else}
<p>
    <strong>{$noresultsfound}</strong>
</p>
{/if}


How it works:

1. We retrieve the nodelist which contains the page alias and also conveniently, the page URL.
2. We iterate through the search results and compare the search entry URL with the nodelist URL
3. When a match is found, we retrieve the particular content block using CGSimpleSmarty with the corresponding $node->alias
4. Next, we search the content block for the search phrase {$phrase}
5. If a match is found, it outputs the result or else moves onto the next search result.

Please Note: CGSimpleSmarty must be installed.

hth
psy


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sat Mar 09, 2013 3:36 pm 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 872
Location: London
Very useful psy just used on a multilingual site in order to restrict the search to specific language. Just a couple of things you may wish to use stripos instead as strpos is case sensitive and also add a counter inside the {if $blockcontent|strpos:$phrase !== false} statement in order to use if no results found.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sat Mar 09, 2013 11:46 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
Thanks Applejack :)

One further refinement to speed things up, change:

Code:
{capture assign=blockcontent}{$cgsimple->get_page_content($node->alias,'name_of_your_content_block')}{/capture}

to
Code:
{$cgsimple->get_page_content($node->alias,'name_of_your_content_block','blockcontent')}


psy


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 12:07 am 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 872
Location: London
I would leave as is using capture as more flexible in case you want to include other content blocks such as title ala {$cgsimple->get_page_title($node->alias)} etc etc


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 12:21 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
Good point.

The suggestion was based on Calguy's comment on http://forum.cmsmadesimple.org/viewtopic.php?f=7&t=65094&p=293838&hilit=capture#p293838 ie don't use {capture} unless necessary as it's slow.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 1:14 am 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 872
Location: London
You could perhaps use |cat but...


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 2:08 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
Yep, whatever works. ;)

Another thing you may want to change is the MenuManager call to
Code:
{cms_module module=MenuManager template=getalias show_all="0"}


in case the search result page is set to not show in the menu. This will include it in the $nodelist.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 2:21 am 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 872
Location: London
I have the search results page set as not show in menu and your code works fine.

Also you can just use {menu template='getalias'}


Last edited by applejack on Sun Mar 10, 2013 2:34 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 2:29 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
I was a bit ambiguous, not the Search module results page, BUT the $nodelist containing the pages from the MenuManager call, ie you want to ensure that ALL active pages are included in $nodelist, not just those marked as "Show in Menu".

Again, yep, you can use the shorthand version of the MenuManager tag. Force of habit over many years to write module tags the full way in other module templates.


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 2:37 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 305
Oh and of course, you'll then have to filter out the Search results page URL otherwise you may end up in an endless loop. :)


Top
 Profile  
 
 Post subject: Re: How would you do semantic search with CMSMS?
PostPosted: Sun Mar 10, 2013 2:38 am 
Offline
Power Poster
Power Poster

Joined: Fri Mar 30, 2007 2:28 am
Posts: 872
Location: London
For anyone else this may be useful UDT for getting the page alias in other instances

viewtopic.php?f=7&t=54145&p=267095&hilit=search+results+alias#p267095


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner