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

[ FREE PLUGIN ] ULTRAGlobals - Collection of Globals and routines

(Page 7 of 10)
> > > >
Quote Reply
Re: [katakombe] The most popular categories In reply to
Hi,

I've been having a think/look at this for you. I'm not really sure whats the best way to approach it. For example, its easy enough to just do:

SELECT * FROM glinks_Category WHERE CatDepth = 1 ORDER BY Number_of_Links DESC LIMIT 10

..which would grab the top level categories, with the highest number of links.

However, trying to "dig" into those sub-categories it quite a bit more difficult/confusing.

If you don't mind just a basic category list, with the top categories (at root level), then I can write you a global for that - but I don't really have time to play around with the other one =)

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] The most popular categories In reply to
Hi Andy!

Thanks, no problem ..

You can do as you want (if you have some spare time), but in my opinion, this version with subcategories is much better, because theoretically there can be 0 links when someone click on a main category - all "clickable" links can be hidden in subcategories. It will be much easier for visitors to go directly there where are most of the links.

Thanks again Smile
Quote Reply
Re: [katakombe] The most popular categories In reply to
Hi,

Untested, but give this a go;

get_top_cat_loop
Code:
sub {
my $tbl = $DB->table('Category');
$tbl->select_options("ORDER BY Number_of_Links DESC LIMIT 10");

my $sth = $tbl->select( GT::SQL::Condition->new('Direct_Links','>','0','FatherID,'=','0') ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . '/' . $tbl->as_url($hit->{Full_Name}) . '/' . $CFG->{build_index};
push @loop, $hit;
}
return { top_cat_loop => \@loop }
}


..then call with:

Code:
<%get_top_cat_loop%>
<ul>
<%loop top_cat_loop%>
<li><a href="<%URL%>"><%Name%></a></li>
<%endloop%>
</ul>

Hopefully that'll 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!

Last edited by:

Andy: Oct 8, 2008, 8:01 AM
Quote Reply
Re: [Andy] The most popular categories In reply to
Thanks Andy, as usual, it works Smile

The thing is that in this case there are categories with 0 "clickable" links, all are located in subcategories.

Anyhow, thanks again. Maybe you'll find another solution later.
Quote Reply
Re: [katakombe] The most popular categories In reply to
Hi,

Try the above modified version. I've made a little change to it (it will only get categories that have at least 1 clickable link at their own level :)

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] The most popular categories In reply to
Sorry Andy, there is no result at all now Unsure
Quote Reply
Re: [katakombe] The most popular categories In reply to
Oops, I think I see the error. Please change:

GT::SQL::Condition->new('Direct_Links','>','0','FatherID,'=','0')

..to:

GT::SQL::Condition->new('Direct_Links','>','0','FatherID','=','0')

(it was missing a ' =))

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] The most popular categories In reply to
Hi Andy!

Much better, but now there are only top-level categories with 1 (or 1+) link without subcategories.
Quote Reply
Re: [katakombe] The most popular categories In reply to
Just remove 'FatherID','=','0' - and that should do the trick =)

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] The most popular categories In reply to
Yap Wink

OK, this is good. Anyhow, the best solution is to count only links - i.e. I can see a category or a subcategory with "less" links above an another with "more" links which can be confusing, but that can wait Smile
Quote Reply
Re: [Andy] The most popular categories In reply to
Hello Andy

Just got to try your plug in.. pretty nice..

Several small globals that I use, they may be worth assing..

All user list

sub {
# Displays all Users.
my $tags=shift;
my $search_db= $DB->table('Users');
my $nh = (ref $tags->{nh} ? ${$tags->{nh}} : $tags->{nh});
my $mh = (ref $tags->{maxhits} ? ${$tags->{maxhits}} : $tags->{maxhits});
my $offset = ($nh-1) * $mh;
$search_db->select_options ('ORDER BY Username ASC',"LIMIT $offset, $mh");
my $sth = $search_db->select;
my $output;
while (my $user = $sth->fetchrow_hashref) {
$output .= qq~<li><a href="$CFG->{db_cgi_url}/page.cgi?page=user&user=$user->{Username}">$user->{Username}</a></li> ~;
}
return $output;
}


All links in a given category

sub {
# all links in a given category.
require Links::SiteHTML;
my $catID = $_[0];
my $catname = $DB->table('Category')->select( ['Full_Name'], { ID => $catID } )->fetchrow;
my $cond = GT::SQL::Condition->new(
Full_Name => '=' => "$catname",
Full_Name => 'LIKE' => "$catname/%"
);
$cond->bool('OR');
my $cat_tbl = $DB->table('Category');
$cat_tbl->select_options('ORDER BY Full_Name DESC');
my $sth = $cat_tbl->select( $cond ) || die $GT::SQL::error;
my $output;
while (my $hit = $sth->fetchrow_hashref) {
my $links_sth = $DB->table('CatLinks')->select( { CategoryID =>$hit->{ID} } ) || die $GT::SQL::error;
while (my $hit2 = $links_sth->fetchrow_hashref) {
my $hit3 = $DB->table('Links')->get($hit2->{LinkID});
$output .= Links::SiteHTML::display('link', $hit3);
}
}
return $output;
}





Random link from a given category

sub {
my ($output,$sth,$hash,$cond);
my $catid = $_[0];
my $limit = $_[1] || 4;
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY rand()", "LIMIT $limit");
my $all_ids = $DB->table('Category')->children($catid);
push @$all_ids, $catid;
$cond = GT::SQL::Condition->new('isValidated','=','Yes', 'CategoryID', 'IN', $all_ids);
$sth = $search_db->select ($cond);
while ($hash = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $hash);
}
return $output;
}



Directory map: a simple map of top few levels of directory
sub {
# will build a map for the directory.
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ( { FatherID => 0}, ['Full_Name','ID','Name'] );
my $output=qq~<table>~;
my $i=0;
while (my ($root_cat,$ID,$heading) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<tr valign=top><td width="100%" colspan="2"><h3><b><a href="$CFG->{build_root_url}/$url1">$heading</a></b></h3></td></tr>~;
$cat_db->select_options ('ORDER BY Full_Name');
my $sth2 = $cat_db->select ( { FatherID => $ID}, ['Full_Name','ID','Name'] );
while (my ($cat,$id,$heading1) = $sth2->fetchrow_array) {
# my $link_count = $DB->table('CatLinks')->count ( {CategoryID => $id});
my $url = $cat_db->as_url($cat);
$output .= qq~<tr valign=top><td width="25%">&nbsp;</td><td width="75%"><a href="$CFG->{build_root_url}/$url">$heading1</a></td></tr>~; }
}
$output.="</table>";
return $output;
}




grand_total_cat
sub { return $DB->table('Category')->count; }

grand_total_newlinks
sub { $DB->table('Links')->count( { isNew => 'Yes' } ) }


grand_total_users
sub { return $DB->table('Users')->count; }
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [ULTRAGlobals] The most popular categories In reply to
Hi,

Glad you like the plugin :)

Quote:
All user list

Cool, may add something like that.

Quote:
All links in a given category

Another interesting one :) I have "new links" in a given category, with the New_Links_By_Category() function.

Quote:
Random link from a given category

Weird, I thought I already had added something like that =) Maybe I was getting confused with AdCode_Randomly_In_Cat() <G>

Quote:
Directory map: a simple map of top few levels of directory

What does this one do? Something like:

Code:
Top Level Cat
Sub Level
Sub Level
Sub Level

Top Level Cat 2
Sub Level
Sub Level
Sub Level

Top Level Cat 3
Sub Level
Sub Level
Sub Level

..or something?

Quote:
grand_total_cat

This can already be done with:

<%Plugins::ULTRAGlobals::Get_Totals('Category')%>


Quote:
grand_total_newlinks
sub { $DB->table('Links')->count( { isNew => 'Yes' } ) }

Cool, will add that one in too =)

Quote:
grand_total_users
sub { return $DB->table('Users')->count; }

This can also be done with the Get_Totals function:

<%Plugins::ULTRAGlobals::Get_Totals('Users','registered')%>

Anyway, I'll try and get those bits added in at some point (maybe today, but not 100% sure - as I'm pretty bogged down with work today, so may not have enough time =+))

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
[ULTRAGlobals] Version 2.3.6 In reply to
Hi,

Version 2.3.6 is now available from here: http://www.ultranerds.com/...s/ULTRAGlobals_L217/

This has a few new functions:

User_List
All_Links_In_Category
Random_Link_In_Category
Number_of_New_Links

(this now brings the plugin to a total of 45functions Smile)

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] [ULTRAGlobals] Version 2.3.6 In reply to
Whoo Hoo!

On your page I notice a link to make a donation, does sending you beer count?


Sandra Roussel
Chonsa Group Design - Fresh Start Housing

Last edited by:

SandraR: Oct 23, 2008, 7:14 AM
Quote Reply
Re: [SandraR] [ULTRAGlobals] Version 2.3.6 In reply to
Hi,

Quote:
Whoo Hoo!

<G>

Quote:
On your page I notice a link to make a donation, does sending you beer count?

hehe sure; ) (wish other people would consider donations too - as I put a lot of work into this plugin - I've only had one, maybe 2 donations since I released 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] [ULTRAGlobals] Version 2.3.6 In reply to
Since you only had 2 donations I donated - check your paypal page the closing page goes to: Acumendb


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] [ULTRAGlobals] Version 2.3.6 In reply to
Thanks :)

Re acumendb - weird! Thats an old company I used to work for several years ago. Will have to check out whats going on there (may be a weird setting in paypal I did, when I was doing testing on coding). Thanks for the heads up =)

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] [ULTRAGlobals] Version 2.3.6 In reply to
A cool addition to the globals list will be (if possible):

A global that will give a total count for all links with specific tags..
Example may be something like: <%Plugins::ULTRAGlobals::Get_Totals_links('has_author', 'not like', '')%>

Also a global that will list these links:
<%Plugins::ULTRAGlobals::List_links('is_Featured', 'eq', 'yes')%>
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] [ULTRAGlobals] Version 2.3.6 In reply to
Hi,

I've just uploaded version 2.3.7. This now has those function included :) (all explained in detail in the documentation :))

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: [katabd] [ULTRAGlobals] Version 2.3.6 In reply to
Hello Andy

Three things here:

- The All Users List is not working and does not show anything..

- Also is it possible to use List_Links function to diplay a list of links based on the 'ExpiryDate'.

- I have a list links based on the author name (Not same as usersname).. on one page I list all authors linked to their listings.. when I use <%Plugins::ULTRAGlobals::List_Links('LinkAuthor','Not Like','','LinkAuthor ASC',10)%> I get the list of author with many duplicates.. can I use a distinct option to limit each author to one be displayed once?

Thank you again for the free plug in..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] [ULTRAGlobals] Version 2.3.6 In reply to
Quote:
- The All Users List is not working and does not show anything..

Which function?

Quote:
- Also is it possible to use List_Links function to diplay a list of links based on the 'ExpiryDate'.

Not sure what you mean? You wanna look for "paid" links?

<%Plugins::ULTRAGlobals::List_Links('ExpiryDate','<','2147483647','Title ASC')%>

Quote:
- I have a list links based on the author name (Not same as usersname).. on one page I list all authors linked to their listings.. when I use <%Plugins::ULTRAGlobals::List_Links('LinkAuthor','Not Like','','LinkAuthor ASC',10)%> I get the list of author with many duplicates.. can I use a distinct option to limit each author to one be displayed once?

Mmm.. not really easily. If you wanna do more complex queries, then I would just use something like:

Custom_List_Links
Code:
sub {

my ($field,$operator,$val,$sort_order,$limit) = @_;

$sort_order ||= "Title ASC";

my $tbl = $DB->table('Links');
if ($limit) {
$tbl->select_options(qq|ORDER BY $sort_order LIMIT $limit|);
} else {
$tbl->select_options(qq|ORDER BY $sort_order|);
}

my $sth = $tbl->select( ['DISTINCT(LinkAuthor)'], GT::SQL::Condition->new('LinkAuthor','NOT LIKE','','') ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {

if ($CFG->{build_detailed}) {
$hit->{detailed_url} = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} );
}

if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }

push @loop, $hit;
}

return { cond_loop_link => \@loop }

}

...and call with:

Code:
<%Custom_List_Links('Field','=','Test','Title ASC',10)%>

(should work, but appologies if it doesnt - its 6:30am here =))

Quote:
Thank you again for the free plug in..

NP Smile

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] [ULTRAGlobals] Version 2.3.6 In reply to
Hi

- Hello

- <%Plugins::ULTRAGlobals::User_List('Username','100')%>
- Works great.
- Will test and let you know.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] [ULTRAGlobals] Version 2.3.6 In reply to
Hi,

Someone just made me aware that in the "Download Area" (via the GLinks admin panel), the version of this plugin was 1.5.0 (very old =)). I've just updated it to 2.3.6, which is the current version available Smile

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] [ ULTRAGlobals ] Ideas please In reply to
Hey Andy,

How about this idea.

Text area in forms (add link, review... etc forms) where users can only input html tags allowed by admin in template design. For example most admin would only want to allow submitters endusers to use tags like <b>, <p> </p> <br> <ol> </ol>, <li> </li>, <ul> </ul> and generally not the emails, link/image inserts..etc and many others.

Or in other words, Admin's ability to limit formatting in forms via only allowed tags would not only give admin an ability to have good looking detailed, review & other pages without having any real worries of end-users using unwanted tags & formatting.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [ ULTRAGlobals ] Ideas please In reply to
Hi,

Mmm, thats a bit more complex than it sounds =)

Doing stuff like [b][/b] isn't too hard - but when it comes to emails, it will be a PITA (as most are sent in plain text, so ALL HTML formatting would need to be removed, and replaced with just simple text)

I'll probably do this as a paid plugin (as its not just a "global") - but gotta find the time to do it though =)

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