If anyone is interested I have written the Days_Old tag back into Links-SQL 2.0. If anyone wants the mod let me Know and I will post it here.
Feb 4, 2001, 12:34 PM
User (69 posts)
Feb 4, 2001, 12:34 PM
Post #2 of 14
Views: 4978
I sure would like that. One less obstacle for me to tackle.
Dan Oakeson
http://www.AssociateCash.com
Dan Oakeson
http://www.AssociateCash.com
Here is the code to add the Days_Old field.
The changes are to Links/SiteHTML.pm.
The added code is between the # ---------- markers.
package Links::SiteHTML;
# ==================================================================
use strict;
use Links qw/$DB $CFG/;
use GT::Plugins;
# ----- added module ---------
use GT::Date;
# ---------------------------
sub site_html_link {
# --------------------------------------------------------
# Format a single link.
#
my $rec = shift;
# Convert the date formats.
if ($CFG->{date_db_format} ne $CFG->{date_user_format}) {
Links::init_date();
# ------------- added line to preserve Add_Date from Links table row -------------
$rec->{Add_Date1} = $rec->{Add_Date};
# --------------------------------------------------------------------------------
$rec->{Add_Date} = GT::Date::date_transform ($rec->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
$rec->{Mod_Date} = GT::Date::date_transform ($rec->{Mod_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
}
# Set new and pop to either 1 or undef for templates.
(defined $rec->{'isNew'} and ($rec->{'isNew'} eq 'Yes')) ? ($rec->{'isNew'} = 1) : ($rec->{'isNew'} = 0);
(defined $rec->{'isChanged'} and ($rec->{'isChanged'} eq 'Yes')) ? ($rec->{'isChanged'} = 1) : ($rec->{'isChanged'} = 0);
(defined $rec->{'isPopular'} and ($rec->{'isPopular'} eq 'Yes')) ? ($rec->{'isPopular'} = 1) : ($rec->{'isPopular'} = 0);
(defined $Links::USER->{Username} and ($rec->{'LinkOwner'} eq $Links::USER->{Username})) ?
($rec->{'isLinkOwner'} = 1) : ($rec->{'isLinkOwner'} = 0);
# ---------------- Links Days_Old calculate ----------------------------
# Figure out how many days old it is if it's a new link.
if ($rec->{'isNew'} eq '1') {
$rec->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $rec->{'Add_Date1'});
}
else { $rec->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------
# Set the detailed_url.
$rec->{detailed_url} = "$CFG->{build_detail_url}/${$rec}{'ID'}$CFG->{build_extension}";
# Parse the template.
my $output = Links::load_template ('link.html', $rec, 0);
return $output;
}
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames);
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
# Print Header.
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
if ($CFG->{build_category_columns}) {
$output = qq|<div class="margin"><table $table_head><tr><td class="catlist" width="$width%" valign="top">\n|;
}
$i = 0;
my $cat_db = $DB->table('Category');
foreach $cat_r (@$subcat) {
# Get the URL and the Category name.
$category_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($cat_r->{Full_Name}) . "/" . $CFG->{build_index};
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;
# ------------------------ Category Days_Old Routine --------------------------
# Calculate the number of days old.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------------
# Append @ if we are using Yahoo style cats, and it is related.
The changes are to Links/SiteHTML.pm.
The added code is between the # ---------- markers.
package Links::SiteHTML;
# ==================================================================
use strict;
use Links qw/$DB $CFG/;
use GT::Plugins;
# ----- added module ---------
use GT::Date;
# ---------------------------
sub site_html_link {
# --------------------------------------------------------
# Format a single link.
#
my $rec = shift;
# Convert the date formats.
if ($CFG->{date_db_format} ne $CFG->{date_user_format}) {
Links::init_date();
# ------------- added line to preserve Add_Date from Links table row -------------
$rec->{Add_Date1} = $rec->{Add_Date};
# --------------------------------------------------------------------------------
$rec->{Add_Date} = GT::Date::date_transform ($rec->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
$rec->{Mod_Date} = GT::Date::date_transform ($rec->{Mod_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
}
# Set new and pop to either 1 or undef for templates.
(defined $rec->{'isNew'} and ($rec->{'isNew'} eq 'Yes')) ? ($rec->{'isNew'} = 1) : ($rec->{'isNew'} = 0);
(defined $rec->{'isChanged'} and ($rec->{'isChanged'} eq 'Yes')) ? ($rec->{'isChanged'} = 1) : ($rec->{'isChanged'} = 0);
(defined $rec->{'isPopular'} and ($rec->{'isPopular'} eq 'Yes')) ? ($rec->{'isPopular'} = 1) : ($rec->{'isPopular'} = 0);
(defined $Links::USER->{Username} and ($rec->{'LinkOwner'} eq $Links::USER->{Username})) ?
($rec->{'isLinkOwner'} = 1) : ($rec->{'isLinkOwner'} = 0);
# ---------------- Links Days_Old calculate ----------------------------
# Figure out how many days old it is if it's a new link.
if ($rec->{'isNew'} eq '1') {
$rec->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $rec->{'Add_Date1'});
}
else { $rec->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------
# Set the detailed_url.
$rec->{detailed_url} = "$CFG->{build_detail_url}/${$rec}{'ID'}$CFG->{build_extension}";
# Parse the template.
my $output = Links::load_template ('link.html', $rec, 0);
return $output;
}
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames);
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
# Print Header.
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
if ($CFG->{build_category_columns}) {
$output = qq|<div class="margin"><table $table_head><tr><td class="catlist" width="$width%" valign="top">\n|;
}
$i = 0;
my $cat_db = $DB->table('Category');
foreach $cat_r (@$subcat) {
# Get the URL and the Category name.
$category_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($cat_r->{Full_Name}) . "/" . $CFG->{build_index};
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;
# ------------------------ Category Days_Old Routine --------------------------
# Calculate the number of days old.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------------
# Append @ if we are using Yahoo style cats, and it is related.
Feb 5, 2001, 3:04 PM
User (193 posts)
Feb 5, 2001, 3:04 PM
Post #4 of 14
Views: 4974
How would we go about making this into a plugin, or is it even possible to do?
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
From my reading on plugins they are able to gain control at existing pre-defined hook points in the code. I do not think that would work for this mod as there are not any plugin hooks in the area where I added the code. Perhaps Alex or someone more familiar with the plugin system can comment on this?
Feb 5, 2001, 5:11 PM
User (193 posts)
Feb 5, 2001, 5:11 PM
Post #6 of 14
Views: 4951
There is actually a plugin hook for every site_html_something subroutine, its just a matter of whether its a pre or post hook, etc.
I'll take a look at it tonight.
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
I'll take a look at it tonight.
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Feb 5, 2001, 5:38 PM
User (193 posts)
Feb 5, 2001, 5:38 PM
Post #7 of 14
Views: 4939
ok, I about have this plugin done, except I'm hitting a problem.
This subroutine is called as a PRE hook for site_html_link:
sub link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_link'
# is run. You should return STOP if you don't want
# the regular code to run, or CONTINUE if you want
# the regular code to run.
#
my $link = shift;
# ------------- added line to preserve Add_Date from Links table row -------------
$link->{Add_Date1} = $link->{Add_Date} ;
# --------------------------------------------------------------------------------
# ---------------- Links Days_Old calculate ----------------------------
# Figure out how many days old it is if it's a new link.
if ($link->{'isNew'} eq '1') {
$link->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $link->{'Add_Date1'});
}
else { $link->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------
return $link;
}
But I'm when I display a link, I get:
Unknown tag: Days_Old
Could anyone please elaborate?
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
This subroutine is called as a PRE hook for site_html_link:
sub link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_link'
# is run. You should return STOP if you don't want
# the regular code to run, or CONTINUE if you want
# the regular code to run.
#
my $link = shift;
# ------------- added line to preserve Add_Date from Links table row -------------
$link->{Add_Date1} = $link->{Add_Date} ;
# --------------------------------------------------------------------------------
# ---------------- Links Days_Old calculate ----------------------------
# Figure out how many days old it is if it's a new link.
if ($link->{'isNew'} eq '1') {
$link->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $link->{'Add_Date1'});
}
else { $link->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------
return $link;
}
But I'm when I display a link, I get:
Unknown tag: Days_Old
Could anyone please elaborate?
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Feb 5, 2001, 10:57 PM
Veteran / Moderator (6956 posts)
Feb 5, 2001, 10:57 PM
Post #8 of 14
Views: 4972
I know this sounds trite, but make sure the plug-in installed properly. Check the plug-in.cfg file.
If not, send me the tarball and I'll take a look at it (the plugins are great that way! :)
PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://LinkSQL.com/FAQ
If not, send me the tarball and I'll take a look at it (the plugins are great that way! :)
PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://LinkSQL.com/FAQ
Feb 6, 2001, 6:14 AM
User (193 posts)
Feb 6, 2001, 6:14 AM
Post #9 of 14
Views: 4909
I finally got it working, after fixing some perl bugs :)
If anyone wants this plugin, just ask.
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
If anyone wants this plugin, just ask.
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Feb 6, 2001, 11:03 AM
Administrator (9387 posts)
Feb 6, 2001, 11:03 AM
Post #10 of 14
Views: 4901
If you want to send it to me, I can review it and put it up on the site.
Cheers,
Alex
--
Gossamer Threads Inc.
Cheers,
Alex
--
Gossamer Threads Inc.
Feb 6, 2001, 1:57 PM
User (193 posts)
Feb 6, 2001, 1:57 PM
Post #11 of 14
Views: 4888
I'm going to add some more features to it, such as some images, and an About section with the tags needed.
Since I don't have to be at school until 10 tomorrow, I should wrap this up early tomorrow.
I'll send it to you Alex the moment I'm done.
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Since I don't have to be at school until 10 tomorrow, I should wrap this up early tomorrow.
I'll send it to you Alex the moment I'm done.

Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Feb 6, 2001, 6:36 PM
User (193 posts)
Feb 6, 2001, 6:36 PM
Post #12 of 14
Views: 4885
Problem.
See this code:
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames);
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
# Print Header.
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
if ($CFG->{build_category_columns}) {
$output = qq|<div class="margin"><table $table_head><tr><td class="catlist" width="$width%" valign="top">\n|;
}
$i = 0;
my $cat_db = $DB->table('Category');
foreach $cat_r (@$subcat) {
# Get the URL and the Category name.
$category_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($cat_r->{Full_Name}) . "/" . $CFG->{build_index};
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;
# ------------------------ Category Days_Old Routine --------------------------
# Calculate the number of days old.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------------
See the Days_Old routine, is there a hook here anywhere I can use? I don't think I can port this part into the plugin because the $cat_r variable originates in the foreach loop.
Anyone have any input?
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
See this code:
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames);
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
# Print Header.
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
if ($CFG->{build_category_columns}) {
$output = qq|<div class="margin"><table $table_head><tr><td class="catlist" width="$width%" valign="top">\n|;
}
$i = 0;
my $cat_db = $DB->table('Category');
foreach $cat_r (@$subcat) {
# Get the URL and the Category name.
$category_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($cat_r->{Full_Name}) . "/" . $CFG->{build_index};
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;
# ------------------------ Category Days_Old Routine --------------------------
# Calculate the number of days old.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = >::Date::date_diff (>::Date::date_get(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }
# ----------------------------------------------------------------------------
See the Days_Old routine, is there a hook here anywhere I can use? I don't think I can port this part into the plugin because the $cat_r variable originates in the foreach loop.
Anyone have any input?
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Feb 6, 2001, 7:45 PM
Administrator (9387 posts)
Feb 6, 2001, 7:45 PM
Post #13 of 14
Views: 4913
Hi,
No, use the site_html_print_cat hook. Look at how YahooSubcats works, you are doing almost the same thing.
Cheers,
Alex
--
Gossamer Threads Inc.
No, use the site_html_print_cat hook. Look at how YahooSubcats works, you are doing almost the same thing.
Cheers,
Alex
--
Gossamer Threads Inc.
Feb 7, 2001, 6:25 AM
User (193 posts)
Feb 7, 2001, 6:25 AM
Post #14 of 14
Views: 4895
Thanks Alex.
It's fully working now.
I just sent it to you.
Enjoy!
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
It's fully working now.
I just sent it to you.
Enjoy!
Robert Blackstone
Webmaster of Scato Search
http://www.scato.com