Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-07-27 13:50:14
- ooz
- Member
- From: Finland
- Registered: 2007-07-27
- Posts: 14
Search issues / search doesn't include category names?
Since categories describe the nature of an article and not the presentation, the categories names should be included into the search, unless I got it really wrong. (in other words, they are not included).
If I name categories like “books” or “cds”, a search for the word book(s) should return also all articles in that category, unless I accidentially post an article about something else in that same cat.
If I search for a word that is not mentioned in the article itself (like on graphics-only-show-off-pages), search will not find it, even when I add it as a keyword! A search for “flowers” would not return the best shots, unless I add written content to the pics.
Is there anybody with the same (newbie-)search-issues?
A newbie asks for help: is there a way to put hands onto the search-functionality without messing it up?
Last edited by ooz (2007-07-29 06:37:50)
“Habit is probably the greatest obstacle of perceiving truth.” R.A. Schwaller de Lubitz
Offline
#2 2007-07-29 06:33:31
- ooz
- Member
- From: Finland
- Registered: 2007-07-27
- Posts: 14
Re: Search issues / search doesn't include category names?
Solved. (beginners luck) :)
Jep, laugh it up, I’m not ashamed about this, even if the solution was blind experimenting…
Here’s what I did (version 4.0.5):
2 Files altered: textpattern/publish/ search.php and textpattern/ publish.php
search.php: added “Category 1” twice, lines 33 and 35 (I’ve no clue what so ever if this is necessary…)
line33 match (Title,Body,Category1) against ('$q') as score",
line35 "(Title rlike '$q' or Body rlike '$q' or Category1 rlike '$q') $s_filter
publish.php: added Category1 to line 577 (this eventually did the trick…)
line577 $search = " and (Title rlike '$q' or Body rlike '$q' or Category1 rlike '$q') $s_filter";
Now search includes the first category name. In effect, a search for cars returns also all articles from the category funnycars.
I hope this is of any use to anybody.
Last edited by ooz (2007-07-29 06:51:06)
“Habit is probably the greatest obstacle of perceiving truth.” R.A. Schwaller de Lubitz
Offline
#3 2007-07-29 09:49:09
- ooz
- Member
- From: Finland
- Registered: 2007-07-27
- Posts: 14
Re: Search issues / search doesn't include category names?
After this exiting learning episode this was a logic follow-up…
Suppose you use a section just for extracting articles to be displayed as for example “product news” or “used items” but don’t have any category with those names (of course not, since cars and books are not the same in nature) or an occurrence of the same expression included in the content, you might want to know…
How to include section-names in the search (-queries) without changing the script:
Post an article into the section with exactly the same name as the section in question. You should then keep this article from rendering (not by changing its status but) by filtering either itself or all others by using the <txp:if_custom_field>
-tag.
At this point I use the same page-template for both sections “books” and “new items” where all book-items belong to the section “books”. I use the other section for rendering a list of new books in a different way compared to all other books by using the <txp:if_section>
-tag in the page-template for books.
To determine whether an item is new, I use a custom_field
like for example “new?” and filter it in a special form launched in the if_section
part of the template. This “new-items-list” -form just checks the custom status with <txp:if_custom_field name="new?" />
and render or not.
Excerpt from page-template:
<txp:if_section name="new_items">
<h3>New items:</h3>
<txp:article_custom form="new_items_list" />
</txp:if_section>
Excerpt from the new-items-list-form:
<txp:if_custom_field name="new?">
<txp:output_form form="article_list" />
</txp:if_custom_field>
ps: this post might actually belong into the How-Do-I-section, anyone who would like to move it?
Last edited by ooz (2007-07-29 09:58:45)
“Habit is probably the greatest obstacle of perceiving truth.” R.A. Schwaller de Lubitz
Offline