Problem/Motivation

Drupal allows a forum to appear in multiple containers via the taxonomy module. This is great because some forums can be classified into multiple categories (containers). However, it does not display the mulitple classified forum correctly at the top hierarchy level (first level). It only shows the first instance of the forum in the first container that it appears. However, when one clicks on the other containers containing the multiple classified forum, Drupal will display the containers' forums including the one that was originally not visible, the multiple classified forum. Drupal should be more consistent and display the multiple classified forum in all containers at all hierarchy levels. Or at the very least, make it a feature to enable or disable this.

Additional problem was uncovered in comment#11. [If I understood it, I would explain what it was.]

Proposed resolution

See comment #21 for proposed solution.

Remaining tasks

Write code for feature to enable single forum to be related to multiple containers.
Write some tests.

User interface changes

Forum containers work properly with the same forum in multiple containers.

API changes

None.

Original report by The Directive

Drupal allows a forum to appear in multiple containers via the taxonomy module. This is great because some forums can be classified into multiple categories (containers). However, it does not display the mulitple classified forum correctly at the top hierarchy level (first level). It only shows the first instance of the forum in the first container that it appears. However, when one clicks on the other containers containing the multiple classified forum, Drupal will display the containers' forums including the one that was originally not visible, the multiple classified forum. Drupal should be more consistent and display the multiple classified forum in all containers at all hierarchy levels. Or at the very least, make it a feature to enable or disable this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bèr Kessels’s picture

Category: bug » feature
Uwe Hermann’s picture

Version: 4.4.2 » x.y.z
Liam McDermott’s picture

Version: x.y.z » 7.x-dev
Jody Lynn’s picture

Category: feature » bug
Status: Active » Needs review
FileSize
22.54 KB
34.58 KB
623 bytes

This five year old issue is a bug and there is a simple fix.

To reproduce:
Create two forum containers and one forum (admin/structure/forum). Then go to taxonomy and edit the term for your new forum, placing it into multiple containers. Go to /forum and the forum only is displayed in one of the containers, even though it truly is in both. (Screenshots attached)

Cause:
function forum_forum_load (which is only called for this page, at least in its full usage), starts out with the proper taxonomy tree of forums, but then loops through and creates a new array which it keys by taxonomy term (preventing the same term being used multiple times). This key is never used and removing it fixes the problem.

andypost’s picture

Is there any reason to allow same forum to appear in different containers?
Suppose we should disable this feature for forum vocabulary

Jody Lynn’s picture

Yeah, that's the other option. We could form_alter the taxonomy settings to not allow putting forums in multiple containers. But then we're dealing with slightly unique behavior in a certain vocabulary, which is a little odd, as opposed to what seems like a very simple fix.

andypost’s picture

I think that this form should be altered anyway because #599016: Only allow nodes to be posted to forums

yoroy’s picture

Version: 7.x-dev » 8.x-dev

Hello new forum maintainer, look what I found :)

larowlan’s picture

Thanks yoroy, do we have a straw poll on this wrt to which way to go.
My performance is to allow multiple parents.

yoroy’s picture

I had to read again to understand correctly. You definately want to be able to post a single forum post to multiple forum containers (for an important message that applies to all visitors of any forum container). But that's not the issue here.

From a UX perspective I would advise to remove the possibility to do this. Although the capability could be viewed as a feature, it is more likely to be confusing than useful.

larowlan’s picture

Turns our there's code in the module to do just this - ie remove the ability to edit the hierarchy field on the vocabulary and add multiple parents to the term - however the code is targeting a non existent field.


/**
 * Implements hook_form_alter().
 */
function forum_form_alter(&$form, $form_state, $form_id) {
  $vid = variable_get('forum_nav_vocabulary', 0);
  if (isset($form['vid']) && $form['vid']['#value'] == $vid) {
    // Hide critical options from forum vocabulary.
    if ($form_id == 'taxonomy_form_vocabulary') {
      $form['help_forum_vocab'] = array(
        '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
        '#weight' => -1,
      );
      $form['hierarchy'] = array('#type' => 'value', '#value' => 1);
      $form['delete']['#access'] = FALSE;
    }
    // Hide multiple parents select from forum terms.
    elseif ($form_id == 'taxonomy_form_term') {
      $form['advanced']['parent']['#access'] = FALSE;
    }
  }
  if (!empty($form['#node_edit_form']) && isset($form['taxonomy_forums'])) {
    $langcode = $form['taxonomy_forums']['#language'];
    // Make the vocabulary required for 'real' forum-nodes.
    $form['taxonomy_forums'][$langcode]['#required'] = TRUE;
    $form['taxonomy_forums'][$langcode]['#multiple'] = FALSE;
    if (empty($form['taxonomy_forums'][$langcode]['#default_value'])) {
      // If there is no default forum already selected, try to get the forum
      // ID from the URL (e.g., if we are on a page like node/add/forum/2, we
      // expect "2" to be the ID of the forum that was requested).
      $requested_forum_id = arg(3);
      $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : '';
    }
  }
}

The problem is with this bit

// Hide multiple parents select from forum terms.
    elseif ($form_id == 'taxonomy_form_term') {
      $form['advanced']['parent']['#access'] = FALSE;
    }

Because there is no such $form['advanced'], instead it is $form['relations'].

Attached patch fixes this.

marcingy’s picture

Category: bug » feature

I agree with yoroy this is a feature request not a bug

andypost’s picture

Category: feature » bug
Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Form container is changed from 'advanced' to 'relations' so this should be commited asap and backported
taxonomy_form_term() D7 & D6

catch’s picture

Priority: Major » Normal
Issue tags: +Needs tests

Needs tests, not a major bug at least.

larowlan’s picture

Possibly the cause of
#361275: Topics are created but not displayed and
#345387: Forum topic will not display
Users there have described irregular formats for $node->taxonomy which could be down to the vocab/terms being setup wrong (ie not locked down).

sun’s picture

Status: Reviewed & tested by the community » Needs work

As @catch mentioned in #14, needs tests.

larowlan’s picture

Notes on how this test would go:
1) Load up the term edit form for a tid in the forum vocab (install hook creates one term - General)
2) Assert that the parent field is not found.

alexweber’s picture

Status: Needs work » Needs review
FileSize
1.9 KB

re-rolled the patch in #11 with the tests described in #17 (patch in #11 comitted with proper attribution)

andypost’s picture

Status: Needs review » Reviewed & tested by the community

#11 should be commited asap or should go to another issue because it's really bug!

But this issues is about different - is forum allowed to be in different containers.

This test make no sense because does not tests #11 and ability for forum to live in different containers.

+++ b/core/modules/forum/forum.testundefined
@@ -165,6 +165,14 @@ class ForumTestCase extends DrupalWebTestCase {
+    ¶

trailing whitespace

+++ b/core/modules/forum/forum.testundefined
@@ -165,6 +165,14 @@ class ForumTestCase extends DrupalWebTestCase {
+    // Test forum cannot appear in multiple containers
+    // Log in as admin user
+    $this->drupalLogin($this->admin_user);
+    // Load term edit form
+    $this->drupalGet('taxonomy/term/' . $this->forum['tid'] . '/edit');
+    // Assert parent field is not found

no dots at the end if comments

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Let's commit the bug fix and the test at the same time, so this needs work to address andypost's review of the test.

Also it looks like the bug fix is nothing to do with the initial report, so we could use an issue summary.

-enzo-’s picture

Hello guys

I was debugging this bug with Koffer this bug for Drupal 7 and we think we found the source of the problem.

The problem: The template structure

The forum list template expect an array structure in the way listed below

container 1
child-A
child-B

container 2
child-A
child-C

Notice the child-A is the same term and must list listed twice in the same array, also notice containers and children are in the same level of array , they are only separated by is_container variable.

The problem is the array structure is returned by the function taxonomy_get_tree($vid, $tid); inside function forum_forum_load of file forum.module. Below and example of returned array

container 1
child-A ( parents: container 1, container 2)
child-B

container 2
child-C

The solution

A) Replace the function taxonomy_get_tree($vid, $tid); inside function forum_forum_load of file forum.module.
B) Change the logic of forum list template: forum-list.tpl.php

We will try to propose a solution for D7.

Regards,

andypost’s picture

Let's leave this issue about #21 - templates and logic
Because current form_alter is broken - I've posted a patch with #18 and another fix in #787652: Forum vocabulary alterations possibly obsolete -- possible to delete forum vocab

+++ b/core/modules/forum/forum.test
@@ -165,6 +165,14 @@ class ForumTestCase extends DrupalWebTestCase {
+    // Assert parent field is not found
+    $this->assertNoField('parent');
   }

We should not test for unused component

andypost’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

I've make a split of forum_form_alter() with tests for vocabulary and term forms in #787652-8: Forum vocabulary alterations possibly obsolete -- possible to delete forum vocab
Not sure this possible for D7 (BC breakage) so for D7 we could live with forum_form_alter().

@larowlan as forum maintainer please take into account that tasks of this issues are different. This about abiliti of forum to live in different containers which means more about queries and templates but #787652 is about currently broken forum_form_alter()

Momseekingbalance’s picture

I just wrote an issue summary. Someone that knows more about this issue should check it over. Be kind, I am a new contributor. (jhodgdon was looking over my shoulder but may not know anything about this issue either)

andypost’s picture

DevElCuy’s picture

Issue tags: +dlatino

Adding tag "dlatino" for reference of the Drupal Latino community.

andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/forum/forum.testundefined
@@ -165,6 +165,14 @@ class ForumTestCase extends DrupalWebTestCase {
+    ¶
+    // Test forum cannot appear in multiple containers
+    // Log in as admin user
+    $this->drupalLogin($this->admin_user);
+    // Load term edit form
+    $this->drupalGet('taxonomy/term/' . $this->forum['tid'] . '/edit');
+    // Assert parent field is not found

This hunk needs re-roll

andypost’s picture

Issue summary: View changes

I wrote an issue summary for your message.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to upgrade to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017.(Drupal 8.3.0-alpha1 is available for testing).

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

g-brodiei’s picture

Category: Bug report » Feature request
Issue summary: View changes
Status: Needs work » Active
Issue tags: -Needs issue summary update, -dlatino +Bug Smash Initiative

Providing an update to summary after 8 years, the original issue is now unable to be reproduced on 8.0.x nor 8.9.x as it is fixed by other related issues (#787652, #588016), the functionality to assign one forum to different container is being disabled in the forum's create/edit form since the bug was fixed back to it's original intention. Test is being written as well to verify no parent fields to appear in term edit form in ForumTest.php line 355 (if I'm correct), thus the original bug is resolved and may be closed.

This issue should now be a feature request to allow same forum to appear in different containers.

container 1
forum 1

container 2
forum 1
forum 2

#21 has proposed a solution, still need work on D8. This feature should be discussed and decided on the usefulness of this feature, as mentioned by #9

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9-only bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Active » Postponed

Forum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to the contributed extension once the Drupal 11 branch is open.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Forum
Version: 11.x-dev » 1.0.1
Component: forum.module » Code
Status: Postponed » Active