Search whole site content

8 posts by 4 authors in: Forums > CMS Builder
Last Post: June 24, 2014   (RSS)

By esupport - June 15, 2014

Hi,

I am creating search page.

How to search whole site content and html pages?

On my "searchResults.php"

Header area:

<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home2/ehost6/public_html/unicomp.com.tw/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load record from 'training'
list($trainingRecords, $trainingMetaData) = getRecords(array(
'tableName' => 'training',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => true,
));

?>

Note : Now is  //load record from "training".   How to load whole site record & html pages?

Search field:

<div class="search-box">
<form action="searchResults.php" method="get" name="search_form" id="search_form">
<input name="title,keyword" id="q" type="text" class="search-field" value="搜尋" />
<input src="icon/search_btn.gif" name="btn_search_submit" id='btn_search_submit' type="image" />
</form>
</div>

searchResults.php (HTML area) :

<?php foreach ($productsRecords as $record): ?>
</p>
<table border="0" cellspacing="0" cellpadding="0" width="700">
<span
id="news_list_lab">
<tbody>
<tr>
<td align="left" valign="top" class="content"><b> <a href="<?php echo 'products-detail.php?num='.$record['category'];?>">
<?php echo htmlencode($record['title']) ?> </a> </b> <?php echo $record['intro']; ?></td>

</tr>
</tbody>
</span>
</table>
<p>
<?php endforeach ?>

Note:

This is code sample.
The "productsRecords" is from my previous site code.  

I have no idea what code I can instead to display search result.

Hello, I hope someone out there can help.

Thanks!

Jac

-Jax H.

By claire - June 17, 2014

Hi Jac

Sorry for the late reply, this is a tricky one. As far as I know it'd be very difficult to implement. I'm going to refer it to one of the senior programmers here, they might have an answer for you.

--------------------

Claire Ryan
interactivetools.com

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

By Dave - June 17, 2014

Hi Jac, 

Unfortunately, there's no built in functionality to search all the database tables and HTML pages on a site.  

CMS Builder supports creating custom searches for a specific section as shown in the docs here: 
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

For searching the entire site you could check out a free Google Custom Search engines, or custom PHP programming to search multiple mysql tables and output results.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By esupport - June 19, 2014

Hi Dave

I tried to figure it out.

Still don't understand below table meaning.

https://nimbus.everhelper.me/client/notes/share/35111/iK6mf3ZEFKU4SpWL8itbJWVGJZdqHTTe/

On my first post.

If I want to search product and news section.

What do I need to change the code?

or

Do you have any sample code for reference?

Thanks a lot!

-Jax H.

By esupport - June 23, 2014

Hi Dave

There are 3 sections  on my site : news, event, promotion news.

Do you mean only a section can be searched?

If I hope to search multiple sections.  I need to create other input fields.

Is it correct?

-Jax H.

By mizrahi - June 23, 2014

imo, the google custom search engine is the way to go. it's significantly more powerful out of the box then the multisearch approach. multisearch has it's place, but as soon as you go beyond searching a few sections, it starts showing it's limitations. 

https://www.google.com/cse/

If you can live with the ads, it's free. Otherwise, the paid version is more than reasonable. It's also free if the organization is a non-profit (501c3). Take a look www.jhf.org for a site that's running CMS builder, but uses google for the search engine. 

Jason

By esupport - June 24, 2014

Hi Jason there

Thanks for the suggestion.

There are some of PHP search code template.  

Like this : 

http://www.youtube.com/watch?v=PBLuP2JZcEg

http://www.youtube.com/watch?v=Tzuuh6wSijo

If we want to use the code on cmsbuilder.

Would it occurs error?  cmsbuilder accept the PHP code?

Thanks.

Jac

-Jax H.