Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

links display on 3 columns

Quote Reply
links display on 3 columns
Hi all ,

I would like to be able to have the links display on 3 columns.

Example . .

Link1 | Link2 | Link3


Could you please help me out.


Thanks.

Quote Reply
Re: links display on 3 columns In reply to
any help ? :(

Quote Reply
Re: [rak] links display on 3 columns In reply to
can we do this with <loop> tag ?

Link1 | Link2 | Link3
Link4 | Link5 | Link6
Link7 | Link8 | Link9

more >

??[blush]
Quote Reply
Re: [rak] links display on 3 columns In reply to
Code:
<%loop link_results%>

<%if first%> <%-- set up the opening table --%>
<TABLE>
<TR>
<%endif%>

<TD>
<%include link.html%>
</TD>

<%ifnot row_num % 3%> <%-- close the row --%>
</TR>
<%endif%>

<%if last%> <%-- close the table --%>

<%if row_num % 3 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>

<%if row_num % 3 eq 2 %> <%-- balance the trailing rows --%>
<TD></TD>
<%endif%>

</tr>
</TABLE>
<%endif%>

<%endloop%>


The idea is there, but it might need some tweaking. Also, I don't know if the complex 'if' will work, if it doesn't, maybe Alex has a suggestion for getting around it.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Sep 13, 2001, 9:30 PM
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
Hi pugdog

What would be the Global that would go with the 3-column-links code that you mentioned above?

I'm starting to get the hang of this stuff, but when I put in your code, all I got was another single column of links.

Thanks for your help.Smile

DT
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
I couldn't edit my previous note. So, I had to add another.

I did a <%GT::Template::dump%> to view all tags available on my category.html page.

For link_results, I got the following in the dump:

Code:
$VAR = 'CODE(0x85c64f4)';

Also, I plugged in an attempt at a global for link_results which looks like this:

Code:
sub {
my $vals = shift;
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY Hits DESC');
my $sth = $link_db->select;
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}

Within the loop, even if I use:

Code:
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><b><%Title%></b></a><BR>
<%if Description%>
<%Description%><BR>
<%endif%>

instead of:

Code:
<%include link.html%>

I still get the full link.html stuff, but no 3 columns.

Any suggestions would be tons appreciated.SmileSmile

DT
Quote Reply
Re: [DogTags] links display on 3 columns In reply to
Just sending it to the top...

Thanks Smile

DT
Quote Reply
Re: [DogTags] links display on 3 columns In reply to
This should all be done in the template.

I have not tried it out, but it's a form of nested loops. If you are not using the 'link.html' file, you shouldn't see the complete results. That might indicate you are parsing the wrong file (links is looking in the wrong place for the template?) or you are bypassing this block of code, and executing another.

I'm still trying to set up a couple of development sites to be able to test these problems out on, but have not been able to do much in the past few days at all.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [rak] links display on 3 columns In reply to
Hi,
I was looking through this as I too would like 3 columns instead of 2.
I am just wondering did anybody get 3 columns to work? afterward ......... or is it possible,

Thanks
$loth
Quote Reply
Re: [$loth] links display on 3 columns In reply to
Flotation...

DogTags Cool
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
I got this to work by changing:

<%loop link_results%>

to:

<%loop links_loop%>

I'm using Links SQL 2.05. I'm not sure if this makes a difference.

Here it is for 2 cols. The default seems to be 1 col.

<!--BEGIN 2-COL LINK LOOP-->
BEGIN 2-COL LINKS<BR>
<%loop links_loop%>
<%if first%> <%-- set up the opening table --%>
<TABLE width="70%">
<TR>
<%endif%>
<TD>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><b><%Title%></b></a><BR>
<%if Description%>
Description: <%Description%><BR>
<%endif%>
</TD>
<%ifnot row_num % 2%> <%-- close the row --%>
</TR>
<%endif%>

<%if last%> <%-- close the table --%>

<%if row_num % 2 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>
</tr>
</TABLE>
<%endif%>

<%endloop%>
<BR>
END 2-COL LINKS
<!--END 2-COL LINK LOOP-->

Thanks for this nice code, pugdog!!

DogTags

Last edited by:

DogTags: Oct 28, 2001, 5:20 AM
Quote Reply
Re: [DogTags] links display on 3 columns In reply to
Code:
<%loop link_results%>

to:

<%loop links_loop%>

<G> ... that was a change in Links 2.05 .... one of the many subtle ones I still have not integrated into my brain.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
Oi,
Thanks for the code, it looks great.
A little wierdness in Internet Explorer for Macs, though.
I can't figure it out. The tables gets all cattywampus.
see?
http://www.ecko.com/links/hip_hop/index.html
I believe that after the first row there are no more <tr> tags, only </tr>
but It works fine in Netscape and on PC's so ...hmmm

I'm a novice in this game and If I'm talking blahblah please feel free to let me know.
Thanks for all your help.

Move



Quote Reply
Re: [move] links display on 3 columns In reply to
Hi

The table code provided by pugdog is totally bare. You could put some numbers in there and most likely solve all the browser probs. Try using hard numbers rather than percentages to start.

HTH Smile

DogTags
Quote Reply
Re: [DogTags] links display on 3 columns In reply to
hi,

can anyone tell me how to modify this code so it displays links in 3 columns?

thanks
regan.

ps: great solution!


EDIT: Don't worry figured it out - just replace the number 2 with 3 and it does everything else! Smile

Last edited by:

ryel01: Jun 13, 2002, 8:41 PM
Quote Reply
Re: [ryel01] links display on 3 columns In reply to
 
I was wrong - it doesn't work just by changing it to a 3.

Did anyone ever manage to get this working with 3 colums of links? It all seems to work ok until...


Code:
<%if row_num % 3 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>

<%if row_num % 3 eq 2 %> <%-- balance the trailing rows --%>
<TD></TD>
<%endif%>


at which point it goes haywire. The code doesn't seem to be sure how many empty or fill in colums it's supposed to be building.

anyone?

cheers,
regan.

Last edited by:

ryel01: Jun 14, 2002, 7:29 AM
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
Hi Pugdog,

This code is GREAT!! It is exactly what I needed. But how I can make the links go the other way?

Example:

Link1 | Link4 | Link7
Link2 | Link5 | Link8
Link3 | Link6 | Link9

Thanks in advance,

Eddie
Quote Reply
Re: [eddie123] links display on 3 columns In reply to
I used this code below, and if there are no links in a category, the rest of my page does not show except there is a link in the category, how do I avoid this?



<%loop links_loop%>
<%if first%> <%-- set up the opening table --%>
<TABLE width="70%">
<TR>
<%endif%>
<TD>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><b><%Title%></b></a><BR>
<%if Description%>
Description: <%Description%><BR>
<%endif%>
</TD>
<%ifnot row_num % 2%> <%-- close the row --%>
</TR>
<%endif%>

<%if last%> <%-- close the table --%>

<%if row_num % 2 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>
</tr>
</TABLE>
<%endif%>

<%endloop%>
<BR>
END 2-COL LINKS
<!--END 2-COL LINK LOOP-->
Quote Reply
Re: [Abusaki] links display on 3 columns In reply to
This thread was started in 2001, and was set up for Links 2.x, not GLinks 3.x.

The code will *not* work properly with the Luna template set.

Just thought I'd mention that.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
Thanks Pup dog,
Is there anyway I can have the Glinks in 3 columns
Dorette
Post deleted by qes In reply to
Quote Reply
Re: [pugdog] links display on 3 columns In reply to
In Reply To:
The code will *not* work properly with the Luna template set.

Why not? I set this up with the Luna template set for 5 columns and it seems to be working fine. Am I missing something? There are some errors in the original HTML above (missing <tr> tag, too many columns to balance the trailing row) but after fixing that it seems to work just fine. Tables generated with this validates OK. Here's my working code (for 5 columns)

Code:
<%if first%> <%-- set up the opening table --%>
<table class="pctable">
<tr>
<%endif%>
<td valign="bottom">

<%Title%>

</td>
<%ifnot row_num % 5%> <%-- close the row --%>
</tr>
<tr>
<%endif%>

<%if last%> <%-- close the table --%>

<%if row_num % 5 eq 4%> <%-- balance the trailing rows --%>
<td></td>
<%elsif row_num % 5 eq 3%> <%-- balance the trailing rows --%>
<td></td><td></td>
<%elsif row_num % 5 eq 2%> <%-- balance the trailing rows --%>
<td></td><td></td><td></td>
<%elsif row_num % 5 eq 1%> <%-- balance the trailing rows --%>
<td></td><td></td><td></td><td></td>
<%endif%>
</tr>
</table>
<%endif%>

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] links display on 3 columns In reply to
As I said, <G> It had to be fixed up to work.

But for some people using tables within a CSS document is not the way to go.
The code is also not CSS compliant, and won't change with changes to the css.

So, there are still a bunch of issues, but for most people, probably, it will work
well enough they won't notice.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.