Hi

I'm trying to set up 2 different forums that need to look different. So far I am completely stumped!! Is there a way of setting up advanced forum to use a specific style for each forum container? My only other option looks like using phpbbforum. Any ideas???

Jon

Comments

michelle’s picture

Title: different themes/styles for different forums » Allow different styles for different forums
Version: 6.x-1.1 » 6.x-2.x-dev
Category: support » feature

There's no way you could do this in 1.x outside of hacking the module. If you want to go to that route, find:

function advanced_forum_get_current_style() {
  return variable_get('advanced_forum_style', 'naked');
}

and put in some custom code to change what it sends back based on what forum you're in.

I'm switching this over to a feature request. It's something I can consider doing for 2.x. Even if I don't get a UI in for it, I could at least make the function easier to hook into.

Michelle

jon pollard’s picture

Thanks!

I've had a hack around with this and I'm a bit lost. I'm looking for something like:

<?php
function advanced_forum_get_current_style() {
  if (forum container name ='my_container_name') {
    return variable_get('my_new_style', '');
  }
  else  {
    return variable_get('advanced_forum_style', '');
  }
}
?>

But I am absolutely stumped on how to get the name of the forum container that we are in. Would this work and do you have any tips on how to grab that variable?

Thanks for getting back to me so quickly!
Jon

jon pollard’s picture

Hi Michelle, I've had another look at this and figured out my first mistake! I've now got this:

function advanced_forum_get_current_style() {
  if ("forum container name" ='my_container_name')	{ 
    return 'my_new_style';
  }
  else	{ 
    return 'advanced_forum_style';
  }
}

But I am stuck as to how I can get the "forum container name" or nodeID of the forum/container. I'm kind of new to Drupal and php, most of what I've done until recently has been classic asp development and I'm not really sure where to turn for help. I'm in the middle of a commercial project, so there are funds to help fix this... Any advice on where I might be able to find help would be much appreciated.

I hope you don't mind me asking for help, but I'm a bit desperate! Is this an easy thing to sort out, or much more difficult than I'm anticipating???

Jon

michelle’s picture

Sorry, I missed that you commented again. I thought it was still active because it's on my to do list.

If you're in the forum topic list, you can get it from the URL. It will be arg(1) since the internal path is "forum/N" where "N" is the forum term ID.

If you're on an individual post, you would have to look at the terms on the node and figure it out from there. I believe it's in $node->taxonomy but I don't know off the top of my head. Take a look in there and see if you can figure it out. If not, I can look more later. Just doing a quick run thru my tracker before breakfast right now.

Michelle

jon pollard’s picture

Michelle

Thanks for the help, I've done a fair bit of hacking around and I think I have a working solution:

function advanced_forum_get_current_style() {

	// get taxonomy arrays
	if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
		$node = node_load(arg(1));
		if (module_exists('taxonomy')) {
			$terms = taxonomy_link('taxonomy terms', $node);
		} 
	}
        // if it's a reply
	if ( arg(0) == 'comment' && is_numeric(arg(2)) ) {
		$node = node_load(arg(2));
		if (module_exists('taxonomy')) {
			$terms = taxonomy_link('taxonomy terms', $node);
		} 
	}

	// horrible list!
	if (
	((arg(1)== 1) or ($terms["taxonomy_term_1"]['href'] == 'forum/1'))	or	
	((arg(1)== 2) or ($terms["taxonomy_term_2"]['href'] == 'forum/2')) or	
	((arg(1)== 7) or ($terms["taxonomy_term_7"]['href'] == 'forum/7'))
	)
  { 
    return 'blue_lagoon';
  }
  else	{ 
    return 'minimal';
  }
}

If I were a better programmer it would be shorter and neater, but at least it works! I needed to learn about php arrays before I could get the taxonomy stuff working and I found a very useful script which drags out taxonomy details here:

http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms...

So, many thanks for your help!
:o)
Jon

michelle’s picture

Status: Active » Fixed

Sounds like you got something working for you and I'm not likely to have time to write anything for this into the module, so calling it good enough.

Michelle

Status: Fixed » Closed (fixed)

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