Designating Non-Searchable Content

Use GitHub to post feature requests for phpwcms.
Locked
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Designating Non-Searchable Content

Post by jsw_nz »

I remember reading somewhere in the forum regarding the issue of site structure elements, set to hidden, still showing up in search results. Basically I have an implementation of Pappnase's 'content right', placing editable (172px wide) 'modules' in the right panel. These modules are included in the final page using the new {URL..} tag. They are designated as 'hidden from frontend'.

What I found however is that during standard site wide search...these modules come up in search results. The user clicks the link, and instead of coming to a full page..they are directed to the 172 pixel wide module itself...not very cool.

From what I remember...there is at present no way to designate these elements (modules) not to come up in search results. I wanted to ask pointer/ideas on workarounds or if there is any plan to support a checkbox in the backend ('Make this (hidden) category non-searchable')

Cheers,
jsw(john)

UPDATE: What I have been able to do is add an additional field to the 'phpwcms_article' table, naming it article_nosearch. It is similar to the other flag fields 'article_public', 'article_aktiv'...etc and is set to 0 by default. Then in the query in: include/inc_front/content/cnt13.article.inc.php,
I added the additional parameter (article_nosearch=0) to the string:

Code: Select all

$sql  = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ";
$sql .= "WHERE article_public=1 AND article_aktiv=1 AND article_nosearch=0 AND article_deleted=0 ";
$sql .= "AND article_begin<NOW() AND article_end>NOW() ";
$sql .= "ORDER BY article_cid, article_sort, article_tstamp DESC;";
Obviously this is a simplified hack of sorts...but it might enhance wcms It should not be too difficult to add a checkbox in the article dialogue, perhaps at the bottom of the page next to status: [ ] visible [ ] public [ ] non-searchable

I also found the original thread that raised the topic of this thread:
http://www.phpwcms.de/forum/viewtopic.php?t=1082

cheers....
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Working...

Post by jsw_nz »

OK...got a 'no search' hack to work here...perhaps this should be in the hacks section...anyway:

Image

**************************************************
Added field:
article_nosearch >> to >> phpwcms_article: INT(1) Default=0

***************************************************
Changed:
include/inc_front/content/cnt13.article.inc.php

added the additional parameter (article_nosearch=0) to the string
(line 43):

Code: Select all

$sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM 
".DB_PREPEND."phpwcms_article ";  
$sql .= "WHERE article_public=1 AND article_aktiv=1 AND article_nosearch=0 AND 
article_deleted=0 ";  
$sql .= "AND article_begin<NOW() AND article_end>NOW() ";  
$sql .= "ORDER BY article_cid, article_sort, article_tstamp DESC;";
**************************
changed inc_tmpl/article.editsummary.tmpl.php
around line 310 adding new td with 'no search' checkbox

Code: Select all

<td><input name="article_nosearch" type="checkbox" id="article_nosearch" value="1"<?php is_checked(1, $article
["article_nosearch"]); ?>></td><td>no search</td>
BTW: the 'no search' text label is not dynamic here
OliverG understands pulling dynamic values here better than I...

****************************************
added three lines in inc_lib/article.editcontent.inc.php

line 51 (or thereabouts): add article_nosearch entry to array

Code: Select all

$article["article_nosearch"] = $row["article_nosearch"];
line 83 (post related):

Code: Select all

$article["article_nosearch"] = intval($_POST["article_nosearch"]);
line 201: (for updating)

Code: Select all

"article_nosearch=".$article["article_nosearch"].", ".
At the end of the day this little hack/workaround allows you to exclude content at the article level from search results.
I am guessing for finer granuality this should be supported as an option for content parts... Hoping this gets included in wcms at some stage...but knowing OliverG, he already has this covered (and more) in next release.

Cheers and All best,
jsw
User avatar
isac
Posts: 410
Joined: Tue 18. Nov 2003, 13:13
Location: Portugal
Contact:

Post by isac »

Great job jsw_nz

Like you, I use hidem pages to include them after in columns on every place, soo I think this hack is very usefull at this moment.

Lets see what Oliver has to say... :D
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Hi Isac

Post by jsw_nz »

Hi Isac,

As a matter of fact apart from accommodating the content right - hidden option - (likely to be replaced in Oliver's next release) - I think there is reason to argue that excluding certain content from search results generally makes good sense. Offers just another level of control for the system.

"Lets see what Oliver has to say..."

I agree...All best, john
stevenlyons
Posts: 69
Joined: Fri 2. Jul 2004, 01:46
Contact:

Post by stevenlyons »

This looks useful--any warnings to the uninitiated before attempting it? Thanks.
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Hi Steven

Post by jsw_nz »

Actually that is a very good question.

Like any hack it is easy for something to go wrong.
Having said that... I think the documentation is complete. Basically builds another field and then talks to it, controlling whether content at the article level is searched or not.

Of course...do a backup of original files before trying...
Will be interested to hear about your own results.....

all best,
jsw
stevenlyons
Posts: 69
Joined: Fri 2. Jul 2004, 01:46
Contact:

Post by stevenlyons »

Doesn't work here:

error while updating article basis information:
UPDATE phpwcms_article SET article_cid=8,article_title='Thank You', article_keyword='', article_public=1, article_aktiv=1, article_begin='2004-07-20 21:01:00', article_nosearch=1, article_end='2010-12-31 23:59:59', article_subtitle='', article_summary='', article_redirect='', article_username='phpwcms webmaster', article_notitle=1, article_hidesummary=1, article_image='a:8:{s:8:"tmpllist";s:7:"default";s:8:"tmplfull";s:7:"default";s:4:"name";s:0:"";s:2:"id";i:0;s:5:"width";i:538;s:6:"height";s:0:"";s:7:"caption";s:0:"";s:4:"zoom";i:0;}' , article_uid=1 WHERE article_id=10;

Followed your instructions precisely. I have RC4 22-06-2004.
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post by jsw_nz »

Not sure where to direct you, other than to mention that update errors are typical in conditions where table data (fields) do not correspond to the query itself. Did you create the extra field in the database?


ADD FIELD
'article_nosearch' to 'phpwcms_article':

I used phpMyAdmin to do this,
using these parameters:

INT(1) Default=0

I have tested the code on two installs, and it works in both. I hope you can get it to work. BTW..nice website.

Cheers,
jsw
stevenlyons
Posts: 69
Joined: Fri 2. Jul 2004, 01:46
Contact:

Post by stevenlyons »

Ah well of course that makes total sense...have to alter the DB itself...
guess this is a little out of my league...

thanks for the compliment.
Locked