When I make a custom view of the forums that tries to override the /forum/% I get this error:
Notice: Trying to get property of non-object in forum_menu_local_tasks_alter() (line 170 of /home/quickstart/websites/example.dev/modules/forum/forum.module).
To recreate: drush a d7 site with ctools and views. Create a forum or two. Put a few posts in the forums.
Import the attached view. Go to the forums, drill into a forum. You'll get the error.
I'm a noob so maybe the view is built wrong. It's a node view, with arguments, Taxonomy ID, filtered on the forum vocabulary. The page is set to a url of forum/%.
The failing line is:
$tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0]->tid : 0);
"page_arguments" is empty on the Views version but is there on the default version.
Is this a views or forums problem? Where do I look next?
Comments
Comment #1
DeweyOxberger commentedTracing into it a bit more shows if the view comes from the normal forum view then $router_item['page_arguments'][0] points to an object. If the view is coming from my custom view it points to an array that contains:
[0] = 'detailed_forum_view';
[1] = 'detail_forum_view';
[2] = '12';
This can't be the answer but I just hacked the code to watch for the two possibilities and handle them both. So forum.module line 168 looks like:
Seems to work but it smells. Was views supposed to be making that object?
Comment #2
DeweyOxberger commentedSide note - it appears this issue is happening in Advanced Forum's D7 version but I've created it here with just Core, ctools, and Views (no AF needed).
Comment #3
mukesh.agarwal17 commentedI think the view is not created in the right manner.. what is it that you are trying to achieve over here with your view? lets say we have a forum page forum/[tid] that will be handled by the forum module.. now if you need a view to display more info or something like that.. you need to create a separate url structure like 'forum/%/detail' which will use tid as the argument.. does this make sense? you cannot register more than one page of the same structure.. in your case 'forum/%' is already handled by forum module.. you'll need another url structure.. in case you need to show something on the same page of the forum, you dont need to add a page display, you can go ahead with a block and then you need to change the block visibility settings to make it appear on forum/% pages..
Makes sense?
Comment #4
DeweyOxberger commentedAre you sure? I thought Views allowed you to override module views. Views comes with a replacement for /taxonomy/term/% as an example so I assumed I could replace /forum/%.
Tracing through the code it seems to work (except the array didn't get the correct values in it). With the hacked code in place it seem to work.
Basically I need /forum/% to display four more columns of taxonomy terms that I've added to a forum. I want to replace the normal forum view with my own.
Comment #5
michelleI don't have an answer to your problem but, if you want a work around, you can use Page Manager in CTools with AF to replace the /fourm/% pages with whatever you like.
Michelle