1 nate_02631 Feb 12, 2008 19:10
3 nate_02631 Feb 15, 2008 20:06
Thanks TITSSN, however this doesn't look like it'll do the job...
I have over 100 blogs and I don't want them to show them in any specific order - only to show the newest posts from all the other blogs (with maybe the ability to *exclude* one or two blogs from the list).
Basically - just like the "old* Blog All page (which *is* my default page - not following why ppl recommend it not be - server overhead?).
I'm still looking at the codebase - but if anyone has already done, or could suggest a way to may this hack possible, that would be appreciated....
4 edb Feb 15, 2008 21:34
http://forums.b2evolution.net/viewtopic.php?t=13439 is more like what you want yah? If you figure out a hack or plugin that can do it that'd be swell. Personally I don't have enough blogs to make it matter but yeah I can see where it would be a great option to have available.
5 nate_02631 Feb 15, 2008 21:46
Heehee = yeah saw that post ;) I'm a little perplexed why the feature was removed or there wasn't some kind of "range" or wildcard option offered...
i.e. if I wanted to include all blogs *except* #53, specify something like:
2-52, 54+
One of the main selling points/strengths of b2 for me was this auto-aggregating feature - have to manually specify the blogs severely limits its utility.
If anyone can offer tips on where I should look - it'd be most appreciated - been looking at the ItemList classes, etc... but darn if I can find it...
6 afwas Feb 15, 2008 21:57
I had a go at it yesterday, but I killed my blog after it crashed severely.
The Dashboard input is at /inc/collections/views/_coll_advanced.form.php lines 89-91:
$Form->begin_fieldset( T_('Aggregation').' ['.T_('Admin').']' );
$Form->text( 'aggregate_coll_IDs', $edited_Blog->get_setting( 'aggregate_coll_IDs' ), 30, T_('Blogs to aggregate'), T_('List blog IDs separated by ,'), 255 );
$Form->end_fieldset();
It then is processed in /inc/collections/model/_blog.class.php lines 534-543:
if( param( 'aggregate_coll_IDs', 'string', NULL ) !== NULL )
{ // Aggregate list:
// fp> TODO: check perms on each aggregated blog (if changed)
// fp> TODO: better interface
if( !preg_match( '#^([0-9]+(,[0-9]+)*)?$#', get_param( 'aggregate_coll_IDs' ) ) )
{
param_error( 'aggregate_coll_IDs', T_('Invalid aggregate blog ID list!') );
}
$this->set_setting( 'aggregate_coll_IDs', get_param( 'aggregate_coll_IDs' ) );
}
Actually I think I was close, but I really screwed it.
You want to put the 'exclusion' in an array and then take the difference from every possible blog and this 'exclusion array'.
This should then be turned into a comma separated string and it replaces 'aggregate_coll_IDs.
Or something like that.
Good luck
7 nate_02631 Feb 15, 2008 22:25
Well, I'm closing on it, methinks - I think the "trigger" seems to be in: /inc/items/model/_itemqueryclass.php
There are *two* where_chapter functions (starting around line 142 - in the latest b2, and the following function "where_chapter2" which seems to be a duplicate). In each there is the check for the aggregate ID's field in the blog:
if( empty( $aggregate_coll_IDs ) )
the "else" portion of this check is:
$this->WHERE_and( 'cat_blog_ID IN ('.$aggregate_coll_IDs.')' );
Just for testing, I changed mine to:
$this->WHERE_and( 'cat_blog_ID > 1' );
(as my all blogs is #1, so this should pull in all other ones) and set the "aggregate" blog ID in blog #1 to 999999, just so *something* is there and the validation on the form won't accept anything else....
Seems to work as expected, at least comparing it to the database, items__item table with the rows sorted by post_datecreated.
It would need to be refined so that the "aggregate blogs" field in the advanced blog setting tabs could accept other parameters besides a comma-separated list of positive numbers, and so forth. (though for my purposes, simply including all blogs except for #53 would satisfy me)....
8 afwas Feb 15, 2008 22:39
Hi nate_02631,
You should be at the point where the variable is created. In /inc/items/model/_itemqueryclass.php line 156:
$aggregate_coll_IDs = $current_Blog->get_setting('aggregate_coll_IDs');
And that setting comes from the snippets I mentioned in my previous post.
Good luck
9 nate_02631 Feb 15, 2008 22:49
Yes, however your previous post was only dealing with the entry of the data - ideally that would need to be changed so it would accept other parameters (like wildcards, etc...) which could then be parsed right around the $aggregate_coll_IDs lines in the item model.
Obviously, *nothin* ain't happening with _coll_advanced.form.php by itself - all the action's in the item query model, though it's pretty easy to see with the snippet you posted above where to get around the comma-separated positive number validation... (though I sux at regex's) :)
I'm not sure what the best syntax might be for having more flexible specifying of blogs - wildcard (*), range (15-20), or exclusionary (-4, -9) - will have to think on that... It could then be parsed to use gt/lt operators, or "NOT IN" vs. "IN" and so forth in the DB query...
I'm guessing these types of "hacks" can't be accomplished with a plugin(?)
EDIT: P.S. only the "second" where_chapter function seems to make a difference - not sure why that is...
10 afwas Feb 15, 2008 23:22
Forget the regex, it's checking for numbers and comma's.
This cannot be done in a plugin, there isn't a hook.
From the AM public bloglist I generated code to get every available blog:
global $Blog;
[php$BlogCache = & get_Cache( 'BlogCache' );
$avail_blogs = $BlogCache->load_public();
Then I took a string inputted in a newly created field in the Backoffice and turned it into an array:
$excluded_blog_IDs_array = explode( $excluded_blog_IDs_string );
and:
$excluded_blog_IDs_array = array_diff( $avail_blogs, $excluded_blog_IDs_array );
This array can replace $aggregate_coll_IDs (is that a string or an array?)
But somewhere I ^()%ed up with strings and arrays ending up calling the DB for $Blog( (Array) ) with an unrecoverable error and I deleted the blog.
The code for generating a field in backoffice was someting like:
$Form->begin_fieldset( T_('Aggregation').' ['.T_('Admin').']' );
$Form->text( 'aggregate_coll_IDs', $edited_Blog->get_setting( 'aggregate_coll_IDs' ), 30, T_('Blogs to aggregate'), T_('List blog IDs separated by ,'), 255 );
$Form->text( '$excluded_blog_IDs_string', $edited_Blog->get_setting( '$excluded_blog_IDs_string' ), 30, T_('Blogs to exclude'), T_('List blog IDs to exclude ,'), 255 );
$Form->end_fieldset();
Good luck
11 nate_02631 Feb 16, 2008 13:58
Afwas wrote:
Forget the regex, it's checking for numbers and comma's. This cannot be done in a plugin, there isn't a hook.
Actually, I was referring to the whole thing in general - not just the regex...
Afwas wrote:
Good luck
Not sure why you keep wishing me "good luck" - is that your post signature or something? ;)
At any rate, I've seem to have found where the action is happening w.r.t. blog aggregation. I don't think I'd follow your methodology of with the "excluded blogs", etc... but rather allow the user to enter either a wildcard "all" with additional negative blog IDs to exclude (as Edb suggested) or enter a number list as usual. Then have the itemquery class construct the query based on that info (but yes a little work would need to be done on the validating side).
I might be able to work something up, but for the moment I'm content to do the little itemquery hack as I've done above (and add NOT blog_id = x). Thanks for your feedback!
Hi Nate,
I had the same problem recently so check this out http://forums.b2evolution.net/viewtopic.php?t=14368
You'll like it.