Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Newest Links Global

(Page 1 of 2)
> >
Quote Reply
Newest Links Global
Hi



I am using a global to display the newest links added to the database:

sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 8');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}

I am trying to limit the size of the title displayed to 50 letters only so the shap will fit right.. is there any way to do that?

EXample:

Actual Title = Buy sell and auction on any items online from sales.com

Displayes Title = Buy sell and auction on any items..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Newest Links Global In reply to
Hi,

Try:

Code:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 8');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Newest Links Global In reply to
Depending on the activity in your site, you might want to remove the "isNew = Yes" line, since that will return no results if none of your links are "new" according to your isNew parameter -- or fewer items than you would like for the same reason.

Because you are ordering your links by date descending, anyway, the newest links will be on the top.

The isValidated parameter makes sure you don't show links that have not been approved yet.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Newest Links Global In reply to
Thanks Alex and Pugdog.



Works great
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Newest Links Global In reply to
hey all--
this is a great mod, and i'd like to use it too, but I have a question: I want my newest links added list to show up on my home page (not links page) via some sort of ssi call, like insert file or exec cgi (it's a .shtml page anyway). How might i do this with the above mod? would it have to create a file or could i call it somehow from my home page? (also, i'm thinking of adding a isEditorsChoice field in my database so that I can just include the newest recommended links, rather than just the newest links). Also, I wouldn't mind including the description as well as the link, but i can probably figure that out myself...
Quote Reply
Re: [celina] Newest Links Global In reply to
Hi



the best way as far as I know is to create a file called new.html and have only the new_links global in it then place it using SSI in your home page..

I thinkUnsure
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Newest Links Global In reply to
well, I'm back. and I've been trying desperately to get this to work.

I have the new links global installed, so that's all good.
but when I make a new template called "new_links.html", I can't get it to build, or I cant' figure out where it builds to (and this is the page I would include on my main homepage using ssi).

Then I've also snooped around these boards for the past four hours (yes, really!) and have tested out a number of other things, including trying to call the page via page.cgi, but that gives me a crazy error message (Invalid Site HTML method: site_html_link1 (link1.html). Most likely template does not exist in default. at /h14/bustmag/cgi-bin/links/admin/Links/SiteHTML.pm line 208.
)

so, what to do? any other ideas folks? please? pretty please?
Quote Reply
Re: [celina] Newest Links Global In reply to
If you installed the global, and called it new_links, then in the template, you'd be able to call it <%new_links%>

It's stored and built in the tag that is inserted into by 'output'


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [celina] Newest Links Global In reply to
Hi

What I have running is:

The global:



sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 7');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 20) {
$link->{Title} = substr($link->{Title}, 0, 20) . '...';
}
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}



then my link1.html contains:

• <font face="arial" size="2">
<a href="<%db_cgi_url%>/safe_jump.cgi?ID=<%ID%>"><%Title%></a>
&nbsp;<%Add_Date%></font><BR>

and just use <%newlinks%> in any templete you wish..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Newest Links Global In reply to
thank you so very much for your quick replies, but I guess I didn't clarify what I want to do.

I do have the global working, and I have the tag <%newlinks%> that I know i can use in a template. But the thing is, I want those links to show up on my web site home page, not my links sql home page.

So, I was hoping to call that newlinks content into my front page using an ssi call.

and in order for that to work, I have to have a file, or a script, that I can call with that ssi call.

so, either I somehow get links to build a new page that I can call into my web site home page (tried this; made a new template called new_links.html and put that <%newlinks%> tag in it, but could not find a way to call the page, as it didn't seem to be getting built by the program), or call it somehow with a script (page.cgi?? couldn't get that to work either).

so...whadoido?

thanks in advance for any suggestions...
Quote Reply
Re: [celina] Newest Links Global In reply to
page.cgi?p=new_links should work.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Newest Links Global In reply to
It should work..but it doesn't.

I get this error:
A fatal error has occured:


Invalid Site HTML method: site_html_new_links (new_links.html). Most likely template does not exist in default. at /h14/bustmag/cgi-bin/links/admin/Links/SiteHTML.pm line 208.

Please enable debugging in setup for more details.


I've moved the template out of the local folder and into the default folder, then back into the local folder...whereever i move it, it still won't work with this call.

So yogi, do I need that plug in that you've been working on? the page building one?
Quote Reply
Re: [celina] Newest Links Global In reply to
Well, of course you need the plugin! Cool

But before it is released:

1) double check the spelling
2) in which template directory did you place it? If it's not the default one, add t=name_of_your_template to the query.
3) make sure the template is readable by the webserver.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [celina] Newest Links Global In reply to
In your home page or whereever you want the new links (must be either shtm or shtml page unless you have ssi enabled all over site, insert

<!--#include virtual="/cgi-bin/links/page.cgi?p=new_links&t=ssi"-->

&t=ssi is very important and not using it will cause fatal errors
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory

Last edited by:

katabd: Jul 8, 2002, 10:26 PM
Quote Reply
Re: [katabd] Newest Links Global In reply to
Oh boy. This thing is still not working.

Here's my new_links global:
sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 5');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}


Here's my newlinks template:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title><%site_title%>: Newest Links</title>
<link rel=stylesheet href="<%css%>" type="text/css" title="style sheet">
</head>
<body>
<%new_links%>
</body>
</html>

(it is called newlinks.html and it is stored in default/local)

Here's my call (inside an .shtml page)

<!--#include virtual="cgi-bin/links/page.cgi?p=newlinks&t=ssi"-->

Here's the error:

A fatal error has occured:


Invalid Site HTML method: site_html_link1 (link1.html). Most likely template does not exist in default. at /h14/bustmag/cgi-bin/links/admin/Links/SiteHTML.pm line 208.

Please enable debugging in setup for more details.


Soooo...do I need to change something in some other file?
Quote Reply
Re: [celina] Newest Links Global In reply to
arg...embarassed.

I figured out the problem.

I never made a links1.html template! how stooopide of me!

oh boy. I apologize.

It works now. Thank you so much everyone for your patience and help.

Blush
Quote Reply
Re: [celina] Newest Links Global In reply to
Hi

your new links templets should only contain:
<%new_links%>



I will think..



Glad it worked for you.. Wink
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Newest Links Global In reply to
Because of another template set, we don't want link.html

Can we change this select to reference the NewsHeading as a type of NotNull reference or True?

$sth = $search_db->select ( {NewsHeading => '', isNew => 'Yes', isValidated => 'Yes' });

unless i should be referencing the other template set, then a path change would need to happen (where)?
Quote Reply
Re: [gatman] Newest Links Global In reply to
This make sense?
Quote Reply
Re: [gatman] Newest Links Global In reply to
Could you have another go at explaining what you're trying to do?
Quote Reply
Re: [afinlr] Newest Links Global In reply to
link1 or whatever link.html may be named is from the default template set - We are using three template sets in the design.

We have need for the data from the template set that is not default.

I thought if{ isNew => 'Yes', isValidated => 'Yes' }); could be changed to something like
{ NewsHeading => 'NotNull', isNew => 'Yes', isValidated => 'Yes' }); where NotNull is a true or false reference

Or, you can change the path to the template set in the global

Any Clearer?

John


Alex code from above

sub {
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 8');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}

Last edited by:

gatman: Dec 14, 2002, 6:48 AM
Quote Reply
Re: [gatman] Newest Links Global In reply to
I'm still not quite clear about this.

$output .= Links::SiteHTML::display ('link1', $link);

As far as I am aware, this line will display the link1.html template from the template set that you are currently in - even if it isn't default. If you are looking at a page such as http://www.mydomain.com/...bin/page.cgi?t=other then it will display link1 from the template set 'other'.
Quote Reply
Re: [afinlr] Newest Links Global In reply to
In Reply To:
... will display the link1.html template from the template set that you are currently in - even if it isn't default.
and the Home Page is the default set and you want to display the newest links from template set 2 or template set 3
Quote Reply
Re: [gatman] Newest Links Global In reply to
I may be missing something here Tongue but I didn't think that links were associated with template sets. Do you mean that you have different installations of Links which are each displayed with a different template set? I'm sure that what you are trying to do is easily solvable I'm just being very slow in understanding what it is!
Quote Reply
Re: [afinlr] Newest Links Global In reply to
Why stop with a "default" template for a category... why can't a like have an overriding template as well ;)

No demo site set up, but I have a beta working on this which will change called templates based on fields in the link, to allow proper display. Actually, my "slide view" pages used a version of this.

For instance, a vertical vs horizontal image. An "image" link vs a classified. Etc.

"include" files don't always work right.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
> >