Gossamer Forum
Quote Reply
Active categories
I would like to have a listing of "active" categories, that is, categories containing new links.

I thought I could do something template-based with <%if Has_New_Links eq 'Yes'%> etc., but can't get it to work, and now think I need a global to do this. I've tried something like:

Code:
sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY ID DESC');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
my $cat_db = $DB->table('Category');
my @root_cats = $cat_db->select ['Full_Name']->fetchall_list;
...

}
return $output;
}
... but can't get it right.

Can anyone help, please?

John
Quote Reply
Re: [gotze] Active categories In reply to
I've just the following tag in the category template:

<%if Number_of_Links '>' '0'%>
Quote Reply
Re: [Alba] Active categories In reply to
Alba,

I don't think that's it. That just shows categories with something in them, doesn't it?

I want to show just categories (including subcats) that have new links in them.
Quote Reply
Re: [gotze] Active categories In reply to
What about <%if Has_New_Links eq 'Yes'%>
and <%if Has_Changed_Links eq 'Yes'%> if you want categories with updated links.

Not sure if this would work to show subcategories though.
Quote Reply
Active categories global In reply to
A bit of progress on this front... this global does (almost) what I need:
Code:
sub {
my $output;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Name');
my $sth = $cat_db->select ({Has_New_Links => 'Yes'} );
while (my $cat = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('newcategory', $cat);
}
return $output;
}
Example

I've created a new template, newcategory, that uses <%Full_Name%> and <%Name%>.

The problem is that Full_Name is "Full Name" and not "Full_Name", and that the urlified tag doesn't work here. I've met this problem before, and thought the solution would be something like this:

Code:

sub {
my $output;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Name');
my $sth = $cat_db->select ({Has_New_Links => 'Yes'} );
while (my $cat = $sth->fetchrow_hashref) {
my $path = $cat_db->as_url($cat->{Full_Name});
$output .= Links::SiteHTML::display ('newcategory', $path);
}
return $output;
}

Can anyone see what is wrong here? (I can't)

Another question: With all the new loop-stuff in GLinks, is there an easier way to do this??

John
Quote Reply
Re: [gotze] Active categories global In reply to
Ah, one more thought ... well, challenge/cry for help, since this is beyond my programming skills ...

Know Technorati Tags? The way they display lists is interesting.

It would be neat to do something similar here Smile
Count the number of new links in each category, and give them a label depending on the number of links ...

Category A (11 new links) => class=bigger
Category B (7 new links) => class=big
Category C (3 new links) => class=normal
(if intervals are like 0-5 => normal, 6-10 => big, and +10 => bigger)

Any ideas?
Quote Reply
Re: [gotze] Active categories global In reply to
I have not given up. I have made some progress, but really would appreciate some helpCrazy

Issue 1: Active Tags

I am still struggling with the linkability issue.

This code:

Code:
sub {
my $output;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ({Has_New_Links => 'Yes'} );
while (my $cat = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('newcategory', $cat);
}
return $output;
}
is fine except it doesn't create the right urls. I've tried as_url etc, but just can't get it to work.

This code, however:

Code:
sub {
my $output;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ( ['Full_Name','Name'], { Has_New_Links => 'Yes' });
while (my ($cat,$name) = $sth->fetchrow_array) {
$cat =~ s/ /_/g;
my $cat1 = $cat;
$output .=qq~<a href="$CFG->{build_root_url}/$cat1">$name</a>, ~;
}
return $output;
}
works, but uses a cheap trick to create the right urls. I don't like having to hardcode the HTML.

So, why can't I get it to work with the template?

Issue 2: Technorati Tags-style
It is important to me to be able to style the output. Here is stuff I want to do:

Code:
<%if Number_of_Links > 50 or Has_New_Links eq Yes%>
<big>
<a href="/links/<%Full_Name%>"><%Name%></a>
</big>
<%else%>
<a href="/links/<%Full_Name%>"><%Name%></a>
<%endif%>

This can be used to present something like this (here: all categories, categories with more than 50 links or with new links have bigger font)

Now I just need to combine these two.

I'll promise to write up a reusable global and stuff if I get help getting it to work.

John
Quote Reply
Re: [gotze] Active categories In reply to
Keep it simple, all you need to do is use the Has_New_Links column. Do all the html generation in the code also:
Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Full_Name');
my $sth = $category->select({ Has_New_Links => 'Yes' });
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}
In the loop, you can do your technorati tags:
Code:
<%nameofsub%>
<%loop new_categories%>
<a href="<%URL%>"<%if Number_of_Links > 50%> class="whatever"<%endif%>><%Name%></a>
<%endloop%>

Adrian

Last edited by:

brewt: May 10, 2005, 12:53 AM
Quote Reply
Re: [brewt] Active categories In reply to
 

Unable to compile 'nameofsub': Global symbol "$sth" requires explicit package name at (eval 17) line 4. Global symbol "$cat" requires explicit package name at (eval 17) line 6. Global symbol "$sth" requires explicit package name at (eval 17) line 6. Global symbol "$cat" requires explicit package name at (eval 17) line 7. Global symbol "$cat" requires explicit package name at (eval 17) line 7. Global symbol "$cat" requires explicit package name at (eval 17) line 8. Global symbol "@gcats" requires explicit package name at (eval 17) line 10.
Quote Reply
Re: [brewt] Active categories In reply to
Thanks Adrian,

I'm afraid this doesn't work :-(
Code:
Unable to compile 'CategoriesWithNewLinks': Global symbol "$sth" requires explicit package name at (eval 16) line 4.
Global symbol "$cat" requires explicit package name at (eval 16) line 6.
Global symbol "$sth" requires explicit package name at (eval 16) line 6.
Global symbol "$cat" requires explicit package name at (eval 16) line 7.
Global symbol "$cat" requires explicit package name at (eval 16) line 7.
Global symbol "$cat" requires explicit package name at (eval 16) line 8.
Global symbol "@gcats" requires explicit package name at (eval 16) line 10.

What's gcats??
Quote Reply
Re: [gotze] Active categories In reply to
heh, fixed typo's. Come on guys, those were just simple bugs, you should have been able to figure it out!

Adrian

Last edited by:

brewt: May 10, 2005, 12:52 AM
Quote Reply
Re: [brewt] Active categories In reply to
Just thinking about this a little more and there is one problem with using Has_New_Links - Has_New_Links will be set even if there are no new links directly in it. If any of its subcategories has a new link in it then it will have Has_New_Links set. So if this isn't what you want, you'll have to go the slower route and select the links which are new (isNew), and figure out which categories those links belong to (pretty much what you had at first).

Adrian

Last edited by:

brewt: May 10, 2005, 12:58 AM
Quote Reply
Re: [brewt] Active categories In reply to
Not me Crazy

Thanks!
Quote Reply
Re: [brewt] Active categories In reply to
Wunderbar!

Thanks again, Adrian. Much appreciated.

John
Quote Reply
Re: [gotze] Active categories In reply to
Might want to recopy the whole chunk of code - I fixed it up a while ago to generate a proper URL.

Adrian
Quote Reply
Re: [brewt] Active categories In reply to
And you might want to sort by just Name instead of Full_Name, since when listing them by Name, it looks like they're randomly sorted :)

Adrian
Quote Reply
Sorting In reply to
Thanks again, Adrian. Yes, I did change
Code:
$category->select_options('ORDER BY Full_Name');
to
Code:
$category->select_options('ORDER BY Name');
so that the list is sorted alphabetically.

I also made a variation of the global, which I call AllCats:
Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}
That produces this page showing all my categories, with highlighted ones with new or many links.

The only remaining issue is the issue with Has_New_Links mentioned above. That's beyond my programming skills, so I hope someone will pick up on this.

John
Quote Reply
Re: [gotze] Sorting In reply to
Hi
I'm using your sub
Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}

and I'm calling it like this
Code:
<%tags%>
<%loop new_categories%>
<%if Number_of_Links > 50 or Has_New_Links eq Yes%>
<big>
<a href="/<%Full_Name%>"><%Name%></a>
</big>
<%if Number_of_Links < 50 or > 25%>
<a href="/<%Full_Name%>"><%Name%></a>
<%else%>
<small>
<a href="/<%Full_Name%>"><%Name%></a>
</small>
<%endif%>
<%endloop%>

I'm getting an output, BUT some the url of all links with two or more words and spaces between are without underscore _ ???
Does anyone know how to fix this?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi,

You sure?

as_url() should automatically convert " " to "_".

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] Sorting In reply to
Andy wrote:
Hi,

You sure?

as_url() should automatically convert " " to "_".

Cheers

Hi Andy,
you can see the tag cloud here
http://www.gpaed.de/g-tags

In the first line see "basale Foerderung" there is the _ missing, and in all other categories with more than one word ?
Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Andy] Sorting In reply to
Hi,

I see the problem :P

You use:

Code:
<a href="/<%Full_Name%>"><%Name%></a>

..but you need to use:

Code:
<a href="<%URL%>"><%Name%></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] Sorting In reply to
Andy wrote:
Hi,

I see the problem :P

You use:

Code:
<a href="/<%Full_Name%>"><%Name%></a>


..but you need to use:

Code:
<a href="<%URL%>"><%Name%></a>


=)

Cheers

Hi Andy,
O.K. I did that, but now I have a part of the URL twice.
I think I have to change this part of the global:
Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}
Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Mmm, you could try editing:

Code:
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";

..to:

Code:
$cat->{URL} = $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";

..but from memory, as_url() doesn't actually put the build_url_url in it - not 100% sure on that 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!
Quote Reply
Re: [Andy] Sorting In reply to
Andy wrote:
Mmm, you could try editing:

Code:
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";


..to:

Code:
$cat->{URL} = $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";


..but from memory, as_url() doesn't actually put the build_url_url in it - not 100% sure on that though =)

Cheers

Hi Andy,
Works fine on my site :-) Sometimes I think my site is reacting different from other glinks sites Blush

I would like to have a second smaller tag cloud.
Is there a way to cut of the output for example to 25 categories ??

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Matthias70 wrote:
Hi Andy,
Works fine on my site :-) Sometimes I think my site is reacting different from other glinks sites Blush

I would like to have a second smaller tag cloud.
Is there a way to cut of the output for example to 25 categories ??

Thanks
Matthias

Hi Andy,
I found a solution on my own.
Just changed
Code:
$category->select_options('ORDER BY Has_New_Links DESC');
$category->select_options('ORDER BY Has_New_Links DESC', 'LIMIT 25');

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi Andy,
can you tell me how to include an title tag and an alt tag into the global.
something like this
$cat->{URL} = $category->as_url($cat->{Full_Name} title='<%category_name)%>' alt=='<%category_name)%>'. "/$CFG->{build_index}";

The output should look like this
<a href="http://www.test.de" title='topcategory/subcategory' alt='topcategory/subcategory'>Test</a>
just like the title tag in the meta description

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi,

Just do it in the template =)

Change:

Code:
<a href="<%URL%>"><%Name%></a>

...to:

Code:
<a href="<%URL%>" title="<%Full_Name%>" alt="<%Full_Name%>"><%Name%></a>

Not sure why you want both alt and title 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!
Quote Reply
Re: [Andy] Sorting In reply to
Andy wrote:

Not sure why you want both alt and title though?

Cheers

Hi Andy,
I knew that the 'alt tag' is not working in Firefox and I thought the 'title tag' does not work in IE.
But I was wrong. The title tag is enough.
Thanks for your help. Works perfect
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi Matthias,

Im reading this thread and trying to understand the concept of using tags with GLinks (which I'll love to do it), and have a question for you. I'm seeing this page:

http://www.gpaed.de/g-tags

and I notice that you've 4 times the tag sport linking to a different pages on your website, dont you think will be nicer and better to have exclusive tags per url?

I'll like to understand better how to use and make a plan for the cloud tag to my website. I was thinking to use tags per category or probably tags per common search term, where size will vary depends on the link count or quantity of links per category. How are you currently using the the different size structure for your website? What are you using to define it?

Thanks in advance and hope you dont mind sharing with me some information,

Jesus
Quote Reply
Re: [Jesus] Sorting In reply to
Hi Jesus,
at the moment the "tag cloud global" picks up every category name. I have four different sport categories on my page and the global shows them all. To have different names for each global would mean to rename the categories, so I tried to give some information by the title/alt-tag.
Maybe there is a way to show the full_name for each cat in the tag cloud, but that's to much text I think...

That's the global I'm using:
Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}

That's the html in my tag.html
Code:
<%tags%>
<%loop new_categories%>
<%if Number_of_Links > 200%>
<big><big><b>
<a href="<%URL%>" title="<%Full_Name%>"><%Name%></a>
</big></big></b> -
<%elseif Number_of_Links > 100 eq < 200%>
<b><big>
<a href="<%URL%>" title="<%Full_Name%>"><%Name%></a>
</big></b> -
<%elseif Number_of_Links > 50 eq < 100%>
<b>
<a href="<%URL%>" title="<%Full_Name%>"><%Name%></a>
</b> -
<%elseif Number_of_Links > 25 eq < 50%>
<a href="<%URL%>" title="<%Full_Name%>"><%Name%></a>
-
<%else%>
<small>
<a href="<%URL%>" title="<%Full_Name%>"><%Name%></a>
</small> -
<%endif%>
It's far away from perfect but working for me ;-)

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Thank you so much Matthias or the info,

I'll give this a try tomorrow to see how it works, I hope we can test and try to make of this an incredible useful idea for everybody. At least I know most of people like the tags system works ;)
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi Andy,
below is the global I'm using for the category tag cloud.
Is there a easy way to exclude "top level categories" in the output and show only subcats???

Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}


Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Try this:

Code:
sub {
my $category = $DB->table('Category');
$category->select_options('ORDER BY Name');
my $sth = $category->select( ['Has_New_Links','Number_of_Links','Name','Full_Name'], GT::SQL::Condition->new('FatherID','>','0','CatDepth','=','1') );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
return { new_categories => \@cats };
}

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!

Last edited by:

Andy: Apr 13, 2008, 1:28 PM
Quote Reply
Re: [Andy] Sorting In reply to
Andy wrote:


Hope that helps.

Thanks Andy,
that helps a lot ;-)

Can you exclude Subsubcategories as well?
Would be great if the global shows only first level subcats and not the subcats of the subcat.
Do you understand what I mean?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi,

Adding

'CatDepth','=','1'

..should work (try the modified global above)

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] Sorting In reply to
Hi Andy,
works fine for me, thanks for your help.
It's quiet in gtforum these days.
No new plugins. Are you running out of new ideas Cool

I must admit, at the moment I have no new ideas, but I'm working on it...

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Sorting In reply to
Hi,

Quote:
works fine for me, thanks for your help.

NP =)

Quote:
It's quiet in gtforum these days.
No new plugins. Are you running out of new ideas Cool

haha, kinda =) I've been working on a couple of large projects, and a few small ones - so havn't have much time to really think about new plugins recently =) If anyone has plugin ideas though, post them here - and I'll see if I can come up with something when I do get some free 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!