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

check if user has reviews

(Page 1 of 2)
> >
Quote Reply
check if user has reviews
Hi,
I'm trying to show on detailed.html a link to the reviews of the LinkOwner.
I'm also trying to check, if this user has a review.
The link to his reviews should only be shown, if he has written at least one review?

But the following code shows nothing?

Code:
<%if Reviews%>
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
<%endif%>

Any ideas how to fix this?
Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi,

Sorry, not sure what your trying to do? Just see if there are any reviews for a link, or any reviews made for a link, by the current person logged in?

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] check if user has reviews In reply to
Hi Andy,
on every detail page I have the name of the linkowner. Beside this name I have a link to his profile and a link to all other entries of this user.
Now I want also a link to all reviews this user made.
That's easy, I just can use this code
Code:
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>

BUT
I want to show the link to the reviews of a user only if there are already some reviews by this user.
Because it does'nt make sense, when other users click on "show reviews of this user" and the just see "There are no reviews by this user" on the next page.
So I tried this code
Code:
<%if Reviews%>
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
<%endif%>
But that does not work

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi,

There are som ways to do that. Below is one of them.

<%set LinkOwner_Reviews = 0%>
<%loop Review_Loop~%>
<%if Review_Owner eq $LinkOwner%>
<%set LinkOwner_Reviews = 1%>
<%lastloop%>
<%endif%>
<%~endloop%>


<%if LinkOwner_Reviews>0%>
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
<%endif%>

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] check if user has reviews In reply to
Hi Dat,
that is only half the way I need it.
Your code shows this link
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
BUT
only if the user comments his own link.

I need a global, that checks, if the user wrote some reviews on his own links AND on other links.

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi Matthias,

I see. Below is the global

sub {

return $ret unless(defined $USER and $USER->{Username});

my $cond = GT::SQL::Condition->new('Review_LinkOwner' => '=' => $USER->{Username});
my $c = $DB->table("Reviews")->count($cond);
return {review_count => $c};

}

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] check if user has reviews In reply to
Hi Dat,
I'm getting an error Frown
Unable to compile 'review_count': Global symbol "$ret" requires explicit package name at (eval 86) line 3

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Try this please!


sub {

return unless(defined $USER and $USER->{Username});

my $cond = GT::SQL::Condition->new('Review_LinkOwner' => '=' => $USER->{Username});
my $c = $DB->table("Reviews")->count($cond);
return {review_count => $c};

}

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] check if user has reviews In reply to
Hi,

Or simpler (and shorter) Smile

Code:
sub {
return unless(defined $USER and $USER->{Username});
return { review_count_num => $DB->table("Reviews")->count( { Review_LinkOwner => $USER->{Username} } ) || 0 }
}

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!

Last edited by:

Andy: Mar 5, 2008, 7:48 AM
Quote Reply
Re: [Andy] check if user has reviews In reply to
Hi Dat,
there is no out put with your global. Or do I have to go ahead with $c in the template like <%if c > 0%>Reviews<%endif%> ???


Hi Andy,
I get the following error with your code
Code:
Unable to compile 'review_count': syntax error at (eval 85) line 4, at EOF Missing right curly or square bracket at (eval 85) line 4, at end of line


Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Whoops, try the modified version =)

Regarding your other question - this should work:

<%if review_count_num > 0%>
they have a review
<%endif%>

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] check if user has reviews In reply to
Hi Andy,
tried your changed global.
There are no errors anymore but now there is no output :-(

Just looking for mistakes on my side
I made a global with your code called "review_count"
I call this global with the following line.

<%review_count%><%if review_count_num > 0%><a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a><%endif%><br />

Should be all right?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi,

Mmm.. looks right.

Try changing:

Code:
return unless(defined $USER and $USER->{Username});

..to:

Code:
if (!$USER->{Username}) { return ''; }

Any difference?

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] check if user has reviews In reply to
Andy wrote:
Hi,

Mmm.. looks right.

Try changing:

Code:
return unless(defined $USER and $USER->{Username});


..to:

Code:
if (!$USER->{Username}) { return ''; }


Any difference?


Yes Unsure with this change there is an error
Code:
Unable to compile 'review_count': syntax error at (eval 85) line 4, at EOF Missing right curly or square bracket at (eval 85) line 4, at end of line
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Sorry, been a long day - should be:

if (!$USER->{Username}) { return ''; } }

..not:

if (!$USER->{Username}) { return ''; }

Sorry about that.

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] check if user has reviews In reply to
Hi Andy,
now we have this error :-)

Code:
Unable to compile 'review_count': syntax error at (eval 85) line 3, near "} return"

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Mmm.. can you paste the global you have? Shouldn't give that error.

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] check if user has reviews In reply to
 
Hi Andy,
here's the global

Code:
sub {
if (!$USER->{Username}) { return ''; }}
return { review_count => $DB->table("Reviews")->count( { Review_LinkOwner => $USER->{Username} } ) || 0;
}

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi,

You're missing the change I said to do before the last one <G>

This shouldn't give any errors:

Code:
sub {
if (!$USER->{Username}) { return ''; }
return { review_count => $DB->table("Reviews")->count( { Review_LinkOwner => $USER->{Username} } ) || 0 };
}

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!

Last edited by:

Andy: Mar 5, 2008, 8:50 AM
Quote Reply
Re: [Andy] check if user has reviews In reply to
Hi Andy,
sorry for that.
Now there is no error but when I use the following code in detail.html there is still no output

Code:
<%review_count%>
<%if review_count > 0%>
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
<%endif%>

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Aaah, I think I see the problem :P


Try this:

Code:
sub {
if (!$_[0]) { return ''; }
return { review_count_num => $DB->table("Reviews")->count( { Review_LinkOwner => $_[0] } ) || 0 };
}

..then call with:

Code:
<%review_count($LinkOwner)%>
<%if review_count_num > 0%>
<a href="<%config.db_cgi_url%>/review.cgi?username=<%LinkOwner%>">Reviews</a>
<%endif%>

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!

Last edited by:

Andy: Mar 5, 2008, 9:03 AM
Quote Reply
Re: [Andy] check if user has reviews In reply to
Hi Andy,
there is still no output :-(

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
How about the new code?

http://www.gossamer-threads.com/...?post=300935#p300935

global and template codes are changed, so update both.

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] check if user has reviews In reply to
Hi Andy,
nothing changed, still no output :-(
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi,

You wanna send me an example link ID, and I'll take a look on your install :) Also, the URL you are looking at the output, to see if it shows :)

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!
> >