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

Get Latest Review on Detailed Page

(Page 1 of 2)
> >
Quote Reply
Get Latest Review on Detailed Page
How would I add 1 review on my detailed page,

I want it to be:

- The most helpful

- The latest

So if there are 2 reviews with the same helpfulness then the latest is shown and if there are no reviews which were helpful then the latest is shown

I would guess someone tried to do this already, but alas the search engine doesnt like me. =)
Quote Reply
Re: [kzap] Get Latest Review on Detailed Page In reply to
The latest, you could do something like;

Code:
sub {

my $table = $DB->table('Reviews');
$table->select_options('ORDER BY Review_Date','LIMIT 1');
my $sth = $table->select() || return $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
return Links::SiteHTML::display('review_link_show', $hit);
}

}

Then create a new template, called 'review_link_show'.... you can use any of the review tags...ie Review_Subject, Review_Contents, etc.

Untested, but it should work :)

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: [Andy] Get Latest Review on Detailed Page In reply to
Hmm that would work for getting the latest out of all reviews but I'm going to have this review on my detailed page, so I would need the latest review for that ID and if there is no review then nothing should show?

Last edited by:

kzap: Sep 15, 2003, 11:01 PM
Quote Reply
Re: [kzap] Get Latest Review on Detailed Page In reply to
Sorry, try this;

Code:
sub {

my $ID;

my $table = $DB->table('Reviews');
$table->select_options('ORDER BY Review_Date','LIMIT 1');
my $sth = $table->select( { Review_LinkID => $ID } ) || return $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
return Links::SiteHTML::display('review_link_show', $hit);
}

}

You should be able to call it on detailed.html, with <%global_name($ID)%>

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: [Andy] Get Latest Review on Detailed Page In reply to
ok thanks, little correction

my $ID = shift; instead of just my $ID;

One more question though, I can't access $Title on the review_link_show, how would I get the name of the link on the page also?
Quote Reply
Re: [kzap] Get Latest Review on Detailed Page In reply to
Whoops.. your right.. sorry. I only just got online when I wrote that.. so my head wasn't quite screwed on...LOL

Regarding the tags.. just do a <%GT::Template::dump%> in that template,and it will show you a list of available tags :)

I think its either Review_Subject or Review_Title...

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: [Andy] Get Latest Review on Detailed Page In reply to

Nope there is no Review_Title to get the title of the link being reviewed, there is a Review_LinkID, so using Review_LinkID, how do i get the Title of the Link?


Quote Reply
Re: [kzap] Get Latest Review on Detailed Page In reply to
How about Review_Subject?

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: [Andy] Get Latest Review on Detailed Page In reply to
Review subject is the subject of the review, but not the name of the link being reviewed

i dunno its weird, not all the variables of review_search_results are available
Quote Reply
Re: [kzap] Get Latest Review on Detailed Page In reply to
Aaah.. I see. You could try a global at the top of the template, which would grab the links details....


<%grab_link_details($Review_LinkID)%>

Code:
sub {

my $ID = shift;

my $sth = $DB->table('Links')->select( { ID => $ID } );

my @link_loop;
while (my $hit = $sth->fetchrow_hashref) {
push(@link_loop,$hit);
}

return { link_loop => \@link_loop };

}

That should then give you a loop for the link.. which you can access with;

Code:
<%loop link_loop%>
<%Title%>
<%Description%>
<%URL%>
...etc
<%endloop%>

Untested, but it should work :)

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: [Andy] Get Latest Review on Detailed Page In reply to
got it. thanks =)
Quote Reply
Re: [Andy] Get Latest Review on Detailed Page In reply to
Andy,

I'm trying to implement this global but keep on getting:

Error: Variable 'review_detail_page' is not a code reference

Here's my global:
Code:
sub {

my $ID = shift;

my $table = $DB->table('Reviews');
$table->select_options('ORDER BY Review_Date','LIMIT 1');
my $sth = $table->select( { Review_LinkID => $ID } ) || return $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
return Links::SiteHTML::display('review_link_show', $hit);
}

}

I'm calling the global with: <%review_detail_page($ID)%>

LinksSQL 2.1.3

Any idea why this is? Thanks.

Safe swoops
Sangiro

Last edited by:

sangiro: Oct 23, 2003, 11:30 PM
Quote Reply
Re: [sangiro] Get Latest Review on Detailed Page In reply to
Double check the name of the sub you made. I think that message basically means the global doesn't seem to exist.

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: [sangiro] Get Latest Review on Detailed Page In reply to
Also double check that you have no leading space. The first four characters of the global must be

sub {

with no spaces before it, or it won't think it's a subroutine.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Get Latest Review on Detailed Page In reply to
Gents,

The global name is definitely correct and there are no leading spaces around sub.... Some thing else here?

Alex - could this have anything to do with the fact that my DB and scripts are now on different machines? Just throwing out ideas....

Reason why I'm asking is becasue the global below, which used to work, now throws the same error. This global builds a "bread crumb trail" for the title on the reviews pages.

Quote:
sub {
my $link_id = shift;
my $title_comment = shift;

my $link_db = $DB->table('Links');

my $link = $link_db->select({ ID => $link_id })->fetchrow_hashref;
my ($cat_id, $cat_name) = each %{$link_db->get_categories ($link->{ID})};
my $title = Links::Build::build ('title_linked', { name => "$cat_name",
home => 1,
complete => 1 });
$title .= qq~ : <a href ="$CFG->{build_detail_url}/$link->{ID}$CFG->{build_extension}">$link->{Title}</a> : ~;
$title .= $title_comment;

return $title;
}

Calling this with: <%review_title_linked($ID, 'Reviews')%>

Safe swoops
Sangiro

Last edited by:

sangiro: Oct 24, 2003, 3:32 PM
Quote Reply
Re: [Alex] Get Latest Review on Detailed Page In reply to
Alex,

I have gotten around to this again and updated this global to look like this:

Code:
sub {
#show_reviews
my $ID = shift;
my ($output);
my $table = $DB->table('Reviews') || return $GT::SQL::error;
$table->select_options('ORDER BY Review_Date DESC','LIMIT 3') || return $GT::SQL::error;
my $sth = $table->select( { Review_LinkID => $ID } ) || return $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('review_link_show', $hit) || return $GT::SQL::error;
}
return $output;
}

Here's the weird thing about it... it built perfectly fine the first time I ran it and the second build gave me the same error again. Crazy

Safe swoops
Sangiro

Last edited by:

sangiro: Jul 5, 2004, 9:14 AM
Quote Reply
Re: [sangiro] Get Latest Review on Detailed Page In reply to
Quote:
I ran it and the second build gave me the same error again.

What error? Unsure (just looked over the whole thread, and couldn't find one mentioned?)

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: [Andy] Get Latest Review on Detailed Page In reply to
Error: Variable 'review_detail_page' is not a code reference

(in my first post in this thread) Smile

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Get Latest Review on Detailed Page In reply to
Sorry, I was looking for a more detailed error Blush

Do your error logs give anything helpful?

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: [Andy] Get Latest Review on Detailed Page In reply to
Nope! Nothing there. This is all I get. I find it particularly weird that this actually worked, and then stopped working wirth no interference whatsoever... Crazy

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Get Latest Review on Detailed Page In reply to
Indeed Unsure

I just tried it via SSH, and it came up as "syntax ok" .... I'm confused Unimpressed

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: [sangiro] Get Latest Review on Detailed Page In reply to
Quote:
Error: Variable 'review_detail_page' is not a code reference

There is currently an issue with running Links SQL 2.1.x with any of our recent programs under mod_perl. The template parser changed and is no longer backwards compatible. The best solution is to upgrade to Links SQL 2.2 which will fix this.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Get Latest Review on Detailed Page In reply to
Aaaah! Thanks Alex. I'll stop spinning my wheels on this then. Smile

Safe swoops
Sangiro
Quote Reply
Re: [Alex] Get Latest Review on Detailed Page In reply to
Ok - got this to work after the upgrade, thanks.

Is there a reason why the <%Num%> tag is not working on the detailed page? All other review tags seem to be fine.

Code:
7 of Unknown Tag: 'Num' people found the following review helpful:

Safe swoops
Sangiro
Quote Reply
Re: [Andy] Get Latest Review on Detailed Page In reply to
I added this to my detailed pages and it looks pretty good. I do want to point out that the review will appear before you have validated it.
> >