Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Last 10 Added

Quote Reply
Last 10 Added
Hi.

Check this link:

http://vxbox.com/...mp;%20Humanities.php

Much like what's there on this site how could the same be done for LSQL wrt following displayed on home page (or any other page):

Last 10 added (all categories composite summary on home page and Category Wise Summary on Category Page). The text should be truncated much like what's there on the above link so that the same fits within a given tablewidth... The link url should be configurable either to the Detailed Proifile or to the <%URL%>

TIA
Anup

Last edited by:

anup123: Aug 9, 2004, 12:26 AM
Quote Reply
Re: [anup123] Last 10 Added In reply to
Quote:
Last 10 added (all categories composite summary on home page and Category Wise Summary on Category Page). The text should be truncated much like what's there on the above link so that the same fits within a given tablewidth... The link url should be configurable either to the Detailed Proifile or to the <%URL%>

You don't ask for much, do you? Tongue

I can't help you with all of that, as I'm a bit pushed for time. However, something like this should do it;

Code:
sub {

my $tbl = $DB->table('Links');
$tbl->select_options('ORDER BY TimeStmp DESC','LIMIT 10');
my $sth = $tbl->select() || return $GT::SQL::error;
my $back;
while (my $hit = $sth->fetchrow_hashref) {
$back .= Links::SiteHTML::display('link',$hit);
}
return $back;
}

Hope that helps.

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: [anup123] Last 10 Added In reply to
Here's a couple more that may help.

sub {
# Displays the new links site wide.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY ADD_DATE DESC', 'Limit 10');
$sth = $search_db->select ( { isNew => 'Yes'}, { isValidated => 'Yes'});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('newlinks', $link);
}
return $output;
}


sub {
# Displays New links by category.
my ($output,$sth,$link);
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY ADD_DATE DESC', 'LIMIT 10');
my $sth = $db->select ( { isNew => 'Yes'}, { 'CatLinks.CategoryID' => $id}, { isValidated => 'Yes'} );
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('new_by_cat', $link);
}
return $output;
}

sub {
# Short description
my $tags = shift;
my $desc = $tags->{Description} or return "No description on this template";
length $desc <100 and return $desc;
my $short = substr ($desc, 0, 100);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}

Regards

minesite
Quote Reply
Re: [Andy] Last 10 Added In reply to
Hi.

Thanks Andy and minesite. I could get the last 10 added (site wide) going with not TimeStmp but Add_Date (as suggested by minesite) going though im still not able to get the link truncated to xx characters...

Something like

This Is My ....
No Site
Useful Resource ....

Quote:
You don't ask for much, do you? Tongue

Yep I agree to agree on that Wink

Thanks
Anup
Quote Reply
Re: [minesite] Last 10 Added In reply to
Hi.

Oh Got it going. I needed to truncate the title, and it worked.

Thanks once again.
Anup
Quote Reply
Re: [anup123] Last 10 Added In reply to
In Reply To:
I needed to truncate the title, and it worked.

How'd you truncate it? Could you post the final code?

Thanks Smile

------------------------------------------
Quote Reply
Re: [DogTags] Last 10 Added In reply to
Hi.

Taken from minesite's code:

sub {
# Short Title
my $tags = shift;
my $desc = $tags->{Title} or return "No Title";
length $desc <21 and return $desc;
my $short = substr ($desc, 0, 21);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}


Then in template called the same as :

<a class="subcat_links" href="........"><%short_title%></a>

Could adjust the 21 to whatever suits the page layout. It works so i presume u have not goofed up copying minesite's code and modifying :)

Thanks
Anup
Quote Reply
Re: [DogTags] Last 10 Added In reply to
Should be able to change "Description" to "Title".
Something like this:

sub {
# Short title
my $tags = shift;
my $desc = $tags->{Title} or return "No title on this template";
length $desc <100 and return $desc;
my $short = substr ($desc, 0, 100);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}

Change the 100 to the number of characters you want to display.

Regards

minesite
Quote Reply
Re: [minesite] Last 10 Added In reply to
Or you could just make a global that will shorten anything you want:

sub {
my $tag = shift;
my $length = shift;
length $tag < $length and return $tag;
my $short = substr ($tag, 0, $length);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}

<%global_name($Title,'20')%> - this would read in the Title tag and shorten it to 20.
Quote Reply
Re: [afinlr] Last 10 Added In reply to
Hi.

That's more flexible.
Just another bit (unrelated to this thread).

A similar global (generalised like the one above) for making any column as template tag (which is otherwise not available).

Thanks
Anup

Last edited by:

anup123: Aug 13, 2004, 8:39 AM
Quote Reply
Re: [afinlr] Last 10 Added In reply to
I’ve got that many globals I’m not sure where I am.
Can shortened and formatted be done together and called like the following.

<%global_name($Title,'20')%>

sub {
my $tag = shift;
my $length = shift;
length $tag < $length and return $tag;
my $short = substr ($tag, 0, $length);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}
<%short($Title,'20')%>

Formatted global by Laura and Andy
http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=263845;search_string=field_content%20%3D%20GT;#263845

sub {
my $field_content = $_[0];
$field_content = GT::CGI::html_escape($field_content);
$field_content =~ s|\n|<BR>\n|g;
$field_content =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;
length $field_content <400 and return $field_content;
my $short = substr ($field_content, 0, 400);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;

}

<%formatted ($Title)%>

Regards

minesite
Quote Reply
Re: [minesite] Last 10 Added In reply to
This should work:

sub {
my $field_content=shift;
my $length=shift;
$field_content = GT::CGI::html_escape($field_content);
$field_content =~ s|\n|<BR>\n|g;
$field_content =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;
length $field_content <$length and return $field_content;
my $short = substr ($field_content, 0, $length);
$short =~ s/\s\S+?$//;
$short .= " ...";
return $short;
}
Quote Reply
Re: [afinlr] Last 10 Added In reply to
Thanks Laura,
I can do some spring cleaning tomorrow.
Tongue

Regards

minesite