Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Minor Featured Mod update

Quote Reply
Minor Featured Mod update
http://run-down.com/...s_sql_featured.shtml

Inconsequential tweak to most people: I changed the Featured field from Yes|No to 1|0. I decided to add an image next to featured sites, and realized this doesn't work too well with the Yes|No field. 370 links later...

Is there a reason why something like

<%if isPopular%>

works, but

<%if isFeatured%>

doesn't when both have Yes|No values? I read something in the forums about "No" still being a value (I think by Pugdog), but why is that not the case for the built in fields?

Dan

Quote Reply
Re: Minor Featured Mod update In reply to
Yes, this little code in site_html_link handles the isPopular, isNew and isChanged:

Code:
# Set new and pop to either 1 or undef for templates.
($rec->{'isNew'} eq 'Yes') ? ($rec->{'isNew'} = 1) : (delete $rec->{'isNew'});
($rec->{'isChanged'} eq 'Yes') ? ($rec->{'isChanged'} = 1) : (delete $rec->{'isChanged'});
($rec->{'isPopular'} eq 'Yes') ? ($rec->{'isPopular'} = 1) : (delete $rec->{'isPopular'});
takes care of the fields.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Minor Featured Mod update In reply to
Sheesh, now I'm wishing I didn't ask... At least I got to listen to lots of music while resetting the featured links.

Thanks,
Dan

Quote Reply
Re: Minor Featured Mod update In reply to
For the record, you could issue the SQL command in the SQL monitor or in the MysqlMan program:

Code:
UPDATE Links
SET isFeatured = '1' WHERE isFeatured = 'Yes';

UPDATE Links
SET isFeatured = '0' WHERE isFeatured = 'No';
.
Actually, all Alex's code did was change the values of the fields once a link was selected. You'll see that code in the program already. You just need to apply it to the 'isFeatured' field as well.

Maybe the template parser is more intelligent in the next release, and will allow things like "No=0" and "Yes=1" to be set as a flag -- yn_boolean=[1|0] in which case Yes/No and yes/no would be treated as 1/0 not as text in an 'if' test.

You do realize, too, that you could have changed the template to:

<%if isFeatured = "Yes"%>

<G>

Many ways to make a hamburger




http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Minor Featured Mod update In reply to
Thanks, I thought there would be a way of changing it through the SQL monitor. Is it possible to change the field type from CHAR to INT (possibly through the def file)? It didn't appear to be, so I wiped out the isFeatured field and started from scratch, using my featured.txt file for the list of ID's to recreate from...

<%if isFeatured = "Yes"%>

I believe I tried that with and without the quotes, and it didn't work. If I remember correctly, both Yes and No values were coming through as a positive result. That doesn't seem right, but I'm pretty sure it is what happened. Hmm.

Dan

Quote Reply
Re: Minor Featured Mod update In reply to
Myabe you needed to use single quotes? I know I've done it to avoid the same situation you got into (changing all the fields).

You can "ALTER" table from the sql monitor, and do just about anything to the table and fields you want.

By far, the easiest way is to use MySQLMan or phpMyAdmin.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Minor Featured Mod update In reply to
As I recall from playing with the isNew settings, > and < calculations worked but = did not. That's why I thought reverting to numerical settings for isFeatured would be wise. It wasn't until I killed the field that I realized how much work I had just gotten myself into... Fortunately, my featured list isn't anything anyone's going to lose sleep over their site not being included for a couple of days.

My comfort level with monkeying around in MySQL is pretty low still. However, I just ordered the book MySQL (and Mastering Regular Expressions, a Perl book, and a few graphics books, so I'll be up to my eyeballs in reading material for awhile) and am setting up a mini home network to play around with this stuff more and hopefully get to where I feel comfortable working more under the hood. If nothing else, I might at least have a clue what you're talking about half the time. Wink

Dan

Quote Reply
Re: Minor Featured Mod update In reply to
>> If nothing else, I might at least have a clue what
>> you're talking about half the time

Great! That will make one of us! <G>

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Minor Featured Mod update In reply to
Now I know why it's not always such an easy task...

Dan