Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Templates with Loops

Quote Reply
Templates with Loops
I want to make my templates use the loops on the pages where there are loops (home, category, etc etc). I do not want to use any of the "category", "links" etc tags. (I am familiar with the workings of GForum, where loops are used all the time, there are almost no "fully-formatted" tags).

Here are a few questions related to this:

1) Has anyone made a complete template set using only loops?

2) If yes, were you able to do that with the tags available on a page, or did you have to use PRE hooks to supply some additional tags? Or were you using your own functions? (e.g. in a category_loop to decide when to start a new <td> element)

3) The "category_loop" in category pages is supposed to contain the information about the subcategories. However I noted that if there are no subcats, then the loop still contains one element, namely the data of the current category. Is that a bug, or is there a reason behind this?
4) Are there disadvantages of using loops?

Thanks a lot for you answers.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Templates with Loops In reply to
Hi,

1. Not that I know of.

3. This is a bug. To fix, have a look at the attached patch. Can you let me know if it works for you?

4. The only disadvantadge is in performance. It takes a bit longer to run through a loop then to use the tag. Not an issue if you are building static pages though.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Templates with Loops In reply to
Thanks for your answer, Alex.

I patched the Build.pm file (even though 'patch < diff.txt' failed, I had to do it manually).

I will start doing the loop templates, and I will be using only static pages anyway, so performance is not an issue.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Templates with Loops In reply to
>>(even though 'patch < diff.txt' failed, I had to do it manually).<<

I don't think diff.txt was a patch...it was a changelog
Quote Reply
Re: [Alex] Templates with Loops In reply to
By the way: it would be very handy if the number of elements in the loops (category_loop, related_loop etc) could also be a standard template variable (for now, I will just set the ones I need manually in a PRE hook). And maybe it would also make sense to include "build_category_columns" as a tag on the category pages. Then all you need to build the subcategory layout is a function/global that tells you if you have to go to the next <td> element in a category table, of the sort:

Code:
sub break_here {
# -------------------------------------------------------------------
# a function that calculates whether we have to start a new <td>
# in a loop that goes over several <td>s. Can be used from a template.
# returns 1 or 0

my $total = shift;
my $cols = shift;
my $current = shift;

my $breakpoint = int ($total / $cols) + ( ($total % $cols) ? 1 : 0);
return !($current % $breakpoint) ? 1 : 0;

}

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Paul] Templates with Loops In reply to
Yes, Paul. It is a changelog file, but the most perfect name is: difference file. It is generated by an RCS software (Revision Control System).

I personally use CSRCS (ComponentSoftware Revision Control System) for Windows, but it is also available for UNIX, named as GNU RCS.
It seems, Alex also uses CSRCS in his developments, like me.

The diff.txt is in the common GNU DIFF text format.
I suppose, the patch will only work if you use GNU patch on it. CSDiff should be compatible with 5.7 GNU RCS.
I suppose, the diff.txt file was written using CSDiff, so you may be read with ComponentSoftware Diff (CSDiff) stand-alone product.
Note: For more details, visit the CSDiff home
http://www.ComponentSoftware.com/csdiff/
(For more information on CSDiff, select Help Topics from the Help menu. )

You can find Unix GNU RCS tools here:
ftp://ftp.leo.org/...ols/gnu/rcs57pc1.zip

You can find ComponentSoftware RCS for Windows here:
http://www.ComponentSoftware.com/
(the standard edition of ComponentSoftware RCS is free for personal use)

Just For Your Info.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...