Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Nifty problem with subcategory.html ...

Quote Reply
Nifty problem with subcategory.html ...
Hi,

is there any chance to get this template modified in any form like this:

<%if its the first category%>
start table with css-border on top in black
<%endif%>

<%if its the last category%>
end table with css-border on bottom
<%endif%>

Thanks for hints!

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Check this.
http://gossamer-threads.com/p/125631

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Let me see, if i understand this - could i use anything like this:

<%if first%>
.... class="firstborder" ...
<%endif%>
<%if last%>
.... class="lastborder" ...
<%endif%>

Would this work?

Thanks again for hints!

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Yup, I think you can. You can use pagi.cgi to test it to verify.Smile

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Hi,

i've tried this in a simple form like this:

<%if first%>
<b>first entry</b>
<%endif%>
<%if last%>
<b>last entry</b>
<%endif%>

and page.cgi as also the static pages are showing nothing ... what i'm doing wrong?

Thanks

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
I think you need to put it inside a loop, check the link I provide again.

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Hi,

No, unfortunately not. If I had rewritten the code to use loops (which would require everyone updating templates) it would be possible, but as is, there is no loops.

The only way to accomplish what you want is to edit site_html_print_cat in Links/SiteHTML.pm or to use a plugin.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
OOps, is it I that misunderstood the description?
In Reply To:
5. Loop support! This is the big one.

<%loop link_results%>
<p> <%include link.html%>
<%endloop%>

would go through your link results, and print <P> followed by the link.html template. Also, inside your loop you have the following tags automatically available:

<%row_num%> - a counter for what row is being looped, starts at 1.
<%first%> - boolean that is true if this is the first row, false otherwise.
<%last%> - boolean that is true if this is the last row, false otherwise.
<%inner%> - boolean that is true if this is not first and not last.
<%even%> - boolean is true if row_num is even.
<%odd%> - boolean is true if row_num is odd.

You can use even and odd tags to produce alternating colors like:

<%loop results%>
<tr><td bgcolor="<%if even%>#FFFFFF<%else%>#000000<%endif%>">..</td></tr>
<%endloop%>
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Hi,

No, I just wasn't very clear. The template parser supports loops, however, Links SQL does not use them. The only time you would use loops is in custom code.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Alex,

>> No, unfortunately not. If I had rewritten the code to use loops (which would
>> require everyone updating templates) it would be possible, but as is, there
>> is no loops.

>> The only way to accomplish what you want is to edit site_html_print_cat in
>> Links/SiteHTML.pm or to use a plugin.

If that is a BETTER way, then the time is now to make the change! The first time people switch over, is the best time to put those sort of changes in.

Don't let legacy code hold you back! Template changes should be minimal, no matter what they are.


PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Hi,

The template changes would be more then minimal though. It would mean changing category.html from:

<%links%>

to:

<%loop links%>
<%include link.html%>
<%endloop%>

However, that makes things easier for people as you could then do:

<table>
<%loop links%>
<%if first%>
first row
<%endif%>
<%include link.html%>
<%endloop%>
</table>

Or use other tags like last, even, odd, etc.

I'll look into this..

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Can Alex or GT give us a new and full category.html here so we can choose what we want and check how we can do?

Thanks.

Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Alex,

This is still pretty minimal ie:

Code:
<%links%>

to:

<%loop links%>
<%include link.html%>
<%endloop%>
If people just have to replace a <%links%> tag with a new tag set, that is pretty easy!

Even complicated templates require only a minimal amount of work to do this.


I'm glad to see that all it would be is changing the main <%nnnnn%> to a set of loop tags.

The sacrifice of having to update your 8 or 9 templates that might use <%links%> or <%categories%> would then be far outweighed by the benefits!

People already have to change the search templates upgrading from 2.0 to 2.0 (term/query/etc). That is much more complicated overall.

Please, please don't get caught in the desire not to change something simple like <%links%> to <%loop links%><%include link.html%><%endloop%> if the trade off in performance is worth it. People will do that, and there is no reason to hold the development back.

The changes I suggested with the table prefix in front of the variables would be much more extensive, and would probably require a conversion program that presented the user with a list of new tags on the left, old tags on the right, and allowed them to change things if they needed to, then just did a search/replace on the template directories. It wouldn't be 100% perfect, but it would probably catch 99% of the tag changes, except those found in an <%if %> or <%loop %> clause. The search/replace program could compile a list of line #'s and files where it found those tags, so the user could change those they needed to, but all in all, even a major tag change wouldn't be impossible.

At some point, though, as the amount of linked data increases, the odds of two tables having the same field names increases. If the major tables used standard prefixes in front of the fields, then this would prevent crunching.

If you notice, w3t has updated their tables to use w3t_ in front of the table names, and a table prefix in front of each field in each table. This goes a long way to large, cooperative databases and programs. By adjusting the field names, you also require a one-time conversion process, but you get rid of large amounts of overhead in stripping/adding the prefix to the variables.

Again, now is a good time to start thinking about this!

Database use will only INCREASE over time, and the more you do to insulate Links' own tables, the better it will integrate into a larger site, and the more advantages it will have over other programs.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
I couldn't have said it better myself. Wink


Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Quote Reply
Re: Nifty problem with subcategory.html ... In reply to
Is there any progress on pugdog's suggestion? Or jsut let us know how to modify the script to use loop if it won't go into the main distribution.