It seems like what I'm trying to do should be possible, but I can't seem to find the answer anywhere.

Is there a way to render a panelized node, including the custom content added through panelizer programmatically?

using node_view(node_load($nid)) returns the data from the node without the customizations and content added by panelizer.

Any advice would be appreciated. thanks!

Comments

morseCode’s picture

This is how i ended up doing this in case someone else happens upon this post

  module_load_include('inc', 'page_manager', 'plugins/tasks/node_view');
  $node = node_load($nid);
  $render = page_manager_node_view_page($node);
morseCode’s picture

Status: Active » Closed (fixed)
eclipsegc’s picture

For anyone else who finds this, here's the appropriate way to solve this:


    ctools_include("plugins");
    $plugin = ctools_get_plugins("page_manager", "tasks", "node_view");
    return page_manager_node_view_page($node);

Eclipse

merylmabin’s picture

#1 mostly worked for me, except that I needed to change the last line:

page_manager_node_view_page( $node )["content"]["#markup"]

Würden’s picture

This only renders the node with the node_view panel, not the panelized panel. So the suggested solutions are not really for panelizer, only panel nodes.

For the standard panels node layout I use a 1col layout but for the panelized layout for full content of a node type I use a different 2col layout, but using the suggested method it seems the whole process of rendering with panelizer is skipped, the node only comes out in the 1col version. Is there any way to actually render the node programmatically with a panelized layout applied?

Würden’s picture

Status: Closed (fixed) » Active

The only way I was able to achieve what I wanted, load the node with the correct panelized layout was to use file_get_contents from the node URL and from there get the raw HTML code and filter out header/footer.
This can't be the only working way of achieving this, it must be possible somehow to load a node as Panelizer does.

damienmckenna’s picture

Version: 7.x-3.1 » 7.x-3.x-dev

@CFE: What view mode are you using with Panelizer for the node you want to display?

Würden’s picture

#7 I'm using the standard, "Full content" build mode. In page manager the Node template is activated and inside that panel is the pane "Node being viewed" content - which is usually rendered via panelizer on the frontend, however using the node_view function it seems to skip rendering with the layout I selected in panelizer. So my guess is that you need to use something more specific than the node_view() function.

andriy khomych’s picture

Hi all, what about set up special view mode for render?Teaser for example.

steveoriol’s picture

Hello,
#1 or #3 worked for me, but I get an Array when I am connected with user 1 (with content is in ["content"]["#markup"]).
with this PHP Notice :

Array to string conversion in eval() (line 31 of /home/sites/drupal7/modules/php/php.module(80) : eval()'d code).

But for anonymous or normal users, "page_manager_node_view_page($node)" return directly the HTML content.

Why? , can I have the same results ?

damienmckenna’s picture

@steveoriol: Maybe the Contextual module, or something else, is trying to add extra data to the output? What is the node being rendered? Maybe that system is expecting the output to be in a different structure, e.g. a string instead of an array?

monymirza’s picture

    global $user;
    module_load_include('inc', 'page_manager', 'plugins/tasks/node_view');
    $node = node_load($nid);
    $node_view = page_manager_node_view_page($node);
    if (isset($user->roles[3])) {
      return drupal_render($node_view);
    } else {
      return $node_view;
    }