Hi!

I would like to create a patch for the aggregator module, to add an option to not generate aggregator blocks. Just to keep the admin/blocks a bit more clean. Depending on how many categories/feeds you have defined the block administration panel may end up hard to manage with blocks that you may never wish to use.

I'm thinking about different approaches.

1) A single option to allow creation of aggregator blocks. This may be enough if you wish to get rid of all of them in one shot. Benefit is it requires little changes and only a new variable to store the value of the module parameter.

2) Add this option at aggregator category/feed level. So one may choose for which categories/feeds to generate blocks. This one is obviously a bit more complex.

3) A combination of 1+2. I mean, a global option at module level could allow you to set if you always wish blocks, never or "let me choose". If the later case is choosen, you could have the option to enable block generation at aggregator category/feed.

Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Status: Active » Needs review
FileSize
7.85 KB

Well, I have finally managed to do something like option 3. The attached patch worked for me.

It adds a new option to the aggregator settings panel that looks like this:

Block generation:
( ) Never, I do not wish to generate aggregator blocks.
(*) Always, please. I wish to generate blocks for all categories and feeds.
( ) Let me choose which categories and/or feeds I wish to generate blocks.

If you choose "let me choose...", then when you create/edit a category or feed you'll have a new option that reads "Create a block for this " that allows you to enable/disable this block, so it is hidden from block administration.

There is no change in the SQL schema in this patch. To store the enabled/disabled status for each block, it uses the 'block' column of the aggregator category/feed tables (set to 0 when disabled). Note this column is used to store the number of items to show for each block, so I believe the patch doesn't break anything.

Please, let me know what do you think. Thanks

Dries’s picture

Personally, I think option #2 would have been easier/simpler.

I'm not sure this feature is necessary. Is this a "real" problem?

markus_petrux’s picture

IMHO, yes it is. Specially when you have defined lots of sources, the block administration gets kind of heavy.

The patch turned to be much simpler than I originally thought. By default, it would behave as always, but with it, you have options that may make your life somehow easier.

bluecobalt’s picture

+1 on this.

I agree that the admin/blocks page gets unwieldy when there is a large number of feeds. It takes a long time to load, and you have to scroll through a lot of unneeded blocks to find the ones that you actually want to turn on.

I haven't tested this as I don't have 4.7 installed, but I like the concept.

markus_petrux’s picture

Thanks, bluecobalt. It's good to know I'm not the only one. :-)

It would be nice if someone else (other than me) could test it. Otherwise it won't get into HEAD, I'm afraid.

The patch simply adds the ability to choose when/how you wish to generate blocks for aggregator feeds with no changes in the DB at all. It uses an existing field, "block" that's used to set the number of items to show per block. With the patch, if this field is set to zero, the block won't appear in block administration. Oh, ah, and there's also a global variable that allows you to say if you want blocks "always", "never" or "let me choose". Pretty simple, really. ;-)

chx’s picture

I know posts like this is not much help but I do not have the time to review but definitely Ó1 for this patch. I put an underscore before aggregator_block function name to kill it quick...

eaton’s picture

The functionality is VERY VERY useful, though -- automatic generation of blocks is nice for a blogroll and horribly bad for large-scale aggregation.

+1 for functionality

Unfortunately, it doesn't seem to apply correctly.

patch: **** malformed patch at line 39: else if ($op == 'configure') {

markus_petrux’s picture

>> malformed patch

Not sure how to check this. I have little experience generating patches, I used WinMerge to generate this one, based on $Id: aggregator.module,v 1.268 2005/12/29 04:46:40 unconed Exp $.

:-(

Dries’s picture

I'd kill the global option and add a per feed option. I think that is going to be the least confusing.

markus_petrux’s picture

Let me bump this one as a self reminder. As soon as this patch gets applied (or rejected <g>), I'll work on it (in the hope to avoid conflicts with the patch format).

markus_petrux’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
5.18 KB

I'd kill the global option and add a per feed option.

ok, the new patch just adds an option to the aggregator category/feed to choose if a block is desired by that specific item.

If the user says yes, the default of 5 items per block is stored in the block field of the corresponding table.
If the user says no, the block field is set to 0.

Then, then block hook query (where block are generated) has been modified to list items where the block field is greater than 0.

Please, see attached patch. I hope this one works. ;-)

Dries’s picture

The way you added the options is ... weird. Some might argue it is a clever hack but to me it's somewhat ugly.

markus_petrux’s picture

I tried to find a way to implement this option by not touch the DB tables. Do you mean, it would be best to add a new field?

...or it is related to the way I added the fields in the form? Is not a good option to use a checkbox (boolean) that updates a numeric column in the tables?

Sorry, what do you mean by "somewhat ugly"? :-( ...how would you do it?

markus_petrux’s picture

Please, let me know what's wrong, so it be could be properly addressed.

1) Is it better to use a different table column to store the "generate block state"?
2) Is the way form fields are validated? Maybe something more simple here?
3) ???

Dries’s picture

I'm leaning toward saying that an extra column field is nicer code-wise.

Gerhard Killesreiter’s picture

Status: Reviewed & tested by the community » Needs work

as per Dries' comments

markus_petrux’s picture

Bumping just to not forget this. I'll look at it.

Egon Bianchet’s picture

Version: x.y.z » 6.x-dev

Resurrecting ...

agentrickard’s picture

Subscribing. Will take a look as I need this functionality for to the MySite module project.

I was already considering this patch. Needs three things?

1) A new column in the aggregator_feed table to indicate block status
2) A global default setting that the admin defines (Block on/off).
3) A per-feed radio form element that defaults to the admin settings (on/off), but allows changes on a per-feed basis.

agentrickard’s picture

Status: Needs work » Needs review
FileSize
7.04 KB

New patch against 6.x-dev.

The administrator sets a global option for default settings. Individual feeds can add/remove their block on update.

Perhaps needs a permission check to see if the person editing the form has permission to create blocks?

Also includes a db schema change in aggregator.install, adds a 'block_create' column.

agentrickard’s picture

FileSize
7.42 KB

Improved version of previous 6.x-dev patch. Now respects 'administer blocks' permission.

agentrickard’s picture

The last patch has a logic error in the block_rehash values set in the form. Will fix and post a new patch later today.

agentrickard’s picture

FileSize
7.5 KB

This should be ready to go.

m3avrck’s picture

I always used to hack this out too.

I would like to see a follow up patch that makes aggregator actually use the taxonomy instead of it's own crude system. That kills the menu system.

With both of those fixes, aggregator will then only *slightly* suck ;-)

+1

agentrickard’s picture

Ted-

With a little thought, we could extend the proposed Aggregator API in two ways:

1) Let the admin select Taxonomy or Category for term storage
2) Let the admin select the parsing engine -- assuming that there is a default engine, and that contrib modules like simplefeed or leech have different parsing rules (ie. turn items into nodes).

Why don't you add notes to http://drupal.org/node/130942 and let's close this issue after its RTBC.

Dries’s picture

Status: Needs review » Needs work

Looking at the aggregator module's code, it looks like there is already a aggregator_feed.block field. It seems to specify the number of news items in a block, and the allowed values range from 2 to 20. I wonder if we can't add a special case for that and allow 0 to mean 'no block'. Not sure what would be best.

I'm also -1 on the global configuration setting. That's just going to be very confusing.

Another problem with this patch is that it doesn't provide an upgrade path. It looks like existing blocks might get turned off after applying this patch (or after upgrading to Drupal 6).

agentrickard’s picture

Three points here:

1) Well, back at http://drupal.org/node/43245#comment-67551, you suggest that an extra field is best, so I went that way.

This feature could be done either way. Pick one; the code is easy. That column becomes either 5 or 0. Or we add the new "block_create" column.

2) As for upgrade path, if we make the default setting "1" == 'on' == '5' (number of items) instead of '0' == 'off', then old blocks will not be destroyed by the upgrade. Right?

I think setting the default value to "on" (however that is stored in the db) fixes the upgrade issue, since existing blocks are only destroyed if they go from "on" to "off".

3) Personally, I don't find the global setting confusing. From a use-case, it's exactly the functionality that I want.

I'll fight for #3, I think that the implemetation is different, but optimal because it provides the most administrator flexibility. Without a global setting, I have to manually select block status for each feed.

Plus, there are use cases (though rare), where an administrator might have 'administer feed' permissions but not 'administer block' permissions. The global setting accounts for that case.

agentrickard’s picture

Status: Needs work » Needs review
FileSize
7.59 KB

Revised patch. The change is that the default setting is now '1' or 'on'. This means that upgraded installations will keep existing blocks, and the module behavior will remained unchanged unless the administrator explicitly turns off block creation.

There is still a 'default setting' for the admin and a setting per feed option, as per my previous note.

Also still storing in a separate column, as the argument for dual-use on the 'block's column seems a little hack-like.

Boris Mann’s picture

+1 on global defaults. Dries, think about it in terms of *lots* of feeds. Especially if OPML Import gets in, then you would have to afterwards go through each feed manually.

See http://groups.drupal.org/node/3538 for an overview of lots of things to fix with aggregator.

agentrickard’s picture

FileSize
6.92 KB

Patch resurrected for the current state of Drupal-6.

catch’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Needs work

No longer applies and this will have to wait for D7 now.

mustafau’s picture

I have implemented Dries suggestion in #26.

Moved feed block settings to feed edit form. Setting to '0' means no block.

Category settings are unchanged.

mustafau’s picture

Status: Needs work » Needs review
Dries’s picture

FileSize
6.23 KB

How about this? Better help texts.

mustafau’s picture

Title: aggregator module - add an option to not generate blocks » Aggregator module - add an option to not generate blocks
FileSize
7.38 KB

Updates OPML import form.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.