Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have implemented a patch that adds two new features for the forum module block.
The options provide more granularity for the forum block, when the admin can select to show only active topics, or new topics, or both.
Patch is attached.
Comment | File | Size | Author |
---|---|---|---|
#23 | forum.module-block-cvs-3.patch | 2.63 KB | kbahey |
#18 | forum.module-block-cvs-2.patch | 2.59 KB | kbahey |
#12 | forum.module-block-cvs.patch | 2.59 KB | kbahey |
#6 | forum.module-block-3.patch | 2.19 KB | kbahey |
#1 | forum.module-block-2.patch | 3.32 KB | kbahey |
Comments
Comment #1
kbahey CreditAttribution: kbahey commentedIf only one option is selected, then having two headers is a bit redundant.
Hence, this 2nd version of the patch eliminates this, and only displays two headers if the two checkboxes are selected.
Comment #2
Dries CreditAttribution: Dries commentedYour patch is reversed and does not conform our coding standards. Won't commit.
Comment #3
Bèr Kessels CreditAttribution: Bèr Kessels commented-1 from me. I am fighting aginat new options :).
What i would like much better, is when you add two new blocks, then you (a) Do not need additional options in the settings sections, and (b)leave that to the blocks adminstration.
Bèr
Comment #4
kbahey CreditAttribution: kbahey commentedDries,
Can you explain more what you mean by 'reversed' ? Do you mean that the patch works the opposit of what it should do? Or you mean 'backed out'? Also, can you be more specific about how it is not up to coding standards?
Ber,
I understand your reluctance for new options. Your suggestion of two blocks is a better solution. I will give it a thought.
Comment #5
Junyor CreditAttribution: Junyor commentedI was looking at this exact issue last night. There should be two separate blocks enabled/disabled through the block administration page.
That leaves one option on the forum settings page about blocks: # of items to show. I think that option is something that should be more integrated into block administration and available for all blocks (where applicable) rather than just the forums block. I've had to hack code just to change the number of items in a block, which isn't user-friendly at all.
Comment #6
kbahey CreditAttribution: kbahey commentedHere is a patch that makes them two blocks, one for active, and one for new.
The admin can select either or both, and place each in a different place. Thanks for Ber for his suggestion.
I understand now what Dries meant by reversed. It is corrected now.
Comment #7
Junyor CreditAttribution: Junyor commentedDon't forgot to remove the settings from the forum settings. And set this issue to patch. :)
Comment #8
kbahey CreditAttribution: kbahey commentedChanging to patch.
There are no settings in this one.
Comment #9
Junyor CreditAttribution: Junyor commentedRight. I meant remove the current settings.
Comment #10
Junyor CreditAttribution: Junyor commentedNevermind, I see that the settings are removed. +1 for this patch. Applies cleanly to 4.5.2, too.
Comment #11
drumm+1
However, I think this patch was made against 4.5.x and not CVS. There are some changes to the block hook which move the settings which I see are not properly handled by this code. I would guess that it does not apply.
Comment #12
kbahey CreditAttribution: kbahey commentedHere is the patch against CVS HEAD.
I have no CVS installation at present, so this is not tested.
Can someone please test it and report here?
Comment #13
tangent CreditAttribution: tangent commentedThe patch applies. It does not comply with the style guidelines though. The spacing and use of tabs is incorrect.
Also, this patch removes the option of having both types of forum links in the same block in favor of putting them in separate blocks. I think it makes sense to leave them in the same block and this removes the temptation to use block titles of the form "Forum: Active topics" which isn't very consistant or elegant.
Comment #14
Bèr Kessels CreditAttribution: Bèr Kessels commentedtangent: Drupal has no other blocks that contain two differten lists. It does also not have two different ficuntions in one block either.
In other words: having a (forum) block that has two lists, is very inconsistant, much more that two different titles.
Can we not change the titles into:
Active forum topics
New forum topics
so +1 for moving them into their own blocks, and -1 from keeping them in one block with more config options.
Comment #15
(not verified) CreditAttribution: commentedYeah, changing the titles to:
Active forum topics
New forum topics
would be preferable.
Comment #16
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedI have to agree with Ber on this one.
As i think the functionality is quite handy for some sites, I am against having options for everything. The best solution in this way will be - as Ber suggests - having two blocks. for an example of how multiple blocks could be implemented in a module, take a look at the block example page of drupaldocs.org, which is very clear..
Besides that, please take some time to let your code be as we want it to be: Coding standards
Comment #17
tangent CreditAttribution: tangent commentedI was going to suggest these block titles at first but I thought it might be better to keep all forum stuff in a single block. I don't think its that important though so +1 on those block title changes.
Comment #18
kbahey CreditAttribution: kbahey commentedThanks for stefan for pointing out the coding standards, rather than just stating that my code is not compliant with them.
I reviewed them, and they are not to my personal liking (e.g. braces are K&R style and not on the same column and on a line by themselves, ...etc.). However, a standard is a standard, whether we like it or not. Conforming to a less than ideal standard is better than no standard at all. So, I will stick to them, since they are the way of doing business around here. By the way, does anyone have pointers to vim settings for these standards?
Regarding the rest of the comments, it seems the concensus is to leave the patch functionality as it is (two blocks, with titles as they are).
So, I am changing the style to be in conformance, and here is a patch for that.
Comment #19
(not verified) CreditAttribution: commentedAny text presented in the UI needs to be wrapped in a call to the t() function for translation purposes.
The line
$title = 'Active forum topics';
in your patch should be changed to:
$title = t('Active forum topics');
Same problem with 'New forum topics'.
Other than that, +1.
Comment #20
kbahey CreditAttribution: kbahey commentedHello Anonymous
If you look a bit down, there is a t($title), which does the same thing you want, to theme to the title of the block.
Comment #21
Gábor Hojtsykbahey, please! You need to wrap the literal string into t(), and not a variable, so the extractor can pick it up. Otherwise +1 on separating forum blocks. Also renamed the issue to reflect this goal.
Comment #22
tangent CreditAttribution: tangent commentedThe switch block also contains some tabs which should be converted to spaces.
Comment #23
kbahey CreditAttribution: kbahey commentedHere is the latest version of the patch, responding to the requests made:
1. The t() only has a literal as an argument
2. Indentation is with spaces and not tabs.
Comment #24
TDobes CreditAttribution: TDobes commented+1 -- I manually created a PHP block for just active forum topics on my site years ago. This would be a welcome improvement.
Comment #25
Dries CreditAttribution: Dries commentedCommitted to HEAD.
Comment #26
(not verified) CreditAttribution: commented