Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need more control over search results.

Quote Reply
Need more control over search results.
I think a template should be created so it is easier to further customize search results. The Search_results template is handy, but it doesn't do a person any good if they want to change the look of the <%link_results%>.

Right now the only way to fix this is by going in and altering the search.cgi file, which is a real pain. An extra template for this would be much easier (sort of like the sub-category template), especially when upgrading the search.cgi file will cause you to have to figure out the changes you made all over again to the new file.



Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
Hi,

<%link_results%> is simply a concatenation of link.html templates, or are you wanting to put something in between?

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Need more control over search results. In reply to
Hi Alex:

That is exactly what I want. Right now if I want to change the spacing of <%link_results%>, the only way to do that is to go in and manually edit search.cgi.

As an example, the default <%link_results%> might look something like this:

Home : Art and Culture : Art History
- Art History at Loggia
- Art History Research Centre

Home : Art and Culture : Art Therapy
- American Art Therapy Association, Inc.
- Art Therapy Research
- Art Therapy on the Web
- ArtForce1
- Marty Levenson's Art Therapy Website

etc.

If I want to add a carriage return to separate the category from the links, maybe an extra carriage return to separate the links from the next category, maybe I might want to bold the category title, or any other minor modification, the only way to do that is to go in and edit search.cgi.

Having to do this is definitely a pain, it would be much easier to have a template that could be used to format the <%link_results%>.


Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
The link_results are obtained from a combination of the link.html file, which formats the individual links, and the build_link subroutine in the Site_HTML.pm file.

You don't need another template, you just need to change how the calling subroutine calls the link.html template if you want to make these sorts of changes.

In build_category, this section of code grabs the links:

# Get the links
$offset = ($opts->{nh} - 1) * $opts->{mh};
$catlink_db->select_options ("ORDER BY $CFG->{build_sort_order_category}", "LIMIT $offset, $opts->{mh}");
$sth = $catlink_db->select ( { CategoryID => $category->{ID}, isValidated => 'Yes' }, [ 'Links.*' ] );
$display{total} = $numlinks = $catlink_db->hits;

while ($link = $sth->fetchrow_hashref) {
$display{links} .= Links::SiteHTML::display ('link', $link);
}

You have to try to figure out the process of how the page is built. The page is built in chunks or blocks, that are strung together to make the whole page. Smaller blocks are put together to make large ones -- such as link.html being used to generate <%link_results%>

Once you grasp how the data is being built, you can make the changes to customize it more exactly.

The program will currently handle 95% of the customizations people want in an easy fashion. Some are more complex, and need to be done at higher levels than just the template.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Need more control over search results. In reply to
I understand how the build process works, this isn't the problem. In my opinion, it is much easier to go in and make modifications to the search.cgi file, all of the code for formatting <%link_results%> is pretty much already there, it just has to be tweaked. If I were to do this by making modifications to Site_HTML.pm, the changes would be more complex and I would have to have a much better scripting knowledge.

Following are the two sections of code from search.cgi that I had to modify to format <%link_results%> to my liking:

--------
# Now format the category results.
my $count = 0;
my ($category_results);
if (!$filter and $cat_count) {
while (my $cat = $cat_sth->fetchrow_hashref) {
last if ($count++ > $mh);
$category_results .= "<li>" . Links::Build::build ('title_linked', { name => $cat->{Full_Name}, complete => 1 }) . "\n";
}
}
---------
# Join the link results by category if we are grouping.
if ($CFG->{build_search_gb}) {
foreach my $cat (sort keys %link_output) {
$link_results .= "<p>" . Links::Build::build ('title_linked', { name => $cat, complete => 1 }) . "

" . $link_output{$cat} . "

";
}
}
else {
$link_results = $link_output{none};
}
--------

My point is "not" that I don't understand how the whole process works. My point is that I don't see how formatting <%link_results%> is any different from formatting the search results, formatting links or formatting categories. These are all cosmetics for the search engine, there are templates for everything else, why not offer templates for <%link_results%>?

Without a template for this, anyone that wants to change <%link_results%> has to have at least a decent scripting knowledge, and if they ever want to upgrade their files, they will have to do it all over again, which is a real pain since the upgraded scripts frequently change.

It is my impression that the entire reason for templates is to help out people with little scripting knowledge and to help make upgrading a snap. <%link_results%> is a pretty basic part of the search engine that I think people would like to be able to easily customize, so why not offer a template for that? As things are right now, if someone doesn't understand exactly how <%link_results%> works, they will have a heck of a time trying to customize it.


Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
I'm not sure what you are driving at.

_ALL_ link formatting goes through link.html

There are different page layouts for different reasons. Search is handled a little differently to allow people to chose to group searches by "topic" or "category" not pure-link order.

<%link_results%> is just what the script or scripts send out to the template to insert. You can change that anywhere in any of the scripts.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Need more control over search results. In reply to
>> _ALL_ link formatting goes through link.html <<

I don't want to change the look of the individual links, I never said that I did. Like I mentioned earlier, I want to change the format/display of <%link_results%>, which is a concatenation of the individual links. If I make a change to link.html, it will affect each individual link but this only indirectly affects <%link_results%>. If I want to make a change to the "group" of links that is presented in <%link_results%>, editing link.html will not accomplish this.

>> <%link_results%> is just what the script or scripts send out to the template to insert. You can change that anywhere in any of the scripts. <<

Like I mentioned earlier, I understand exactly what <%link_results%> is, and I understand how to change it by editing the scripts. I actually already have everything working exactly how I would like it to at my site.

What I "don't" understand is how a scripting pro such as yourself doesn't see the logic in creating a template for <%link_results%> to make it easier for amateurs to format <%link_results%> and also to facilitate easier upgrades to later versions of the software. The entire point of the templates is to make things easier.

>> There are different page layouts for different reasons. Search is handled a little differently to allow people to chose to group searches by "topic" or "category" not pure-link order. <<

This statement only strengthens my argument. People want to be able to easily customize their search results, a <%link_results%> template would help greatly to simplify the process. As I mentioned before, none of the scripts have to be edited for category or link cosmetics, so why should it be necessary to format <%link_results%>? In previous versions of the script, if you wanted to change the look of sub-categories, you had to do this by editing one of the script files. Now that there is the subcategory template, the process is MUCH easier! Why not do the same for <%link_results%>? The idea is the same.

Put yourself in the shoes of an amateur for a moment and maybe you will get my point. =)


Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
In Reply To:
What I "don't" understand is how a scripting pro such as yourself doesn't see the logic in creating a template for <%link_results%> to make it easier for amateurs to format <%link_results%> and also to facilitate easier upgrades to later versions of the software. The entire point of the templates is to make things easier.
Maybe because I don't see what this is all about.

<%link_results%> is _JUST_ the collection of link.html iterations. It doesn't have any formatting in it.

If you want <%link_results%> to be a list, your link_html should start with a <LI> tag, and be an "item" that is then inserted between <UL><%link_results%></UL> tags.

If you want each link to be a table row, you start with a <TR> and end with a </TR> and you put link_results between <TR><%link_results%></TR>

What other "link_results" would you format??

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Need more control over search results. In reply to
>> <%link_results%> is _JUST_ the collection of link.html iterations. It doesn't have any formatting in it. <<

If this is true, then explain to me exactly how it is determined how many carriage returns should be made after a subcategory link and before each collection of links in that subcategory? What happens if I want to have the sub-category link bolded or italicised? Formatting. None of this can be done using variations of the suggestions you just provided. Your formatting suggestions will affect <%link_results%> as a group, but they do not affect specific parts of that group, such as how the subcategories are presented in relation to the links.

If <%link_results%> is _JUST_ a collection of link.html iterations, then a template should be required to determine exactly how these "iterations" and sub-categories should be presented. This is all that I am getting at, and I don't understand why you don't understand this. =P



Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
When everything is finally abstracted out, that line of code will be part of an HTML file, most likely.

First, I don't use the category groupings, because searches should be by relevancy, not categories -- where the most relevant category or link could be the last one presented. This was the first thing I removed from Links 2, and the first thing I worked around in Links SQL.

Second, adding another template for what is a single line of code, may help in data abstraction, but it would incur a performance hit. Since the "formatting" is actually part of what "search.cgi" is doing, ie: presenting the "found" links by category, editing the line of HTML in that file is _not_ unreasonable, or bad form.

Yes, it would be nicer to have all this embedded html in one place, and it eventually will be, but this is _not_ a "links results" formatting or template, which is what I couldn't understand.

There is no way to embed this in the current logic, since each "block" has to be a fully encapsulated block.

You would need to _alternate_ the sub-category name template with the link.html template.

You could do this yourself, actually, if it's that important, but you would incurr a performance hit for that one line that is probably not worth it in the larger scheme of things.

90% of what would need to be done could be set with a <FONT> and a prefix/postfix tag set, where they are set as global configuration options. Beyond that, anything would really be "custom" programming, and editing a single line of HTML in the .cgi file is _still_ the most "cost effective" solution.

This is why I had no idea what you were referring ot.





PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Need more control over search results. In reply to
I honestly don't care about the logic behind everything, I am just suggesting a method that could be used to make the formatting of search results "much" easier. If it can be done, great, if it can't or won't be done, oh well, I guess I will have to live with it.

You are right, a template that would format the link results would be simple, and that is entirely the point. Here is what I would think an average link results template might look like:

<b><%subcategory%></b>
<break><break> (standard code doesn't show)
<%links%>
<break><break><break>

Very simple, but any "amateur" currently using the program would have a hard time producing these formatting options without a template. Contrary to what you say, this does not "just" consist of editing a single line in a .cgi file. First the person has to know which file to actually edit, then they have to track down which line(s) of code will affect the formatting. In my case, I did have to modify multiple lines of code. Many amateurs won't know how to do this.

I think Alex partly implemented templates to appeal to a larger audience, people who don't have as much scripting knowledge. On that thought, why bother creating templates unless you have a template for "everything"? If you don't, you are just going to get more and more amateurs coming to this forum, asking how to format the search results, getting an answer, and then saying, "huh?". Why put yourself through that torture? =P

Obviously a template would be of little use to you since you don't use category goupings, but that doesn't mean it wouldn't be useful for someone else.

Forget about all of your programming/scripting knowledge and put yourself in someone else's shoes. If Alex really wants this program to sell like hotcakes, he would make it easy enough to use that just about any average Joe could install, customize and run the script with very little support.



Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com
Quote Reply
Re: Need more control over search results. In reply to
Hi,

I see your point, but the more templates you add, the more difficult it becomes for the end user, especially when trying to make changes.

This sort of thing will be added in once we get loop support inside of templates. We've been toying with something like:

<%loop results%>
...
<%endloop%>

However, this will probably not be in the final version.

Cheers,

Alex

--
Gossamer Threads Inc.