I get how to use the blocks, but I would like to put certain forums, or threads into a panel. Any ideas on how to do this?

Comments

jeff h’s picture

You can put forum nodes into a panel very nicely... create a node override panel (url will be node/%) and give it a node id context. Tick each content type you wish to override.

Putting other parts of the forum system (eg forum listings) into a panel is not so easy. Doable, using code (I can provide you with some sample code if you know your way around template.php) but without a bit of your own PHP I am not aware of a way to do this right now.

iaminawe’s picture

I have been wanting to put the forums listings page and the user blog listing page into a panel too.

I have searched around quite a bit for a solution to this so if you have code that you could share to help achieve this I would be most appreciative.

Thanks

jeff h’s picture

OK, the code isn't without compromises; to the best of my knowledge, your panel won't have access to contexts, for example.

Firstly, read through the info at http://drupal.org/node/232644. Basically my only modification to that code is to switch the value of the 'DEFAULT' depending on the current page's path.

In the _phptemplate_variables function in your theme's template.php, put the following code:

    case 'page':
		$current_panel = panels_page_get_current();
		if (!isset($current_panel->pid)) {
		    // Load our default panel, depending on the current section, and call it by name.
				switch (arg(0)) {
					case 'forum':
			    	$panel_name = 'forums';
						break;
						
					case 'articles':
			    	$panel_name = 'articles';
						break;
						
					case 'downloads':
			    	$panel_name = 'downloads';
						break;

					case 'links':
			    	$panel_name = 'links';
						break;

					default:
			    	$panel_name = 'default';
						break;
				}
				
				$panel = panels_page_view_page($panel_name, false);

		    // Insert the actual content of the page using string replace.
		    $panel = str_replace('%CONTENT%', $vars['content'], $panel);

		    // Replace the page content with our altered panel.
		    $vars['content'] = $panel;
		  }

Hope I got that all right (I'm pulling a fair bit of site-specific stuff out of the above code). Let me know how you go!

Jeff

surge919’s picture

this is what my _phptemplate_variables function looks like:



function _phptemplate_variables($op = 'page'){
    case 'page':
        $current_panel = panels_page_get_current();
        if (!isset($current_panel->pid)) {
            // Load our default panel, depending on the current section, and call it by name.
                switch (arg(0)) {
                    case 'forum':
                    $panel_name = 'forums';
                        break;

                    case 'articles':
                    $panel_name = 'articles';
                        break;

                    case 'downloads':
                    $panel_name = 'downloads';
                        break;

                    case 'links':
                    $panel_name = 'links';
                        break;

                    default:
                    $panel_name = 'default';
                        break;
                }

                $panel = panels_page_view_page($panel_name, false);

            // Insert the actual content of the page using string replace.
            $panel = str_replace('%CONTENT%', $vars['content'], $panel);

            // Replace the page content with our altered panel.
            $vars['content'] = $panel;
          }
}


I get the following error when I run it..

Parse error: parse error, unexpected T_CASE in /var/www/html/php/drupal-5.7/themes/ability/template.php on line 42

Any ideas?
thanks.

iaminawe’s picture

havent had a chance to apply this yet but will report back with results when I do.

sdboyer’s picture

The proposed code ought not have any effect on your panel's access to contexts.

FYI, this is now the fourth issue where someone has referenced http://drupal.org/node/232644 as a reason that a) they went down a path that gave them more problems with panels, not less, or b) they got really confused about what panels does and doesn't do. I just don't have time to take care of documentation stuff like that right now, but I'm getting to the point where I almost just want to delete it. If nothing else, it does a _really_ great job of muddying the nomenclature even further.

@OP: 'certain' forums or threads may be a little difficult. They'd have to be differentiated based on taxonomy ID or something like that, so that you can tell panels_page to only panelize nodes with certain tids.

Panelizing all forums, though, is much more just a matter of picking a node ID context and ticking the right boxes, as pointed out in #1.

The title replacement issue is just plain complicated and ugly right now, although we've got a fix in that hopefully evens things out for RC1.

iaminawe’s picture

I get the same T_Case Error when I run the above code so it does not work for me yet either.

I noticed though that I cant seem to get the example at http://drupal.org/node/232644 to work any more either.
My template does not have the $op = 'page' in it and if I place it within the _phptemplate_variables that is being declared I notice no visible difference.

@sdboyer - so is this method a dead end to replace the main forums and faq page? It seemed to work once and well and then never again. This is a really great thing to be able to do with panels.

Has anyone done this before with the drupal forums?

Maybe I just need to theme my main forums page to look like my panels page?
The node override works great for individual forum threads.

sun’s picture

Status: Active » Fixed
function _phptemplate_variables($op = 'page'){
    case 'page':

You should learn PHP. See http://de.php.net/manual/de/control-structures.switch.php

socialnicheguru’s picture

subscribing

Status: Fixed » Closed (fixed)

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