Forum

Thread tagged as: Question, Problem

page specific search function on multiple pages.

Im looking to have multiple search functions on 3 pages of a clients site. However I only want to search the content on that certain page. I looked up the "from-path" php function, but can't seem to get the function working. I have the following markup.

<?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>10, 'excerpt-chars'=>0, 'hide-default-doc'=>false, 'from-path'=>"/realtors.php", )); ?>

I only want the search function to look up content on the realtors.php page.? Any help would be appreciated. Without the 'from-path' function. the search function works great, however it pulls content from all over the site.

Cheers, Matt

MATTHEW URSO

MATTHEW URSO 0 points

  • 6 years ago

Sorry, Here is the structured code.


<?php perch_search_form(); ?> <div id="spacer"></div> <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>10, 'excerpt-chars'=>0, 'hide-default-doc'=>false, 'from-path'=>"/realtors.php", )); ?>
Rachel Andrew

Rachel Andrew 394 points
Perch Support

from-path needs to be a directory, so if your realtors.php was actually /realtors/index.php you could use from-path=>"/realtors"

Rachel Andrew said:

from-path needs to be a directory, so if your realtors.php was actually /realtors/index.php you could use from-path=>"/realtors"


<?php perch_search_form(); ?> <div id="spacer"></div> <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>10, 'excerpt-chars'=>0, 'hide-default-doc'=>false, 'from-path'=>"/realtors/", )); ?>

Still not working. My document is now located in a realtors folder in the root folder

ex. /realtors/index.php

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you add debug to that page what does it output?

https://solutions.grabaperch.com/development/how-do-i-debug-problems

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is anything on your site working? Those look like pretty fundamental configuration errors.

Can you post your diagnostics report? You should have been asked for that when creating your post.

I accidentally deleted some files yesterday.

My search function is working, however it says no results found when I state the 'from path' here is an example of two screenshots.

alt text for image

alt text for image

The search works perfectly when no path is selected, however when the path is defined, no results could be found?

Here is my mark up.


<?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>10, 'excerpt-chars'=>0, 'hide-default-doc'=>false, 'no-conflict'=>false, 'from-path'=>'/realtors/', )); ?>

Any help is appreciated. Here is my debug message.


SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='da913fceaf4e235197cb0e8950c8d491' LIMIT 1 UPDATE perch2_users SET userHash='0e0c2536e53b899be35468d09029c2ee' WHERE userID='1' SELECT p.privKey FROM perch2_user_privileges p SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID SELECT *, REPLACE(pagePath, '/index.php', '') as sortPath FROM perch2_pages WHERE pageNew=1 ORDER BY LENGTH(sortPath)-LENGTH(REPLACE(sortPath, '/', '')) ASC SELECT p.*, (SELECT COUNT(*) FROM perch2_pages WHERE pageParentID=p.pageID) AS subpages FROM perch2_pages p WHERE p.pageParentID IN (0, 4) ORDER BY p.pageTreePosition ASC SELECT * FROM perch2_content_regions ORDER BY regionOrder ASC SELECT * FROM perch2_content_regions WHERE regionPage='*' SELECT DISTINCT regionTemplate FROM perch2_content_regions ORDER BY regionTemplate ASC SELECT * FROM perch2_content_regions WHERE pageID=1 AND regionPage!='*' ORDER BY regionOrder ASC Queries: 11 Memory: 2.506
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you replaced the files you deleted?