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

check if user has reviews

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!
Quote Reply
Re: [Andy] check if user has reviews In reply to
Hi,

LOL - sorted it. It needed Review_Owner, *not* Review_LinkOwner Wink

Code:
sub {
if (!$_[0]) { return; }
return { review_count_num => $DB->table("Reviews")->count( { Review_Owner => $_[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!
Quote Reply
Re: [Andy] check if user has reviews In reply to
Hi Andy,
works perfect Smile
This global should be in Ultra globals package.
I wonder why I was the first asking for it.

Thanks a lot.
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Hi Andy,
I'm having some trouble to get this code working.
Can you have a look at it?
All parts work fine, only the red part has no effect...

Code:
<%Plugins::ULTRAGlobals::See_If_User_Has_Reviews($LinkOwner)%>
<%if isHome eq 1 and Jump_Clicks > 500 and user_links_number < 7 and review_count_num < 5%>

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Matthias70 wrote:
Hi Andy,
I'm having some trouble to get this code working.
Can you have a look at it?
All parts work fine, only the red part has no effect...

Code:
<%Plugins::ULTRAGlobals::See_If_User_Has_Reviews($LinkOwner)%>
<%if isHome eq 1 and Jump_Clicks > 500 and user_links_number < 7 and review_count_num < 5%>

Upps, I just saw in the global descripition, that it will work only in detailed.html and link.html.
Is there a way to run it in the sidebar?

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
What do you see with <%review_count_num%>

?

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:
What do you see with <%review_count_num%>

?

Cheers

<%review_count_num%> shows Unknown Tag: 'review_count_num' in the rightsidebar.html ;-)

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Mmm, what template is this in? The only reason I can see it would do that, is with:

Code:
if (!$_[0]) { return; }

...i.e if $LinkOwner isn't being passed in properly...

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:
Mmm, what template is this in?

The template is called include_rightsidebar.html
Can you tell me where to put this part
Code:
if (!$_[0]) { return; }

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
You don't need to put that code anywhere. I was just explaining why it may be empty.

So whats the value of <%LinkOwner%> ?

..and how *exactly* are you calling the function?

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:
You don't need to put that code anywhere. I was just explaining why it may be empty.

So whats the value of <%LinkOwner%> ?

..and how *exactly* are you calling the function?

Cheers


<%LinkOwner%> is an unknow tag in include_rightsidebar.html, too

I'm calling it this way:
Code:
<%Plugins::ULTRAGlobals::See_If_User_Has_Reviews($LinkOwner)%>
<%if review_count_num > 5 and Jump_Clicks > 500 and user_links_number > 7%>
TEXT
<%endif%>




By the way, I have another idea for a Plugin. Don't know if there is a way but what do you think about this community activity plugin ;-)

Is there a way to check the time, when a user added a link or added a review.
Should be used like this:
<%if last_link older 1year and last review older than 1year%>
It's been a long time, what about supporting the community. Write a review or add a new link...
<%endif%>

Thanks

Matthias
gpaed.de

Last edited by:

Matthias70: Jun 15, 2010, 5:27 AM
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Ok, well thats your problem them ;) $LinkOwner is required (as it should exist in both link.html, detailed.html etc) ...

Quote:
Is there a way to check the time, when a user added a link or added a review.
Should be used like this:
<%if last_link older 1year and last review older than 1year%>
It's been a long time, what about supporting the community. Write a review or add a new link...
<%endif%>

Sure, could be done - but afraid I don't have time to do anything like that at the moment =) Would just need to grab the latest LinkID and ReviewID, and then do a GT::Date::date_diff() to see how many days ago that was :)

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:
Ok, well thats your problem them ;) $LinkOwner is required (as it should exist in both link.html, detailed.html etc) ...
Quote:

O:K. then I will try to integrate this code into detail.html ;-)

Is there a way to check the time, when a user added a link or added a review.
Should be used like this:
<%if last_link older 1year and last review older than 1year%>
It's been a long time, what about supporting the community. Write a review or add a new link...
<%endif%>


Sure, could be done - but afraid I don't have time to do anything like that at the moment =) Would just need to grab the latest LinkID and ReviewID, and then do a GT::Date::date_diff() to see how many days ago that was :)
Cheers

No Problem :-) Can I remember you on this at a day without world cup games Wink

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Quote:
Can I remember you on this at a day without world cup games

Huh? :P

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
Sometimes the easy way is the best ;-)
Now I'm using this global:

review_count
Code:
sub { return $DB->table('Reviews')->count( { Review_Owner => $USER->{Username} } ); }

With the above global this code is working everywhere...
Code:
<%if review_count > 5 and Jump_Clicks > 500 and user_links_number > 7%>
TEXT
<%endif%>

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] check if user has reviews In reply to
Erm, well if you were trying to do that, why didn't you just do:

<%Plugins::ULTRAGlobals::See_If_User_Has_Reviews($user.Username)%>

;)

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:
Erm, well if you were trying to do that, why didn't you just do:

<%Plugins::ULTRAGlobals::See_If_User_Has_Reviews($user.Username)%>

;)

Cheers

Hey Andy, you are the coder, not me Wink
Thanks

Matthias
gpaed.de