Gossamer Forum
Quote Reply
Editors Global
Hi

Is there a global that will return a list of the categories a given editor is responsible for?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Editors Global In reply to
Did you ever work this one out?
Quote Reply
Re: [sooke] Editors Global In reply to
Code:
my $user = 'Username';
my @list = $DB->table('Editors', 'Category')->select( { Username => $user }, 'Full_Name' )->fetchall_list;

I *think* that should work.
Quote Reply
Re: [Paul] Editors Global In reply to
Thanks Paul, I'll try that... It looks like it would work anyways.

I am running out of dynamic pages to put good things like this on in my static setup.

Maybe an empty dynamic page built into links for customization with user globals would be nice - for non-plugin writers like myself. (hmmm, not sure that makes senseCrazy)
Quote Reply
Re: [sooke] Editors Global In reply to
Hi

Sorry I am late in responding but I have been out for a while..

Did Paul's suggestion work?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Editors Global In reply to
Yes, I beleive it did... I did change something though, just trying to remember what it was... I have since pulled it off, as I am tinkering around with the whole concept.... I post back here if I remeberCrazy
Quote Reply
Re: [Paul] Editors Global In reply to
Paul, I'd like to take this two steps further, and I wonder if this is an easy change on top of this.

A global which showed how many links, and how many categories, the editor has under their belt!

Quote:
my $user = 'Username';
my @list = $DB->table('Editors', 'Category')->select( { Username => $user }, 'Full_Name' )->fetchall_list;

I guess editor_categories_total = the number of rows in @list?

for each category in @list, select Number_of_Links from lsql_Category and sum them to equal editor_links_total.

Can the above code be modified to do this?

My attempts are as bad as this:

Code:
my ($editor_links_total) = $DB->table('Category')->select(['SUM(Number_of_Links)'] where the category is in @list?)->fetchrow_array;


ThanksSmile

Last edited by:

sooke: May 10, 2002, 2:42 PM
Quote Reply
Re: [sooke] Editors Global In reply to
Code:
my $cat_total = ~~@list;
my $lnk_total = $DB->table('Category')->select( 'SUM(Number_of_Links)', { ID => \@list } )->fetchrow;

I think that should work.
Quote Reply
Re: [Paul] Editors Global In reply to
Thanks Paul,

I've tried this and it is returning just a blank... probably something really dumb on my part. I have place the tag <%editor_lnkcat%> into browser_info.html, for the editors to see.


If I change the return part to just return $cat_total; it returns 0, instead of about a thousand in this case. And return $lnk_total; on its own returns blank.

I am thinking this might not work because there is more than one instance/record per editor in the editors table, and the associated Category ID's are often subcategories of another category they are assigned. This means the category count would be counted twice? Somehow LSQL knows which categoroies have each editor assigned to them when it is building.... so it must be possible to add the number of links and unique categories an editor has even if this has to happen while the build is going on... hmmm I thought it may be just a simple global that could do this...

Code:


sub {
# Returns the number of Categories and Links under an editor's responsibility

my $user = 'Username';
my @list = $DB->table('Editors', 'Category')->select( { Username => $user }, 'Full_Name' )->fetchall_list;

my $cat_total = ~~@list;
my $lnk_total = $DB->table('Category')->select( 'SUM(Number_of_Links)', { ID => \@list } )->fetchrow;

return ("Categories: ", $cat_total, " Links: ",$lnk_total);

}

Last edited by:

sooke: May 10, 2002, 4:15 PM
Post deleted by Paul In reply to

Last edited by:

Paul: May 11, 2002, 1:52 AM
Quote Reply
Re: [Paul] Editors Global In reply to
I think the answer to this one lays in the Directory Dept function that Ivan just wrote, especially this part:

Code:


# Immediate subcats
my @category_level;


my $sth = $l_cat->select ({FatherID => 0});
while (my $category = $sth->fetchrow_hashref) {
push @category_level, $category;
&update_cat($category,$level);
}
@categories[$level] = \@category_level;
$level++;

# Fetch all subcategories below
while ($#{$categories[$level-1]} > 0) {
my @category_level;
my $num_cat_father_level = $#{$categories[$level-1]} + 1;
for (my $i=0; $i < $num_cat_father_level; $i++) {
my $father_id = ${$categories[$level-1]}[$i]->{ID};
my $sth = $l_cat->select ({FatherID => $father_id});
while (my $category = $sth->fetchrow_hashref) {
push @category_level, $category;
&update_cat($category,$level);
}
}
@categories[$level] = \@category_level;
$level++;
}
return;
}


Except:

Don't increment the directory depth, rather just count the number of sub directories.

It would have to loop through this for each entry an editor has in the records table, but minus out duplicated categories. Still awful complicated, but I think this is one step closer.

Food for thought!
Quote Reply
Re: [Ian] Editors Global In reply to
Ian, I try to run your code but its not working.
please help.