Gossamer Forum
Home : Products : Links 2.0 : Customization :

What's New to the Homepage...

Quote Reply
What's New to the Homepage...
hola,

is it possible to have the list of new sites on the homepage, like the way they are displayed on the what's new index page? (not the lastlink mod...)

Lunedì, 10 Luglio 2000 (1).
Giovedì, 6 Luglio 2000 (1).
Mercoledì, 5 Luglio 2000 (1).
Martedì, 4 Luglio 2000 (18).
Lunedì, 3 Luglio 2000 (1).
Domenica, 2 Luglio 2000 (1).
Sabato, 1 Luglio 2000 (2).
Venerdì, 30 Giugno 2000 (2).
Giovedì, 29 Giugno 2000 (3).
Mercoledì, 28 Giugno 2000 (2).
Martedì, 27 Giugno 2000 (1).

thanks for any help,

ciao

Quote Reply
Re: What's New to the Homepage... In reply to
The way I'd try to do it is to copy some of the sub build_new and add it to sub build_home in nph-build.cgi

If your carefull with what you take accross and remember to add to the bit at the top:

local .....

Then add the tags in site_html_templates.pl



Glenn

Quote Reply
Re: What's New to the Homepage... In reply to
i've tried a lot of cut & past into build_home
but since i'm not a programmer Frown the results
are errors over errors...

anyway, thanks for your speedy answer!!!

did someone already made this mod?
could you post it?

thanks,

ciao

Quote Reply
Re: What's New to the Homepage... In reply to
I had another look at it and it seems quite a bit of work to do (perhaps more than it's worth)

Anyway I wondered if you thought about using ssi to display it on your homepage as it would be much easier. Just change the build extensions to .shtml in links.cfg

Edit the path it builds the new page links to in nph-build.cgi

Finally just use an ssi include on your homepage.



Glenn

Quote Reply
Re: What's New to the Homepage... In reply to
hola,

you're right glennu, it's much easier with ssi... but i think it would slow down my site...

anyway... i'v got the what's new on homepage by modifing
the sub site_html_home in site_html_templates.pl
like this (modifications are in red...):

In Reply To:
sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.

# Start What's New results...

# Now we go through all the new_links (which are organized by category), and
# build the html in array indexed by date then category.

$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}
}

# Then we go through each date, and build the links for that date. If we are spanning
# pages, we will create a seperate page for each date and need to set up a few other
# variables (like title and total). We will also want to reset links_results each time.

DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
$long_date = &long_date ($date);
if ($build_span_pages) {
$link_results = "";
$total = $span_totals{$date};
$title_linked = &build_linked_title ("New/$long_date");
}
else {
$link_results .= "<p><strong>$long_date</strong>\n<blockquote>";
}
CATEGORY: foreach $category (sort keys %{$link_output{$date}}) {
$category_clean = &build_clean ($category);
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= ${$link_output{$date}}{$category};
}


# Crete the new page, and do a bit of HTML work for the main page.
if ($build_span_pages) {

$main_link_results .= qq|<li><a href="$build_new_url/$date$build_extension">$long_date</a> ($total).|;
$main_total += $total;
}
else {
$link_results .= "</blockquote>";
}
}

if ($build_span_pages) {
$link_results = "<ul>$main_link_results</ul>";
$total = $main_total;
}
$title_linked = &build_linked_title ("New");

# Stop What's New results...


return &load_template ('home.html', {
category => $category,
grand_total => $grand_total,
long_date => $long_date,
bhlnew => $link_results,
bhltotal => $total,

%globals
});
}
you also need tho put <%bhlnew%> and <%bhltotal%> tags in your home.html template...

i'd like to know if everyhing is correct...
i mean... to clean out what it is not necessary, and so on...

please, give me your feedback...
i'm not a perl programmer and, really,
i still have not realized how it can works!!!

Blush

there is one more mod i need:
since i've got the link to the new links added on the homepage,
i don't need anymore the what's new index.html file...
how can i stop the build of this page???

thanks,

ciao

Quote Reply
Re: What's New to the Homepage... In reply to
Yeah, sorry, I should have though to do that! Yeah that makes sense and sounds like a good idea. Instead of putting it in your sub home_page you could put it in a new subroutine ie. sub buildnew {.....
Define it in the globals at the top of site_html_templates.pl
That way you can put the new link info in any template you want.



The code you have posted looks fine to me so if it works I would keep it! There's not really anything you can get rid of there, I assume you'll be spanning pages so in which case I'd keep it all there.

To stop it building the new page you'll need to edit nph-build.cgi
Delete the whole of sub build new page {...
Then delete the sections refering to it in build all and build staggered. They'll be commented so you should be able to find them easily.

KEEP the other parts referring to it in build stats and update newpop

That should do it, but I'd create a backup of nph-build.cgi beforehand just incase it doesn't work.

Good luck!

Glenn


Quote Reply
Re: What's New to the Homepage... In reply to
In Reply To:
you're right glennu, it's much easier with ssi... but i think it would slow down my site...
Having a few pages in a .shtml document would not slow down your site. If all pages were .shtml, that might.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: What's New to the Homepage... In reply to
hola,

i'd like to make a routine that will output
the total number and the list of the new addition.

i've used the above code to create a sub bhl_new {
in the site_html_templates.pl file... then
i added bhlnew => &bhl_new, in the %globals
in order to put the results in any of my templates...

i've obtained to show, on the pages where i've inserted
the variable, the results of $title_linked = &build_linked_title
("New");
... that's not what i need...

i think i should make something different because there are
two varialbles to get out of the routine:

$link_results = "<ul>$main_link_results</ul>";

and

$total = $main_total;

please, can you help me build this routine?
i don't know if i'm close to the solution or if i'm far away...

something appens, i've got an output but it did not take
the effect that i've hoped...

thanks,

ciao


Quote Reply
Re: What's New to the Homepage... In reply to
hola,

In Reply To:
Having a few pages in a .shtml document would not slow down your site. If all pages were .shtml, that might.
... in this way i can't learn how to modify Links engine.
i think it's a great program, it can be used in many ways...
and the best is that you can customize it as you like...

... if you know where to put your hands!!!
that's why i'm doing this way...

Smile

i'd like to learn as much as possible of Links,
with the help of this forum... and by studing perl!!!

ciao
Quote Reply
How to write a subroutine!!! In reply to
hola,

the code below works fine when in sub site_html_home,
but does not when i try to make it a new subroutine...

bhlnew => $main_links_results,
bhltotal => $main_total,

should be in the globals section of site_html_templates.pl
to allow their use in any of my templates...

please help!!!

thanks,

ciao

In Reply To:
sub bhl_new {
# --------------------------------------------------------
#

$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}

}

DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
$long_date = &long_date ($date);
$total = $span_totals{$date};
$main_link_results .= qq|<a href="$build_new_url/$date$build_extension">$long_date</a> <b>($total)</b>
|;
$main_total += $total;
}
}
Quote Reply
Re: How to write a subroutine!!! In reply to
To include the subroutine in your globals you'd need to use bhl_new => &bhl_new, instead.

I'll have a look at doing it soon, but I could guess roughly how to start thinking about it:
in globals:
bhl_new => &bhl_new,


sub bhl_new {
# --------------------------------------------------------
#
my (%link_output, $category_clean, $long_date, $category, $date, $main_link_results, $main_total, %span_totals);
local ($total, $link_results, $title_linked);

$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}
}

DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
$long_date = &long_date ($date);
$total = $span_totals{$date};
$main_link_results .= qq|<a href="$build_new_url/$date$build_extension">$long_date</a> <b>($total)</b>
|;
$main_total += $total;
}
return $total;
}

Try something like that.


Also I had a thought the other day:
What about using the enhanced template mod, then you could probably put the new links anywhere you want just by using include commands.


Glenn






Quote Reply
Re: How to write a subroutine!!! In reply to
hola,

thanks Glenn for your replies...
i'll try soon the enhanced template mod,
even if i'd be happy to learn how to make
this subroutine!!! we're not far away, right?

Smile

i've tried the following codes without progression:

return $total;
in sub bhl_new
bhl_new => &bhl_new,
in globals
<%bhl_new%>
in home.html

it printed out (0) in the homepage,
something is coming out from the sub but...

return ($total, $main_link_results);
in sub bhl_new
bhl_new => &bhl_new,
in globals
<%bhl_new%>
in home.html

it printed out nothing in the homepage...

i'll try to put the new subroutine in nph_bulid.cgi,
but i'm still wonder about how to handle the two variables
i need to build the correct output:

$main_link_results that means the link to the single day
additions - Lunedì, 10 Luglio 2000 (1) - and $main_total
that means the total of new additions...

thanks again,

ciao

Quote Reply
Re: How to write a subroutine!!! In reply to
Try using this just to see if it returns the total, if it does then we know it's reading the links database etc... and so getting the other stuff shouldn't be too hard:


sub bhl_new {
# --------------------------------------------------------
#
my (%link_output, $category_clean, $long_date, $category, $date, $main_link_results, $main_total, %span_totals);
local ($total, $link_results, $title_linked);

$total = 0;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}
}

DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
$long_date = &long_date ($date);
$total = $span_totals{$date};
$main_link_results .= qq|<a href="$build_new_url/$date$build_extension">$long_date</a> <b>($total)</b>
|;
$main_total += $total;
}
return $total;
close DB;
}


If it doesn't work etc. then I'd use what you did before and just display it on your homepage.


Glenn

Quote Reply
Re: How to write a subroutine!!! In reply to
hola,

not working :( now i can:

- use ssi
- add the working code to all other subroutines i want to show the what's new results (sub site_html_search_results, sub site_html_search_form etcetera)
- keep trying to build that subroutine

... to be or not to be!?!?!?

ciao


Quote Reply
Re: How to write a subroutine!!! In reply to
I would have a go at using the enhanced template option which is in the resource center.

That way you can let it build the index onto the whats new page and include that page anywhere you want to.

In some ways it's better than ssi because it includes the files for when it builds the page. (ie. it will be static afterwards)

I think it seems to be the better easier option.


Glenn

Glenn

Quote Reply
Re: How to write a subroutine!!! In reply to
If you want to have another try at the sub routine I have an idea:

Take all the info that you copied to site_html_home. Put that into a new sub routine as before. call it sub site_html_bhl_new

Then in nph_build.cgi go to where ever you want to put the new links into: ie. build_home
and put:

$bhl_new = &site_html_bhl_new;

To be honest I haven't a clue whether it'll work (it probably won't!) only I saw there was a similar command in
buil_home which got it to include the site_html_print_cat



Glenn