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

Ultra Globals, Users_Listings

Quote Reply
Ultra Globals, Users_Listings
I have a main listing with the URL as a hook to other attached documents to that listing.
Say the detailed.html is a person, with the URL defined as 12345. That person has other associated files, also built separately with detailed.html but linked within each other with a search specificly "12345". This URL is unique to each person.
Then I display a link on the persons detailed.html which does a search to 12345, and in the regular search form everything asociated with "12345" is displayed.

Perhaps, using this code, I can instead of linking to the LinkOwner, we can get files that belong to URL12345.
Using the Contact_Name would be just as good.

Possible?

Thanks,

Juan Carlos




Code:
# Users_Listings[/url]
This global will get a list of the users links, and also separately the links ordered by rating, and also by hits.
<%Plugins::ULTRAGlobals::Users_Listings($LinkOwner)%>
..or to get as list of links owned by the current logged in user, use:
<%Plugins::ULTRAGlobals::Users_Listings($LinkOwner)%>
Then, in the template (after the above code) - you can use:
<h2>Users Links</h2>
<%if user_links.length%>
<%loop user_links%>
<%include link.html%>
<%endloop%>
<%else%>
<p>No links.</p>
<%endif%>

<h2>Users Links By Hits</h2>
<%if user_links_by_hit.length%>
<%loop user_links_by_hit%>
<%include link.html%>
<%endloop%>
<%else%>
<p>No links.</p>
<%endif%>

<h2>Users Links By Rating</h2>
<%if user_links_by_rating.length%>
<%loop user_links_by_rating%>
<%include link.html%>
<%endloop%>
<%else%>
<p>No links.</p>
<%endif%>

Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Hi,

Ok, I'm not 100% sure what you mean here. Are you saying (for example), a user has a URL of 12345 - and they also have several other listing with the same URL (and you want to get the listings, something like WHERE URL = 1234) .. is that right?

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] Ultra Globals, Users_Listings In reply to
Yeah, I think you got it. The common denominator between them is the URL field or the Contact_Name field.

JC
Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Hi,

Untested, but try:

users_listings
Code:
sub {

my $user1 = $_[0];

# normal links
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC','LIMIT 3') || die $GT::SQL::error;

my $sth = $link_db->select( { isValidated => "Yes", URL => $user1] } ) || die $GT::SQL::error;

my @links;

# just normal links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links, $link;
}

# ratings
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY Rating DESC', 'LIMIT 10') || die $GT::SQL::error;

my $sth = $link_db->select( { isValidated => "Yes", ID => $user1 } ) || die $GT::SQL::error;

my @links2;
# just top rated links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links2, $link;
}

# ratings
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY Hits DESC', 'LIMIT 10') || die $GT::SQL::error;


my $sth = $link_db->select( { isValidated => "Yes", ID => $user1 } ) || die $GT::SQL::error;

my @links3;
# just top rated links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links3, $link;
}

return { user_links => \@links , user_links_by_hit => \@links3, user_links_by_rating => \@links2 }

}

...call with:

Code:
<%users_listings($URL)%>
<%if user_links.length%>
<%loop user_links%>
<%include link.html%>
<%endif%>
<%endif%>

(etc)

Untested, but should work fine =)

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] Ultra Globals, Users_Listings In reply to
Im getting the following error on the page:

Unable to compile 'users_listings': syntax error at (eval 39) line 9, near "$user1]" Global symbol "$sth" requires explicit package name at (eval 39) line 14. Global symbol "$user1" requires explicit package name at (eval 39) line 23. Global symbol "$user1" requires explicit package name at (eval 39) line 37. Unmatched right curly bracket at (eval 39) line 48, at end of line syntax error at (eval 39) line 48, near "} }"
Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Sorry - was a typo - serves me right for trying to reply pissed :P

Change:

my $sth = $link_db->select( { isValidated => "Yes", URL => $user1] } ) || die $GT::SQL::error;

...to:

my $sth = $link_db->select( { isValidated => "Yes", URL => $user1 } ) || die $GT::SQL::error;

Hopefully that will sort it =)

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] Ultra Globals, Users_Listings In reply to
Worked great!

Thank you Andy
Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Hmm spoke too soon... Workes great in dynamic mode.... but doesnt work in static.
Its missing the directory where files are built in.

Sample should be: http://www.site.com/detailed/something/other/page_1234.html
Its building: http://www.site.com/something/other/page_1234.html

So all links are broken. Doesnt happen in dynamic only in static.

Any ideas?
Here is my loop:

Code:
<%users_listings($URL)%>
<%if user_links.length%>
<ul style="text-align: left">
<%loop user_links%>
<li><%include link.html%></li>
<%endloop%>
</ul>
<%endif%>


Here is the global:

Code:
sub {

my $user1 = $_[0];

# normal links
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC','LIMIT 300') || die $GT::SQL::error;

my $sth = $link_db->select( { isValidated => "Yes", URL => $user1 } ) || die $GT::SQL::error;

my @links;

# just normal links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links, $link;
}

# ratings
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY Rating DESC', 'LIMIT 10') || die $GT::SQL::error;

my $sth = $link_db->select( { isValidated => "Yes", ID => $user1 } ) || die $GT::SQL::error;

my @links2;
# just top rated links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links2, $link;
}

# ratings
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY Hits DESC', 'LIMIT 10') || die $GT::SQL::error;


my $sth = $link_db->select( { isValidated => "Yes", ID => $user1 } ) || die $GT::SQL::error;

my @links3;
# just top rated links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links3, $link;
}

return { user_links => \@links , user_links_by_hit => \@links3, user_links_by_rating => \@links2 }

}

anyone see where its missing something?

Thanks,

Juan Carlos
Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Hi,

Please change instances of:
Code:
$CFG->{build_root_url}

..with:

Code:
$CFG->{build_detail_path}

That should sort it =)

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] Ultra Globals, Users_Listings In reply to
Hmmm not working... its added the actual linux full pwd path, plus the http path.. very funky..
Ill PM you a URL so you can see it.

Thanks Andy.
Quote Reply
Re: [Gorospe] Ultra Globals, Users_Listings In reply to
Sorry, I mean't:

$CFG->{build_detail_url}

...not

$CFG->{build_detail_path}

Been a loooong day =)

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] Ultra Globals, Users_Listings In reply to
Worked great Andy.

Thanks

Juan Carlos
Quote Reply
Re: [Andy] Ultra Globals, Users_Listings In reply to
Hi Andy

I use your global normal links on the detail page.
But, I would like to exclude the current link.

I think that I must use a condition :

Code:
# normal links
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC','LIMIT 5') || die $GT::SQL::error;
my $linkID = $DB->table('Links')->select({LinkID=>$id})->fetchrow_hashref->{ID};
my $cond = GT::SQL::Condition->new('LinkID','<>',$id);

my $sth = $link_db->select($cond,{ isValidated => "Yes", LinkOwner => $user1 } ) || die $GT::SQL::error;
my @links;
Do You think that it is possible?

Thanks for your suggestion.

Mick
Quote Reply
Re: [MJ_] Ultra Globals, Users_Listings In reply to
Hi,

In the function, you would need to pass in $ID as a 2nd paramtater to the loading global ... then the sub would be something like:

Code:
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC','LIMIT 5') || die $GT::SQL::error;
my $sth = $link_db->select( GT::SQL::Condition->new('LinkID','<>',$_[1]) ,{ isValidated => "Yes", LinkOwner => $user1 } ) || die $GT::SQL::error;
my @links;

Hope that helps

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] Ultra Globals, Users_Listings In reply to
Hi Andy,

That does not function for me. I always have : No link.

An idea ?

Thanks again,

Mick

Last edited by:

MJ_: Oct 17, 2011, 8:29 AM
Quote Reply
Re: [MJ_] Ultra Globals, Users_Listings In reply to
What is the whole sure you are using? and its name... also how you are calling it.

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] Ultra Globals, Users_Listings In reply to
Hi Andy,

> also how you are calling it.

<h2>Users Links</h2>
<%if user_links.length%>
<%loop user_links%>
<%include link.html%>
<%endloop%>
<%else%>
<p>No links.</p>
<%endif%>

Thanks,

Mick
Quote Reply
Re: [MJ_] Ultra Globals, Users_Listings In reply to
I need the bit before (the global being called), and also the whole "global" you are using Wink

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] Ultra Globals, Users_Listings In reply to
Oops!

I use your ULTRA plugin :

Code:
my $user1 = $_[0] || $USER->{Username};
# normal links
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC','LIMIT 3') || die $GT::SQL::error;
my $sth = $link_db->select(GT::SQL::Condition->new('LinkID','<>',$_[1]), { isValidated => "Yes", LinkOwner => $user1 } ) || die $GT::SQL::error;
my @links;
# just normal links.
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $link->{ID} );
push @links, $link;
}

Thanks,

Mick
Quote Reply
Re: [MJ_] Ultra Globals, Users_Listings In reply to
Ok, so you need to call it like:

Code:
<%Plugins::ULTRAGlobals::Users_Listings($LinkOwner,$ID)%>

..and that should work then

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] Ultra Globals, Users_Listings In reply to
You are the best! Smile

Thanks for your patience!

Mick