Because of another issue that I reported, I was using a dev version of Views Accordion. I updated that dev version last week or the week before, which I believe broke the accordion. The headers were visible for each accordion, but clicking on them did not reveal the hidden divs. Knowing I was using a dev version I decided to wait until the next official release, to see if the problem still occurred, before reporting a bug. So I updated to the latest recommended version today and now VA does not work at all. All lines display in full, as if Javascript was turned off or something. However, this is not the case. Other jQuery modules are unaffected. Only VA is broken. I tried creating new VA views, but get the same problem.

I attached two screen-shots highlighting the bug, one showing the VA settings and the other showing the result. I set some fairly standard options, but nothing behaves the way it should. Further, I see a "Stop" link, which I'm guessing has something to do with auto cycle functionality, but I do not have it set, so I'm unsure why these links appear at all, and why the Open All/Close All links do not.

There seem to be some sort of internal settings out of whack, only where are they kept and how do I reset them? I tried deactivating the module, but there is no uninstall, so there's no way to clear any settings. I'm not sure if this is a broader issue, or if there is some "do over" I can do here.

I'm using the latest version of Drupal 6 (6.14) and Views (6.x-2.7, though I had the same problem with 6.x-2.6), as well as the tendu theme (a Zen variation, 6.x-2.1-beta5).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Manuel Garcia’s picture

Category: bug » support

I have setup my view exactly how you have, using three fields (title, teaser and node link), and with the options you show in the screenshot for views accordion, and it's working just fine...
I even tested using the same theme as you are (although this should not affect the accordion at all, unless you are using custom views-view-accordion.tpl.php files).

Did you delete the whole views_accordion directory and then unpacked the new version?
If so, did you try re-saving the settings/using other settings?

As of now, I am unable to replicate your issue, so I'm setting the status to support request. If we confirm this is indeed a bug, we'll set the status accordingly.

grantkruger’s picture

Thanks for your fast reply. I had tried what you suggested. I went back and did it one more time. I removed the module from Drupal, physically deleted the folder, removed all setting from the view, got the view working with other settings, then changed the view one more time for good measure, then downloaded the latest version of the module, then activated it, changed the view to views accordion. I still got the same issue, namely all the elements displayed in full and a visible "Stop" Link.

I think it is related to the theme in some way, and I kinda proved it. Acting on my guess I changed my default theme to garland and sure enough, the accordion now works as expected. We do have a customized version of Tendu and I do have to wonder if our Themer changed something that might affect VA.

I should add that I'm using the Admin module which uses the slate theme for admin, which seems to be active in some fashion, even when you are editing pages in your main theme. The Admin module is a port back from Drupal 7, so it's a good way to make Drupal 6 sites feel more like Drupal 7 sites, and is also a sign of things to come. I was not sure if it was the combination that was the issue, so I turned it off, but the problem remained. So yes, the signs are that it is our theme, in some way, messing with the way jQuery works... or maybe is changing the way views displays output, which affects VA.

Do you have any suggestions on what we might look for? HTML/CSS that might mess with the way VA works? I think it may be useful, so I'm including some HTML code. I wish there was some way to abbreviate it, but I seem to be stuck with the html code tag in this forum. Here's what the HTML looks like for the broken code:

<div id="block-views-test_accordion-block_1" class="block block-views block-first block-last block-odd">
	<div class="content">
			<span class="stop-accordion"><a class="stop-accordion" href="#">Stop</a></span>
			<div class="view-content">
				<div class="item-list views-accordion views-accordion-test_accordion-block_1">
					<div id="views-accordion-test_accordion-block_1">
						<div class="views-accordion-item accordion-item-0 accordion-item-odd accordion-item-first">
							<div class="views-field-title">
								<span class="field-content">Test Blog Entry</span>
							</div>
							<div class="views-field-body">
								<span class="field-content">LEFT Suspendisse congue enim non ligula euismod eu consequat orci iaculis!...</span>
							</div>
						</div>
						<div class="views-accordion-item accordion-item-1 accordion-item-even">
							<div class="views-field-title">
								<span class="field-content">Test Blog Entry 2</span>
							</div>
							<div class="views-field-body">
								<span class="field-content">Morbi nec mattis quam. Nulla vel ligula ac libero elementum egestas. Vestibulum...</span>
							</div>
						</div>
						<div class="views-accordion-item accordion-item-2 accordion-item-odd">
							<div class="views-field-title">
								<span class="field-content">Test Blog Entry 3</span>
							</div>
							<div class="views-field-body">
								<span class="field-content">Sed fringilla suscipit convallis. Curabitur semper sem vitae quam scelerisque...</span>
							</div>
						</div>
						<div class="views-accordion-item accordion-item-3 accordion-item-even">
							<div class="views-field-title">
								<span class="field-content">Test Blog Entry 4</span>
							</div>
							<div class="views-field-body">
								<span class="field-content">Suspendisse vitae nisi ac mi volutpat semper volutpat eu metus. Proin convallis...</span>
							</div>
						</div>
						<div class="views-accordion-item accordion-item-4 accordion-item-odd">
							<div class="views-field-title">
								<span class="field-content">Test Blog Entry 5</span>
							</div>
							<div class="views-field-body">
								<span class="field-content">Etiam gravida sapien a eros blandit in faucibus turpis luctus. Nulla facilisi....</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
Manuel Garcia’s picture

In the case for VA, I document in the tpl included in the module what needs to be there etc. I don't recommend changing this tpl unless you know what you're doing.

My suggestion is you check if any views tpl files other than the defaults are being used (if you have any views tpl in your theme's directory). If so, remove them from your theme, and see if that fixes the problem.

grantkruger’s picture

We tried removing all of the themer's tpl files, but the problem remained. Very baffling. Something really odd is going on here.

However, today I found a clue. I looked at our test site hosted on another server... and VA is working there with the exact same code & database. Very baffling. Identical code, identical databases, and yet one works and the other does not. I've flushed caches more times than I can count and tried multiple things. Since jQuery works browser-side and I'm running my local dev and the remote test site in two tabs in the same Firefox session, it suggests that this is actually indirectly a PHP error of some kind.

My first thought was that my php settings might be different, and certainly it appears to be the case because there is one possible clue. In the test site, the site where VA is working, when editing the VA view I see the following error message:
warning: array_merge_recursive() [function.array-merge-recursive]: recursion detected in xxx/includes/common.inc on line 2216.
However, if I change to view to a different display style, then re-edit the view, then the error is gone. Add VA back, save and re-edit... and the error is back. So the possibility exists that there is some error that is getting blocked on my test site, which in turn allows VA to function properly, but on my test box, where setting are less stringent and I get no error, VA breaks.

I hope I was clear there. In summary, in one environment I get the above error message, but VA works, while in another environment I get no error and VA does not work.

Another side note is that the test site is Linux and my local machine is a Mac, but I'm not sure if/how that affects things either.

The code in /includes/common.inc is as follows (line 2204 to the error line, 2216):

  // For inline Javascript to validate as XHTML, all Javascript containing
  // XHTML needs to be wrapped in CDATA. To make that backwards compatible
  // with HTML 4, we need to comment out the CDATA-tag.
  $embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
  $embed_suffix = "\n//--><!]]>\n";

  foreach ($javascript as $type => $data) {

    if (!$data) continue;

    switch ($type) {
      case 'setting':
        $output .= '<script type="text/javascript">' . $embed_prefix . 'jQuery.extend(Drupal.settings, ' . drupal_to_js(call_user_func_array('array_merge_recursive', $data)) . ");" . $embed_suffix . "</script>\n";

I hope this is some help. Hopefully all this means more to you than it currently does to me.

Manuel Garcia’s picture

Very weird indeed, no clue what could be going on, VA does nothing fancy when it comes to passing settings to the js file, same old stuf done in other plugins, and it just gets them from views itself.

I'd compare both server settings when it comes to php, loaded php/apache modules and versions, maybe that gives you a clue, but afik VA does nothing fancy requiring any other php stuf than you normaly have for running drupal.

grantkruger’s picture

I'll see what I can find. All I know is that all the rest of the site's jQuery works fine, even the jQuery on the same page. Thanks for your timely replies. This has been a time-killer. I'll come back to it later and assess needs again.

grantkruger’s picture

Having shelved this for quite some time, I am planning to come back to it. I thought I'd add the following interesting tidbits:

  1. If I embed Views Accordion view X into a standard block in the main content area, then it does not work.
  2. If I embed Views Accordion view X into Panels pane, then it does work.
  3. (Edit to add:) If I embed a second Views Accordion view Y into Panels pane that already has view X, then it does not work (probably an unrelated issue).
  4. If I embed Views Accordion view X into an element created by another jQuery module, in this case a QuickTabs tab structure, then it does work.

Could this be some obscure unclosed tag, unclosed something, condition? Could Panels and QuickTabs be fixing the issue?

ehs4n’s picture

Version: 6.x-1.2-rc2 » 6.x-1.3
Category: support » bug

I am using Views Accordion with my custom theme. If I use the accordion with block display, it works fine, but if i render a view in my theme using views_embed_view(), it doesnot work. In that case the view is displayed, but without accordion. Even the required files (css / js included in accordion module) do not get loaded at that time.

And if i assign the the same view (block display) again in my theme, it again starts working normally.

Please help.

grantkruger’s picture

More information for you. I think this entire problem might be related to the PHP version. The test site where VA mostly works is on PHP 5.2.4. However, when we moved the site to our live site with PHP 5.2.10 then any stand-alone VA broke. Only those VA blocks embedded in panels or quicktabs. Taking note of my development box where it does not work, I see that I'm on PHP 5.2.9.

To summarize: works with php 5.2.4, broken with 5.2.9 and 5.2.10.

I'd like to have tested this and proved the point conclusively, but my sysadmin pointed out that we want to keep upgrading PHP versions in case of security issues and he does not want to backtrack to PHP 5.2.4 and then be stuck on it. So there you have it. My guess is that something fails in a later version that was fine in an earlier version, and that this is the root of the problem.

For now I'm going to wrap all my VA blocks in a panel, which resolves the bug. I hope this helps.

Manuel Garcia’s picture

using php 5.2.10 here, works fine

grantkruger’s picture

Another theory bites the dust.

grantkruger’s picture

It's so odd. I thought I had a workaround, by adding accordions to panels... which works fine... unless you are using a VA group. Groups in VA disappear if they are in a Panel.

Do you have any suggestions for me? A suggested hack, a workaround, something to look for... anything? What can I do to track this thing down? What could be different about one older Linux server I'm using, where VA works, compared to my Macbook or a brand new Linux server? Something is going on on the server end. I'm out of ideas.

agrathea’s picture

Priority: Normal » Critical

I looked into this issue myself, and I discovered that there was a difference between the way the page's javascript was loading for the working and non-working versions. I'm still baffled by how just putting the code on another server could make this change, because there is essentially nothing different between the versions other than the server environment (and even those are only slightly different).

What is happening, as far as I can tell from my non-JS-expert standpoint, is that the attributes that control the javascript are loading twice. Here's some sample code from what is being generated in the non-working version:

"views_accordion": { "views-accordion-program_contents-block_1": { "keeponeopen": [ 0, 0 ], "startopen": [ 0, 0 ], "rowstartopen": [ "0", "0" ], "speed": [ 500, 500 ], "disablecloseothers": [ 1, 1 ], "grouping": [ 1, 1 ], "togglelinks": [ 1, 1 ], "autocycle": [ 0, 0 ], "autocyclespeed": [ 5000, 5000 ], "display": [ "views-accordion-program_contents-block_1", "views-accordion-program_contents-block_1" ], "usegroupheader": [ 0, 0 ], "header": [ "views-field-title", "views-field-title" ] } }, "views": { "ajax_path": [ "/views/ajax", "/views/ajax" ], "ajaxViews": [ { "view_name": "program_contents", "view_display_id": "block_1", "view_args": "4+18", "view_path": "node/320", "view_base_path": null, "view_dom_id": 6, "pager_element": 0 }, { "view_name": "program_contents", "view_display_id": "block_1", "view_args": "4+18", "view_path": "node/320", "view_base_path": null, "view_dom_id": 7, "pager_element": 0 } ] } };

In the one that's working, it looks more like:

 "views_accordion": { "views-accordion-what_we_look_for-block_1": { "keeponeopen": 0, "startopen": 0, "rowstartopen": "0", "speed": 500, "disablecloseothers": 1, "grouping": 1, "togglelinks": 1, "autocycle": 0, "autocyclespeed": 5000, "display": "views-accordion-what_we_look_for-block_1", "usegroupheader": 0, "header": "views-field-title" } }

When I delete the "doubles" in the first version and replace my code with that which is generated automatically, it loads fine.

Any ideas on what could be causing this?

grantkruger’s picture

So... we came up with a fix... well, it would be more honest to call it a horrible, nasty, vicious little hack. First, some context. We still don't know where the actual issue is, but here's the thing, the method render() (in views_accordion_style_plugin.inc) gets called twice for the same view. It appears that this is because the view itself is called twice. As a result, render() calls drupal_add_js() twice for the same view, and this is what breaks the accordion, resulting in what was mentioned in 13. If drupal_add_js() only gets called once, then all is well. So, knowing this, but not really getting why the method is being called twice, we were unable to treat the source of the problem or to tackle the problem in the "ideal" way... let alone best practices. So we put in a small hack that ensures that drupal_add_js() is called once.

Here's the diff code for the changes we made to views_accordion_style_plugin.inc:

    * Render the display in this style.
    */
   function render() {
+	global $renderDuplicate; // CHANGE
+
     $output = parent::render();
 
     // dpm($this->display->handler->get_option('fields')); // for dev-troubleshooting
@@ -160,7 +162,14 @@
         }
       }
     }
-    drupal_add_js(array('views_accordion' => array($view_id => $view_settings)), 'setting');
+    // CHANGE BELOW
+	if ($renderDuplicate) { // Is this the first time render has run for the view?
+		unset($renderDuplicate);
+	} else {
+		$renderDuplicate = true;
+		drupal_add_js(array('views_accordion' => array($view_id => $view_settings)), 'setting');
+	}
+    // CHANGE ENDS    
 
     return $output;
   }

As you can see, it's horrible, basically just asking if this is the second time through and then skipping it. A better way would be some way of asking if this is the second time through for the same view. Hell, I'm sure almost every other way of doing this would be better. In our case this does not matter as we never have two accordions on the same page anyway. It's a bandaid on an axe wound... but hopefully this workaround is of some use to helping you to resolve this.

Manuel Garcia’s picture

Category: bug » support

OK, this is definetly not a bug report, since its only you in that enviroment seeing this problem. So I'm setting this to support request.

I've got no idea what would go on like i said, and well, you are modifying the module's files, so your reponsibility now... In the js I'm already checking if it already did its thing, so no clue what would be causing the problem, and I cannot replicate it... sorry!

grantkruger’s picture

Well the module does not appear to be checking to see if it has already done it's thing because that seems to be the problem. If you look at #13 the JS is wrong. It fails if the same view is called twice. Views handles this fine and the view does not appear twice. VA does not handle this and duplicates the JS entry. We're looking in to this and I'll let you know what we find, but this could happen to someone else.

We do not want to change the module code. How else could we identify the problem? We only changed it to demonstrate the issue to you and to try and be helpful. We had no idea you were being annoyed by the information.

Manuel Garcia’s picture

It's fine changing the code to troubleshoot, of course. It's even fine to change the code otherwise, this is free software after all.

As far as what is said in #13, I cannot replicate this, and so it's impossible for me to troubleshoot this or even to verify it.

Your information is not annoying me. If I gave that impression on my last comment, it was not my intention.

The JS does check if it has done its thing already, in this line:
var hasRan = $(idSelector + ' ' + contentSelector).length;

And after we check this variable before doing anything:
if (!hasRan) {

You may want to troubleshoot in this area see if you find anything for your case.

I am of course opened to fixing this if it's eventually found to be a bug, but as it stands right now, I cannot replicate it, so there's not much I can do but give you info on how the module works...

hefox’s picture

Way too tired to read above, but there's an issue when $view_id is duplicate; the drupal_add_js does an array merge and values that shouldn't be combined get combined (the header selector turned into 'field-field-title,field-field-title' for example). $view_id needs to be unique. I would have a patch, but tried upgrading to dev and forgot to commit first, so it's messy atm.

ionut.alexuc’s picture

I implemented a workaround for that.

I have a global $renderDuplicate; in the function render in file: views_accordion_style_plugin.inc

Then I use:

global $renderDuplicate; 

if (!in_array($view_settings['display'], $renderDuplicate)) {
  drupal_add_js(array('views_accordion' => array($view_id => $view_settings)), 'setting');
  $renderDuplicate[] = $view_settings['display'];  
}

Basically, I put all the displays into array and I do not allow to add the values for that display again.

Ionut

Manuel Garcia’s picture

That's not a clean way of solving this ionut.alexuc.

Apparently hefox in #18 found a way to fix this (although I havent been able to duplicate this problem), I'm opened to suggestions, but please submit a proper patch so we can all play on the same ground.

ionut.alexuc’s picture

I had to fix this bug for someone else.

He cloned the website to another hosting and the accordion was not working... and working on the first hosting.
So, it may be an issue with the environment, not with the views_accordion.

I will check the comment #18 and see if there are duplicate views in the page.

Manuel Garcia’s picture

Status: Active » Closed (fixed)

Assuming this is no longer a problem for you, due to lack of activity.

mohirt’s picture

I'm having this exact same problem, only I can't get the fix ( #14 ) to work and I don't appear to have any duplicate views ( #18 ). I have spent a number of hours on this today and can confirm it's the same bug.

mrfelton’s picture

Version: 6.x-1.3 » 6.x-1.4
Status: Closed (fixed) » Active

Same problem for me. The change in #14 works for me.

mrfelton’s picture

Status: Active » Needs review
FileSize
944 bytes

Here is a patch to the effect of #14

firebus’s picture

Priority: Critical » Major

i also had this problem, in this case i have the accordion in a view block, and i am using blockreference to display the block inside a cck node.

fix in #14 worked for me.

accordion was working fine when the block was displayed in a normal (block.tpl.php in a region) way.

re #17, it's clearly not enough for the js to check to see if it's done its work before it starts to modify the DOM - we also need this check to make sure drupal_add_js(..., 'settings') isn't performed twice. but i have no good reason why that should be...

sambaynham’s picture

An interesting bug for you:
For various reasons, I have had to use views embed view to insert a view accordion into some tabs on my page.
This worked fine, right up until I imposed a testing regime:

$view = views_get_view($viewname) or die('no such view');
$view->set_display('default');
$view->args = array($rel_parts_from_node);
$output = $view->preview();
if ($view->result)
{
$testcondition = "true";
}

And that gave me this error. Take the code out again, and it works just fine.
I'm no drupal Ninja, but I think that calling the view before views accordion had a chance to do so broke it.
Maybe you can make something of this, I'm not sure.

For myself, I now need to think of a way to test without testing. Hmm. Zen.

Katrina B’s picture

Chiming in with a note that I'm having the same problem. I am using Views Accordion in a Viewfield, which is then being called through other Views (I'm trying to create collapsible comments in Views). One View, which I've made the default "group home page" View for Organic Groups, displays the Views Accordion just fine. Another View does not -- even if I try to display it as a page, a View Reference, or a block.

I haven't tried patching the module yet ... but I did want to note that the problem exists for more than just those who have posted here thus far.

Katrina B’s picture

Our developer applied the patch -- now I get Views Accordion for the first row of a View, but not for the rest of the rows.

Parkes Design’s picture

Version: 6.x-1.4 » 6.x-1.5

Thankyou - Option 14 worked for me as well.

grantkruger’s picture

Our patch was a horrible hack based on a tight timeline. However, as I recall, it would only work if there was a single views accordion on the page, which was all we needed. Your needs may differ. I think we had one exception to this and we were able to use views groups to make it work. It has been two years, so memory is a bit fuzzy.

tommeir’s picture

#14 worked for me as well as a fix for a different error, where the accordion would break if arguments where present in the view load.

jvieille’s picture

#14 made it worse; accordion does not collapse anymore in any situation.

Edit:
#19 is the right one

uddhi108’s picture

I was having the same issue as #13 and #14 fixed it for me. Look at view source to see if #14 fix is for you.

Thanks for the fix!

Manuel Garcia’s picture

Status: Needs review » Closed (won't fix)

6.x no longer supported.