When i want to create new content, i can go to Create new content->Forum Topic, so is logical that i can select the forum i will post my topic.
But when user is going to add topic to a forum where user is placed, user can get confused about the forum so , i want to hide select list in the post topic form.
have the Advanced Forum that option?
thanks

CommentFileSizeAuthor
#6 view_forum_selector.patch1.4 KBGeorge2

Comments

michelle’s picture

Title: FORUM SELECT LIST DISPLAYING OPTIONALLY » Option to hide forum drop down when forum already selected
Category: support » feature

No, it isn't. It's a reasonable feature request but will need some thought. You don't want to hide it from moderators, for instance. So it would have to be role based or permission based of some sort.

Michelle

madwalo’s picture

oh yes you are right, so it comes a bit complicated so, you depend of current path and permissions, i know a lot of things have to be done first so i'll be patient
many thanks

madwalo’s picture

well i've hidden the list using formfilter this may be a solution, the problem is that it hide the list from both referer pages

http://drupal.org/project/formfilter

michelle’s picture

Title: Option to hide forum drop down when forum already selected » Hide drop down forum list from non admins
Version: 5.x-1.0-alpha10 » 6.x-1.x-dev
Assigned: Unassigned » michelle
Category: feature » task

Moving this to the to do list.

Michelle

michelle’s picture

Status: Active » Postponed

Will revisit this in 2.x.

Michelle

George2’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta1
Status: Postponed » Needs review
StatusFileSize
new1.4 KB

here's a patch for you. when patched, a new permission will be added that will allow roles to see the forum selector when a forum id is passed upon a new topic creation.

in the OP usecase scenario, when "create content > new forum" topic is clicked, the forum selector will show regardless of the permission setting, but when new topic is clicked, the select input becomes a hidden form element.

michelle’s picture

Status: Needs review » Postponed

Thanks for the patched. As I said on IRC, though, this won't go in 1.x so it's still postponed. Also still need to figure out how to prevent it from hiding the selector by default. Given the IRC discussion, I guess it will need to be combined with a master setting to turn it on.

Michelle

George2’s picture

well according to system.install, you just need to directly update the permission rows for each role with the new permission which is trivial.

michelle’s picture

Trivial, maybe, but icky. And what happens when they add new roles? I don't like that idea at all. I'd rather have a master switch to turn it on and then have permissions work normally at that point.

Michelle

michelle’s picture

Version: 6.x-1.0-beta1 » 6.x-2.x-dev
Assigned: michelle » Unassigned
Category: task » feature
Status: Postponed » Active
webchick’s picture

There are a few things wrong with this approach, imo...

a) It hard-codes the forum's vocabulary as '1'. It should use variable_get('forum_nav_vocabulary', '')
b) It creates a new permission for viewing the selection box when we could easily re-use "administer nodes" or a similar, already-existing "smarter than the average bear" permission.
c) It assumes that forum topics are the only things that will ever be posted to forums. As of Drupal 6, any content type is allowed to be posted to the forum.

However, I used the basis of this patch to fix this same issue in DruBB, which you can find at #472672: form_alter() out the forum selection widget from post form if you're curious.

michelle’s picture

Thanks, webchick. :)

Michelle

George2’s picture

webchick, thanks. though,

a) i repeatedly asked in #drupal about this problem over a few days as what i did seemed VERY dirty. i got no answer at all, so i did what i could to solve the problem in the time i wanted to spend on it.
b) i disagree.
c) excellent, if only that was widely known.

jaron’s picture

I tried adding the patch and though the permissions come up, selecting them doesn't actually hide the drop down field. Am I missing something? I see there is some debate as to whether or not this should exist but it is exactly what I'm looking for. Is the patch posted here still the one to use, or is there another way to achieve the same functionality?

Thanks.

RAFA3L’s picture

Suscribe

michelle’s picture

Status: Active » Postponed

This is going to hang out in the drubb project for now and will possibly become part of the upcoming moderation module rather than AF.

Michelle

netentropy’s picture

I am just curious on the status of this.

It has always seemed sort of odd to me that Drupal's forum module handles the selection of forums this way.

michelle’s picture

The status is postponed. If you look at all those boxes right above the comment form, the status is the last one listed.

Michelle

vladgur’s picture

Title: Hide drop down forum list from non admins » You can fix this in your own module

Ive used the patch suggestion above and simply used my own module to alter forms in question:
I reused 'administer forums' permission. note that I created a new content type 'forum_comment' to be used by nodecomments as comments for my forum, hence the name of the second form('forum_comment_node_form'). Your comment form may be called differently.
I also wanted to hide shadow copy stuff.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
	// if editing/creating forum topic or comment
	// and user has no administer access
	if(in_array($form_id, array('forum_node_form', 'forum_comment_node_form')) 
			&& !user_access('administer forums'))
	{
		$forumid="";
		//if its a comment node, get the term from its parent node
		if($form_id=='forum_comment_node_form')
		{
			//get parent node
			$node=node_load($form['comment_target_nid']['#value']);
			//get forum term id from the parent node
			$forumid=current($node->taxonomy)->tid;
		} 
		else if($form_id=='forum_node_form')
		{ //if its a forum node and we're editing it
			if(end(arg())=='edit')
			{
				//get forum term id from node embedded in the form
				$forumid = $form['#node']->forum_tid;
			}
			else //if we're creating a topic
			{
				// get forum term id from the end of args
				$forumid = end(arg());
			}
		}
		//attempt to find forum term based on forum term id
		$forum = forum_term_load($forumid);
		//if forum is found
		if($forum)
		{
				//hide forum selection
				$vocab = variable_get('forum_nav_vocabulary', '');

				$default_term=$form['taxonomy'][$vocab]['#default_value'][0];
			 	$form['taxonomy'][$vocab] = array(
		       		'#type' => 'hidden',
		       		'#default_value' => 	$forumid,
		     	);
				//hide shadow copy
				$form['shadow']['#type'] = 'hidden';
		}
	
 	}
 }

code updated to account for editing/creating comments/topic

Furthermore, i generate breadcrumbs based on node taxonomy in the template.php, so the user can tell where he is currently located.

vladgur’s picture

snupo’s picture

Title: You can fix this in your own module » Hide drop down forum list from non admins

vladgur: so, how to use the code you posted? (in newbie terms I mean)

regards

vladgur’s picture

you create your own module and put this function in there.

boran’s picture

@vlagur: This would not work for me with D6, The error on submission is
"An illegal choice has been detected. Please contact the site administrator"
Watchdoc shows "Illegal choice 25 in taxonomy element."
Now 25 is the correct $forumid.

Reviewing the code, what is this line for?
$default_term=$form['taxonomy'][$vocab]['#default_value'][0];

I also tried setting
'#default_value' => array($forumid),
since dsm showed me that this usually an array.
No good eother "warning: preg_match() expects parameter 2 to be string"

The default_value value is important to ensure the posted it attributed to the correct forum.
That is why "$form['taxonomy']['#access'] = false;" is insufficient.
Also tried "$form['taxonomy']['#type'] = 'hidden';", which allowed a post to be created but was not visible in the forum..

pumpkinkid’s picture

The default_value value is important to ensure the posted it attributed to the correct forum.
That is why "$form['taxonomy']['#access'] = false;" is insufficient.
Also tried "$form['taxonomy']['#type'] = 'hidden';", which allowed a post to be created but was not visible in the forum..

This is exactly what I am seeing.... I had to do a display none, but we all know that's just a hack!

Also, I should probably mention, that this is happening on a site that is not using advanced forums as well, so the issue is likely not with anything Advanced forum is doing...

michelle’s picture

Status: Postponed » Closed (won't fix)

I'm not going to be doing this one in 2.x. It will likely happen in 7.x-3.x but in such a different way that this issue will be irrelevant.

Michelle