Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to have a "dynamic" table width?

Quote Reply
How to have a "dynamic" table width?
Hi!

After having LinksSQL set up, that it is displaying images, I need a mod that belongs to this.

We're going to have 2 different sizes of thumbs and therefore it's needed to have the cell,

where the thumb is displayed has a width, that belongs to the thumb.

In link.html I have

<td width="160"><div align="center"><img src="....../links/thumbs/<%file_name%>" border="1"></div></td>

and I'd like to have something like

<td width="<%thumb_width%>"><div align="center"><img src="....../links/thumbs/<%file_name%>" border="1"></div></td>

And when I'm adding a new link, there should be a Pulldown menu where I can select thumb_width 1 or 2.



What do I have to do? Adding a new global, where the sizes of thumb_width1 and 2 are specified? And adding a new

colum for the "add links" for it?

Any ideas? Wink



sun
Quote Reply
Re: [sun112] How to have a "dynamic" table width? In reply to
Solved by myself. Cool

Wasn't as complicated as I thought.



sun
Quote Reply
Re: [sun112] How to have a "dynamic" table width? In reply to
Just so people know how you would do this, all you need is a couple more fields in your lsql_Links table. Something like image_width and image_height, then in your templates, just use something like;

<img src=<%image%> <%if image_width%>width=<%image_width%><%endif%> <%if image_height%>width=<%image_height%><%endif%>

You could do some more complicated stuff, like using Image::Size to grab the size of the image, and then dynamically getting its dimensions, but the above is the easiest method Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to have a "dynamic" table width? In reply to
I've done it this way:

I added a new colum in links ( Links: Table Editor )

Column Name: isStandardsize

Column Type: ENUM

Column Index: Regular

Column Values: Yes No

Not Null: Yes

Default: Yes

Form Display: isStandardsize

Form Type: Select

Form Names and Form Values: Yes No

With this column I've a new field called isStandardsize when I add new links, which is automatically set to Yes.



Now I modified the link.html like this:

<%if isStandardsize eq 'Yes'%>
<td width="110"><div align="center"><img src="............/links/thumbs/<%file_name%>" border="1"></div></td>
<%else%>
<td width="160"><div align="center"><img src="............/links/thumbs/<%file_name%>" border="1"></div></td>
<%endif%>

That means, when isStandardsize is Yes, size is set to 110. If set to No, size is 160.

sun