1

With Drupal and views you can generate a table with for example a list of users and their contact details.

Let's say I have a user outside of the system that I want to add to the table statically, what's the best way to do this in Drupal?

The ways I am thinking of are:

  • Write a module that db_select or use enityfieldquery into an array, add the external user info and put it through theme table and outputs it on a page.

  • Override the views template and add the user info there.

    Are there better ways?

  • 1

    1 Answer 1

    2

    Low level way is to use hook_query_alter - with it, you can add UNION with anything.

    More direct Views way is hook_views_post_execute:

    This hook is called right after the execute process. The query has been executed, but the pre_render() phase has not yet happened for handlers.

    Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after. Altering the content can be achieved by editing the items of $view->result.

    0

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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