If you have a grouped field (such as a date, for example), the unformatted preprocessor makes an incorrect assumption.
In the ForEach, it's assumed $id correlates to the $id in $view->result (eg, a "row counter"). However this is not the case. The $id actually corresponds to the row number for the group. This means if you have lots of groups, all with single grouped values, this $id will always be 0 (zero).
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | grouping_field_tokens-1002714-5.patch | 1.58 KB | pascalduez |
| #4 | grouping_field_tokens-1002714-4.patch | 1.54 KB | pascalduez |
| #3 | grouping_field_tokens-1002714-3.patch | 1.43 KB | pascalduez |
| #2 | grouping_field_tokens-10027414-2.patch | 1.87 KB | nicholasthompson |
| #1 | grouping_field_tokens-1002714-1.patch | 1.49 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedDoes this patch fix the problem?
Comment #2
nicholasthompsonNo, however that row_index is handy to know as I fixed it using a static counter ;-)
Attached is an alternative patch which includes the above patch + a fix for this issue (using the $id and the $row_index together).
Comment #3
pascalduez commentedHi,
I'm experiencing the same issue, token replacement on row classes getting messed when grouping fields.
Patch in #1 did no resolved the issue.
Patch in #2 did no resolved the issue and thrown an error
"Invalid argument supplied for foreach() in [...]/semanticviews.module at line 36."
Using $view->row_index is indeed a good idea, but as it refers to the last rendered row index, then the incrementation overpass the result rows number.
The following patch create a static var initialized at 0, and increment it at the end of the preprocess fonctions.
Review welcome :-)
Comment #4
pascalduez commentedOkay, previous patch in #3 logically fails on pages with several views...
The following address it using a keyed array by view vid.
Comment #5
pascalduez commentedview vid doesn't work with views exported in code, thus not stored in DB.
Switched to view name...
Comment #6
bladwin commentedDoes this [comment #5] patch work ... can anyone else confirm?
----- EDIT: Confirmed Working -----
Comment #7
bladwin commentedThe patch in comment #5, I can confirm that it works.
I upgraded my semanticviews module to the latest 1.x-dev release before applying the patch though. Can someone else confirm that the patch also works as intended with the stable 1.1 release?
----- EDIT -----
So a few hours went by, no error messages and everything was working -- the error that appeared was an error in semanticviews.module, Line 36: (invalid argument supplied)
I changed the two "$row" args to "$row_id", which is what the patch is changing in semanticviews.theme.inc. the error moved down a line to 37 and was still an invalid argument supplied. The other strange issue is that if the error appears 8 times, it was only the last 8 rows whose tokens were not processed, the preceding rows, in multiple groups, had their tokens processed w/o any issue. I'm hoping that I will get this resolved soon, as I really need my $row $tokens to be processed in a group.
Comment #8
MrMaksimize commentedSo I don't know much about semanticviews, or views coding in general, but here's how I ended up modifying a code to get this to work.
What was interesting is that some rows that run through this function are empty variables, therefore the warning in the foreach loop.
The second thing, I'm not sure about this, but as far as I know you can't run a foreach loop on a stdClass object. So I added the conversion to an array before the loop runs.
Comment #9
MrMaksimize commentedyay! got it working. after looking at it more it turns out that quicktabs pre-loading the views in the background was the culprit of the empty rows being passed. But the really good question is why?!? :)
Comment #10
djschoone commented#1002714-5: Bug with Token Replacements when grouping works for me. I did not patch the semanticviews module, but made de changes in the function and placed it in template.php
Comment #11
Scyther commentedD6 no longer supported. It will not be fixed.