Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Short review_contents in "all reviews"-global

Quote Reply
Short review_contents in "all reviews"-global
Hi,
I'm using the global below, to show the title of all reviews on a page.
Is it possible to show a short part (50 signs) of the review (Review_Contents) under each title? May be with a link called "more" to the whole review?

The global All_Reviews

Code:
sub {
my (@links,$sth,$link);
my $search_db = $DB->table('Links','Reviews');
$search_db->select_options ("ORDER BY Review_Date DESC");
$sth = $search_db->select ( { Review_Validated => 'Yes' });
while (my $link = $sth->fetchrow_hashref()) {
if (length $link->{Title} > 70) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';}
$link = Links::SiteHTML::tags('link', $link);
push@links, $link;
}
return {All_Reviews=>\@links};<br>
}



And the loop in the template

Code:
<p><%All_Reviews%>
<%loop All_Reviews%>
<a href="<%config.db_cgi_url%>/review.cgi?ID=<%ID%>"><%Title%></a><br>
<img src="<%Links::Utils::image_url("stars-5-${Review_Rating}.gif")%>" align="top" title="<%Review_Rating%> von 5" />
<b><%Review_Subject%></b> von <%if Review_GuestName%><%Review_GuestName%><%else%><%Review_Owner%><%endif%>
<a href="<%config.db_cgi_url%>/review.cgi?ID=<%ID%>"></a><br/><br/>
<%endloop%>
</p>


Thanks
Matthias

Matthias
gpaed.de

Last edited by:

Matthias70: Oct 23, 2007, 10:56 AM
Quote Reply
Re: [Matthias70] Short review_contents in "all reviews"-global In reply to
Hi Matthias,

Below should work

Matthias70 wrote:


The global All_Reviews

Code:
sub {
my (@links,$sth,$link);
my $search_db = $DB->table('Links','Reviews');
$search_db->select_options ("ORDER BY Review_Date DESC");
$sth = $search_db->select ( { Review_Validated => 'Yes' });
while (my $link = $sth->fetchrow_hashref()) {
if (length $link->{Title} > 70) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';}
$link = Links::SiteHTML::tags('link', $link);
if (length $link->{Review_Contents} > 50) {
$link->{Review_Contents} = substr($link->{Review_Contents}, 0, 50) . '...';}
push@links, $link;
}
return {All_Reviews=>\@links};

}



And the loop in the template

Code:
<p><%All_Reviews%>
<%loop All_Reviews%>
<a href="<%config.db_cgi_url%>/review.cgi?ID=<%ID%>"><%Title%></a>

<img src="<%Links::Utils::image_url("stars-5-${Review_Rating}.gif")%>" align="top" title="<%Review_Rating%> von 5" />
<b><%Review_Subject%></b> von <%if Review_GuestName%><%Review_GuestName%><%else%><%Review_Owner%><%endif%>

<%Review_Contents%>&nbsp;
<a href="<%config.db_cgi_url%>/review.cgi?ID=<%ID%>">more</a><br/><br/>
<%endloop%>
</p>


Thanks
Matthias

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Short review_contents in "all reviews"-global In reply to
tandat wrote:
Hi Matthias,

Below should work

Hi Dat,
yes it works perfect Smile
Thanks for your help

Matthias

Matthias
gpaed.de
Quote Reply
Span pages in "all reviews" global In reply to
By the way, I've never seen it before,
but is there a way to have span pages in this all reviews global?

Thanks
Matthias

Matthias
gpaed.de