URL phrase for multiple keywords

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 12, 2011   (RSS)

By degreesnorth - January 6, 2011

Probably an obvious answer, but I can't figure it out. What would the URL when I want the results to display 2 or more keywords, for example, I want to combine Egypt, Syria, Jordan and Turkey as a grouped URL result. For example, if I want just Turkey, I do this: http://acac6262.staging-zeus.netregistry.net/tours_summary.php?country_list_keyword=Turkey, but how do I include Egypt, Syria, Jordan and Turkey. I've tried the &, comma, etc but nothing works??

Thanks

Re: [degreesnorth] URL phrase for multiple keywords

By Jason - January 7, 2011

Hi,

There currently isn't a way to have CMS Builder automatically search 1 field for multiple values. However, we can set this up with just a little extra coding.

From the look of your URL I'm assuming the field country_list is a single value drop down field. I'm also going to assume that the name of your section is "tours".

We're going to construct our URL to use comma separated values like this:
tours_summary.php?country_list=Turkey,Egypt,Syria,Jordan

Next, we're going to capture this list in our php code and use it to create a custom where clause:

$where = "1";

foreach(explode(",",@$_REQUEST['country_list']) as $country){
$where.=" OR country_list LIKE '%".mysql_escape($country)."%'";
}


Finally, we use our where clause to select our records

list($tourRecords,$tourMetaData)=getRecords(array(
'tableName' => 'tours',
'allowSearch' => false,
'where' => $where
));


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] URL phrase for multiple keywords

By degreesnorth - January 11, 2011

Hi Jason
Ummm, where do I put this code? I am assuming on the page where I want the result to appear? And I've tried every variation of this order, and keep getting errors. Is the order it's supposed to appear in?

Alternatively, I was wondering whether the "where" or "limit" can achieve the same thing? The country_list is a seperate table, where the field name "title" is the where the country name is inserted. Would this work as this sort of makes more sense, but I can't get this kind of phrase to work and there's nothing similar on the forum.

Thanks