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

Featured Site mod help

(Page 1 of 2)
> >
Quote Reply
Featured Site mod help
Hi,

I'm thinking of adding a subroutine to make Links SQL automate the maintenance of my "Featured Site" page. Previously, I was entering sites that link back to my site in a text file -- one link per line -- which would then randomly be selected by a cgi script and included in the HTML page. When upgrading to Links SQL, I realized that my method of using the jump.cgi link was a problem, as the Links SQL import compresses the link numbering... I went through and changed them to their actual URL's for the time being.

What I would like to do is add a field to the database, isFeatured. This would default to No and could be flagged as Yes, if appropriate. A subroutine would then be added to nph-build.cgi, which would assemble the text file mentioned above. Here's where I could use some help, as I don't think my Perl/SQL skills are quite up to putting it together.

I believe the shell of the sub would look like this:
Code:
if ($isFeatured == "Yes") {
$OUT = "<a target=\"_blank\" href=\"<%db_cgi_url%>/jump.cgi?ID=<%ID%>\"><%Title%></a> <%Description%><BR><BR>";
}

$file = "/path/to/featured.txt";
open (FEATURED, $file) or die "Can't open $file Reason: $!";
print FEATURED (\%OUT);
close FEATURED;
Do <%ID%>, <%Title%>, and <%Description%> need to be declared for this to work, and do quotes need to be escaped? Am I even on the right track as to how to write to the file? Also, I'm sure more needs to be done in terms of checking the isFeatured field.

Any help would be greatly appreciated in getting me started. Also, if you can think of better ways I should be approaching this, I am open to suggestions.

Thanks,
Dan

------------------
Run-Down -> Links SQL
http://run-down.com/
Quote Reply
Re: Featured Site mod help In reply to
Dan,

To do what you want to, as far as declaring the variables, it depends on what sub you add it to...unless you wanted an entirely separate one. In which case it might look something like this:
Code:
sub is_featured {
my($featured_r, $sth);

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
if ($sth->rows) {
$featured_r = $sth->fetchall_arrayref();
}
%OUT = (); # Start with a clean hash.
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
$OUT{anyothers} = $featured_r->{'anyothers'};
$OUT{anyothers2} = $featured_r->{'anyothers2'};
$OUT{etc} = $featured_r->{'etc'};

# The best way to do this is to add a sub
# into HTML_Templates to format it's output
# copy & paste any routine and just change file it
# reads as it's template.

open(FEATURE, "$file");
print FEATURE &site_featured_template(\%OUT);
close(FEATURE);
}

The use of $OUT{field_name} is used to put fieldname=value into an array (or a hash, they got me confused but I'm getting there) called %OUT that is then passed to a template. The code isn't perfect but this would be the basics...I hope that helps a little Wink

Well I wasn't going to put in the template stuff but I may as well, add something like this into HTML_Templates:

Code:
sub site_featured_template {
# --------------------------------------------------------

my ($tags, $dynamic) = @_;
my $template = defined $dynamic ? $dynamic->param('t') : undef;
(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";

defined $dynamic and &load_user ($dynamic, $tags);
my $output = &load_template ('featured_sites.html', {
%$tags,
%GLOBALS
}, undef, $template);
defined $dynamic and &clean_output($dynamic, \$output);
return $output;
}

Now important part is to add this sub into the @EXPORT = qw/ &site_featured_template .../ at the beginning of your HTML_Templates.pm file...

Then make a new template file called featured_sites.html, et Voila

[This message has been edited by phoule (edited March 13, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
Wow, thank you very much for taking the time to write that out!

I was wondering if it needs to be passed to HTML_Templates.pm, as I was merely going to build a text file each day, not build a page from a template like the other sections. I'm a little unclear on how that works.

Also, I had intended on making it a separate sub, as you guessed correctly. No reason that I can think of to clutter one of the other subs, except maybe to avoid passing variables needlessly...

I probably won't get a chance to play with it much tonight; just got home and have to run out the door again. Plus I just got my long awaited new computer in the mail Smile and can't wait to set it up, but I only have one monitor... So many choices!

Thanks again, I'll let you know how things turn out when I dig into it a bit.

Dan
Quote Reply
Re: Featured Site mod help In reply to
then all you'd need to do is add a call to the list in nph-build.cgi to have this subroutine entered during each build.

You've illustrated the process for adding a new subroutine/page/feature to Link SQL pretty well!

The process is the same for adding any new "feature" page or item.

To add a new user-generated feature, you need to look at jump.cgi and search.cgi for the set up and calls, and for a frame work to insert your code.

There is a really good framework for adding features to Link SQL, and if you make sure all your calls go through DBSQL.pm and the HTML_Templates.pm files, then your subroutines should be portable from one version to the next.

I'm behind adding to the FAQ, and I need a new computer here before I'll have the resources to catch up. But, these are great ideas that are prime to help people start to make their own mods.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: Featured Site mod help In reply to
Dan,

As far as using a template, it is optional but like pugdog said, it makes it more portable. Besides your template being so straight forward will probably only be something like this:

<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>

But hey, if you do it with a template it wouldn't take much at all to port it into page.cgi, so it can be generated on the fly while people are checking out your site, keeping it upto the minute...I don't know if this will be necessary for you, but someday you may want it that way.

And pugdog Wink thanks for the vote of confidence, I was intimidated at first by LinkSQL but once you see it...it only gets easier!

[This message has been edited by phoule (edited March 13, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
I see now what you meant by the template use.

I'm running into a few errors, but first one quick, seemingly stupid question: How do you get a field included in %db_select_fields in Links.def?

Ok, with the code phoule provided, I assume $file = "/path/to/featured.txt"; should be added before the "open" line. Also, the variables should be delcared as my($featured_r, $sth, %OUT, $file);

Adding the last two varibables cleared up one problem. However, when running the build, I get the error, "Can't coerce array into hash at nph-build.cgi line 733." Line 733 is:

$OUT{ID} = $featured_r->{'ID'};

Does "ID" need to be declared somehow? It doesn't seem to be in the other subroutines.

Thanks,
Dan
Quote Reply
Re: Featured Site mod help In reply to
 
Code:
%db_select_fields = (
Network_Membership => 'None,My Postcards,123 Greetings, Other',
isChanged => 'Yes,No',
ReceiveMail => 'Yes,No',
isNew => 'Yes,No',
isPopular => 'Yes,No'
);

Where Network_Membership is defined in the database/array list above as:

Code:
Network_Membership => ['29', 'TEXT', '25', '25', '0', '', 'None|My Postcards|Other', '1']

Don't forget the proper placements of the trailing ',' ... after every item in the list except the last one.






------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: Featured Site mod help In reply to
For the easy one first first...
When you added your new field, you can add in some options to it, then re-sync your def file. For your isFeatured field the vlue of 'Yes|No' without the quotes should be placed in the Validation option, then put No in the default option. When you re-sync your def file it will be automatically added to the db_select part in Links.def

pugdog you beat me to it Wink
Sorry about missing those two vars in the my definition line, though you could also use $LINKS{build_root_url}/featured.txt or something to keep it easily portable if you ever upgrade and saves you from having to define it.

As for the Array vs. Hash thingy, this one took me quite a while to figure out, I still don't really understand the difference between them, except that one holds both the Fieldname and it's value...I think! If you're having this problem there is a sub in DBSQL.pm you can use to convert an Array into a Hash, I haven't used it yet so please someone corect me if I'm wrong on it's usage Wink I'm only going by how I've seen it used...

Before the line %OUT = (); # Fresh Hash
Add this in:
$featured_r = $LINKDB->array_to_hash($featured_r);

If that doesn't work I think you might need to consult someone who really knows what they're doing...I got lucky with the same error when I was integrating a cookie authentication scheme, but I'm still not sure how I got it to work...


[This message has been edited by phoule (edited March 13, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
And he gets lucky a second time! Smile

Adding that last line in got past the errors. I was looking in db_utils.pm, and the closest I could find was sub cgi_to_hash. But, there's always a "but"...

Looking at the output of the text file, here's what it built (I set isFeatured to Yes for two links):

<a target="_blank" href="http://run-down.com/cgi-bin/runlinks/jump.cgi?ID=ARRAY(0x8367b48)">ARRAY(0x8374074)</a> <BR><BR>

Can anyone decipher what exactly is happening there? Something appears to be lost in the conversion. My featured template contains:

<a target="_blank" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a> <%if Description%><%Description%><%endif%><BR><BR>

As far as the select field thing, resyncing the def file is the part I was missing. Thanks. Pugdog, you sort of lost me on your explanation.

Dan
Quote Reply
Re: Featured Site mod help In reply to
Well I've give it another lucky shot... Smile

I don't know what is happening, but I also remember seeing a fethall_hashref():PS after thinking about it it's probably because you don't have the foreach statement, when it goes to print in the template that HASH(goobledygook) is probably the combination of both ID's & Both Title's.

Try taking out the array_to_hash line and in this line:
if ($sth->rows) {
$featured_r = $sth->fetchall_arrayref();
}

Change it to fetchall_hashref();
I know I've seen that for fetchrow statements so it might exist for the fetchall statement too...You should also add in a foreach statement to print out one line for each link you want in your fetured.txt file.



[This message has been edited by phoule (edited March 13, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
Hey Dan did you get it?
Quote Reply
Re: Featured Site mod help In reply to
No, I called it a night and just got up 20 minutes ago... I was able to add in a foreach loop that didn't cause errors, but then the text file output didn't recognize the <%tags%> in the template. No surprise though, seeing as how I was taking wild guesses at how to structure it.

(Aside: I definitely plan to increase my understanding of Perl and MySQL beyond current dabbler status, but that first big step is always the tough one! Sort of an all or nothing endeavor...)

Here's what I left off with:

my($featured_r, $sth, %OUT, $featured, %link_output);

%OUT = (); # Start with a clean hash.
foreach $featured (sort keys %link_output) {
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
}

I know the problem(s) lies in the foreach line, I'm just not exactly sure where. I can probably swing by the perl site and figure it out, though.

Thanks,
Dan
Quote Reply
Re: Featured Site mod help In reply to
Good morning Wink
Aie...yeah your foreach should be surrounding the fetchrow_hashref...

I can see that something isn't right with this!!! Maybe you should ignore doing the change I suggest below and just get your foreach statement to work in a similar manner...enclosing the fetchrow part.

I figure your only using 4 variables so maybe we can tackle this another way using a while statement:
Code:
sub is_featured {
# --------------------------------------------------------
# Creates a featured sites page.
#
my($featured_r, $id, $url, $title, $descript, $sth, %OUT);
$sth = $LINKDB->prepare (qq!
SELECT ID, URL, Title, Description
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
%OUT = ();
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
while($id, $url, $title, $descript) {
$featured_r = $sth->fetchrow_hashref();

print FEATURED &site_featured_template( {ID => $id, URL => $url, Title => $title, Description => $Descript} );
}

close(FEATURED);
}



[This message has been edited by phoule (edited March 14, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
Mornin'. So, I impressed you with my blundering, eh? Smile

I tried the while loop, but that doesn't print anything to the text file... ($Descript should be $descript in the print line.) I moved the foreach line outside the fetchrow_hashref like you suggested, making the subroutine:
Code:
my ($featured_r, $sth, %OUT, %link_output);

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}

%OUT = (); # Start with a clean hash.
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
}

open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template(\%OUT);
close(FEATURED);
That still only outputs one link to the file and doesn't recognize the tags:

"<a target="_blank" href="http://run-down.com/cgi-bin/runlinks/jump.cgi?ID=Unkown Tag: ID">Unkown Tag: Title</a> <BR><BR>"

How does sort keys %link_output work?

Thanks,
Dan
Quote Reply
Re: Featured Site mod help In reply to
 
Quote:
When you added your new field, you can add in some options to it, then re-sync your def file. For your isFeatured field the vlue of 'Yes|No' without the quotes should be placed in the Validation option, then put No in the default option. When you re-sync your def file it will be automatically added to the db_select part in Links.def
Something seems to be missing... I have it set up with Yes|No set up as the validation field, but resyncing does not add isFeatured to %db_select_fields.
Quote:
You need to look at how it's done in the Links.def file, then just add the field to the list, with the default values.
Pugdog, do you mean to edit Links.def directly, or is it done through the SQL Monitor? If you edit Links.def directly, wouldn't you lose all such changes whenever you resync?

Dan
Quote Reply
Re: Featured Site mod help In reply to
When you're on, you're on! It turned out to be fetchrow_hashref, but I don't think the funky looking stuff was due to the ommitted foreach. Changing to fetchrow_hashref with no foreach built one of the links just fine, but ignored the other.

Now if I can just figure out the correct foreach syntax (can't seem to find a very similar example); it was so much simpler in Pascal... Smile

Here's the full subroutine, sans foreach:
Code:
sub is_featured {
# --------------------------------------------------------
# Creates a featured sites page.
#
my($featured_r, $sth, %OUT);

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}

%OUT = (); # Start with a clean hash.
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};

open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template(\%OUT);
close(FEATURED);
}
Thanks for all the help thus far!

Dan
Quote Reply
Re: Featured Site mod help In reply to
Hey Dan,

Code:
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}



open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template(\%OUT);
close(FEATURED);

These two parts need to be combined into one. Each time you go through the foreach loop it needs to print a line in featured_test.txt. In this case there are 2 %featured_r in %link_output. Open the file before you start the foreach, then place the print FEATURED inside the foreach after $feature_r gets assigned the right variables. Then close FEATURED after the foreach id done it's iterations.

So it would look more like:
Code:
%OUT = (); # Start with a clean hash.
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'}; print FEATURED &site_featured_template(\%OUT);

}
close(FEATURED);

As for the other db_select_field thing, I'm not sure it should work if it got added into you SQL database as an enum object. Check that when you edit the field properties you check the box in the first column, otherwie changes you request will not be processed. I know I've done that a few times and couldn't figure out why, realizing much later that it was just that.

Good luck
Quote Reply
Re: Featured Site mod help In reply to
Thanks for the continued efforts. I'm still not having any luck with this... I tried several variations of your last suggestion, and all of them print out a blank text file.
Code:
sub is_featured {
# --------------------------------------------------------
# Creates a featured sites page.
#
my ($featured_r, $sth, %OUT, %link_output);

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();

%OUT = (); # Start with a clean hash.
open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
foreach $featured_r (sort keys %link_output) {
if ($sth->rows) {
$featured_r = $sth->fetchrow_hashref();
}
$OUT{ID} = $featured_r->{'ID'};
$OUT{Title} = $featured_r->{'Title'};
$OUT{URL} = $featured_r->{'URL'};
$OUT{Description} = $featured_r->{'Description'};
print FEATURED &site_featured_template(\%OUT);
}
close(FEATURED);
}
I also tried moving the closing "if" bracket to after the print line, but it made no difference. The only thing I can think is that when it printed a single record correctly,
Code:
$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
!);
$sth->execute();
was not separated from the rest by the foreach loop. However, moving it inside the loop still prints a blank text file. Any other thoughts?

As far as the %db_select_fields, I have isFeatured set up just the same as the other fields such as isPopular, the only difference being that "Form Length" is set to "3" instead of "0". Setting it to "0" just makes a smaller text entry box; doesn't make it a dropdown box. Surely there's another way of doing this...

Dan
Quote Reply
Re: Featured Site mod help In reply to
I wish I could devote more time to answeing your questions, but! Take a look at the sub build_category_pages and see how it adds links to the category pages. just spend some time tweaking your foreach statement to get it right. If it helps at all, try and find out what the variables values are and how many times the foreach is looping by using debugging techniques, print out the variables values and die; the script. Then you'll be able to see what is happening and what and hopefully why it isn't working.
Quote Reply
Re: Featured Site mod help In reply to
phoule,

I certainly understand you have other demands on your time, and I appreciate the help you've provided. I'm closer than I was at the start, so that's a good thing!

I think the next thing I do (nearly "done" with the early stages of getting the new computer working) will be trying to get the featured .txt page built into page.cgi, so I can test it dynamically instead of repeatedly building the database. That should keep my host much happier (although I haven't caused any problems yet). Smile

Thanks,
Dan

edit: wow, check out this post time and the previous post time; that's not easy to do!

[This message has been edited by Dan Kaplan (edited March 15, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
Whew, I've nearly got it working!!!

I ended up doing it slightly different than discussed above, and for whatever reason, I was able to close in on the solution by following examples in page.cgi (I have a question about page.cgi structure, but I'll save that for a new thread).

Here's my sub in nph-build.cgi:
Code:
sub is_featured {
# --------------------------------------------------------
# Creates a featured sites page.
#
my ($link, $sth, $link_results, $featured_r, $id, $title, $url, $description);

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
ORDER BY $LINKS{build_sort_order_cool}
!);
$sth->execute();

# Create the HTML for the individual links.
$featured_r = '';
while ($link = $sth->fetchrow_hashref) {
$id = $link->{'ID'};
$title = $link->{'Title'};
$url = $link->{'URL'};
$description = $link->{'Description'};
$featured_r .= qq~<a target="_blank" href="$LINKS{db_cgi_url}/jump.cgi?ID=${$link}{'ID'}">${$link}{'Title'}</a> ${$link}{'Description'}<BR><BR>\n~;
}

open (FEATURED, ">$LINKS{build_root_path}/featured_test.txt") or die ("unable to open featured page: $LINKS{build_root_path}/featured_test.txt. Reason: $!");
print FEATURED &site_featured_template ( { featured_r => $featured_r } );
close(FEATURED);

}
I then simply made featured_sites.html contain:

<%featured_r%>

The only thing I can think of that remains to be solved is a minor one, but key to the needs of this little project... I need each link to be printed on a separate line in the text file, as I am using a random text script to pull a line from the file for the featured site.

I would have thought adding a second \n at the end of the $featured_r .= qq~ line would accomplish this, but it seems to have no affect. All of the links are printed out on a single line still.

Any ideas?

Thanks again,
Dan
Quote Reply
Re: Featured Site mod help In reply to
I'll bet the text file is being read as "html"... you probably need to insert "<br>" into the file, not "\n"

Look at the _source_ of the output text file. If it's formatted correctly, the "\n" is being inserted.... but the browser is looking for a <BR>

You can get around that by enclosing the output text in "PRE" and "\PRE" tags..... but that is ugly.

Quote Reply
Re: Featured Site mod help In reply to
 
Quote:
I can visualize a very simple solution, that could quickly become very complex.
Famous last words! Smile

No rush on my behalf to look into it (I'll take a peek also and see if I can follow how the flag works), seeing as how I was able to work around it and I con't really need the compression.

I think I remember you saying something about the links-as-shopping cart project in another thread, but I'm not quite sure... How do you envision that turning out? Will it be an add-on to Links SQL, a complete Links SQL package and/or a commercial product, secure transactions, etc? I can see the admin interface being a very strong aspect.

Also, do you have any time framework that you are looking at for the Links SQL banner rotation script, or is it a work on it when time permits type of thing? The main reason I ask is that I just set up WebAdverts (which is much easier to install and work with than the version I tried nearly a year ago and seems to work quite well for "simple" applications) and will probably go ahead and register it unless you think your script will materialize soon.

Dan
Quote Reply
Re: Featured Site mod help In reply to
I got it to work!

The text file source code was not formatted correctly before -- it was all on one line. The HTML output (page.cgi) was ok, but that didn't help the random picker...

I made a few changes, most significantly being turning off "compress white space" in Links.pm. I think that was the key aspect. Is there any way to turn it off for select routines, or is it an all or nothing proposition?

The other thing I changed was wrapping each link in <p> </p> tags instead of <BR><BR> at the end. This seemed to solve the problem, but after changing a few things, I think it might have been a browser cache thing (I thought I refreshed, but maybe not) while testing the compress white space around the same time...

I also added in a few things to the subroutine in nph-build.cgi to output build results like the other subs. Here's the output text file:

http://run-down.com/featured_test.txt

Just a couple hundred more links to set isFeatured to Yes... Here's the page it will be pulled into when it is finished:

http://run-down.com/featured.shtml

And lastly, here's the full subroutine in nph-build.cgi (for anyone following along that wants to do a similar thing):
Code:
sub is_featured {
# --------------------------------------------------------
# Creates a featured sites page.
#
my ($s, $f, $e, $file, $total, $link, $sth, $featured_r, $id, $title, $url, $description);

$file = 'featured_test.txt';

$USE_HTML ?
print "Building <a href='$LINKS{build_root_url}/$file' target='_blank'>Featured</a> ... \n" :
print "Building Featured Page ... \n";
$s = time();

$sth = $LINKDB->prepare (qq!
SELECT *
FROM Links
WHERE Links.isFeatured = 'Yes'
ORDER BY $LINKS{build_sort_order_cool}
!);
$sth->execute();

# Create the HTML for the individual links.
$total = 0;
$featured_r = '';
while ($link = $sth->fetchrow_hashref) {
$total++;
$id = $link->{'ID'};
$title = $link->{'Title'};
$url = $link->{'URL'};
$description = $link->{'Description'};
$featured_r .= qq~<p><a target="_blank" href="$LINKS{db_cgi_url}/jump.cgi?ID=${$link}{'ID'}">${$link}{'Title'}</a> ${$link}{'Description'}</p>\n~;
}

open (FEATURED, ">$LINKS{build_root_path}/$file") or die ("unable to open featured page: $LINKS{build_root_path}/$file . Reason: $!");
print "\tFeatured Links: $total\n";
print FEATURED &site_featured_template ( { featured_r => $featured_r } );
close(FEATURED);
# All done.
$f = time();
$e = $f - $s;
print "Done ($e s)\n\n";

}
Thanks again for all the help getting this to work! Smile It took a while, and I still have a lot of links to change, but long-term it will be a HUGE time saver.

Dan


[This message has been edited by Dan Kaplan (edited March 17, 2000).]
Quote Reply
Re: Featured Site mod help In reply to
Code:
I made a few changes, most significantly being turning off "compress white space" in Links.pm. I think that was the key aspect. Is there any way to turn it off for select routines, or is it an all or nothing proposition?

The setting is a flag in the Links.pm file, so you should be able to either edit the routine to only compress certain files, or ignore certain files, or possibly to set/un-set the flag before calling each routine.

I have not looked at how the flag is used specifically, but it's probably in the &load_template call when the template is written out to file. If you want to ignore certain templates, could specify them.

This would be another good area for adding a flag to the "database" on whether to compress output or not either on a default or an override basis.

Got soooooo much to do Smile

This weekend will be to get the all-on-one finished and to start the links-as-shopping-site project.

I can visualize a very simple solution, that could quickly become very complex.

> >