0

I've got a view that I'm accessing via code and used to pull fully rendered view code and work great. But after one of the updates (looking like 6.x-2.15 or 6.x-2.16 maybe changed it?), I can no longer reference fields that are using views' field token replacement logic. All I appear to have access to now is the text that contains the token arguments, and not the final rendered code.

This is the code that used to work:

function _custom_module_get_view_options() {
    $view = views_get_view('VIEW_NAME', true);
    $view->pager['items_per_page'] = 0;
    $view->execute();
    $view->execute_display();

    $items = array();   
    foreach ($view->style_plugin->rendered_fields as $display) {
        $items[$display['FIELD_NAME_1']] = htmlspecialchars_decode($display['FIELD_NAME_2'], ENT_QUOTES);
    }

    return $items;
}

The $view->style_plugin->rendered_fields doesn't appear to exist any more in the executed view...

As I mentioned above, anything else I have tried only gets me the un-replaced text patterns.

Site is on Drupal 6, and currently using Views 6.x-2.16 but was previously using Views 6.x-2.12 when it functioned as expected.

0

There were several changes between these versions. If you check out Releases for Views you can see a list of changes for each version, and you can download each intervening version. I would suggest you peruse the list, and maybe roll back your current version, until you discover the specific change which broke your site. Then open an issue on the Views project page.

3
  • Thanks for the feedback, I've looked through the releases and see that 2.15 and 2.16 made changes related to the token replacement, but am not finding a specific issue that I can sink my teeth into...I'll dig around some more for sure though.
    – Chris Budy
    Mar 19 '13 at 18:40
  • Stepping through the versions it appears things breakdown in 6.x-2.14 actually. Have gone through all the logged changes, and nothing sounds like this have poked through the code for ones that sound remotely related and don't see anything that would cause the rendered_fields object to stop being created...sigh.
    – Chris Budy
    Mar 19 '13 at 20:53
  • The security fixes were in 6.12 1nd 6.13. You should run a diff between 6.13 and 6.14 to see exactly wha the changes were. Good luck.
    – Triskelion
    Mar 19 '13 at 21:16
0

The $view->execute() and $view->execute_display() no longer return rendered_fields.

I swapped those two lines with $view->render() and I now get the expected rendered_fields element in the $view->style_plugin object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.