Drupal 7 use custom layouts created by Panels module

1.3k views Asked by At

I have recently installed the Panels module. It allows me to create custom layouts for my contents. Now, what i wish to do is, choose these template layouts while creating/editing a certain type of component so that when viewed that content appears in the selected layout.

Hope I made myself clear. Please excuse me if this topic has already been discussed. If so, providing me the link of the post will be helpful enough. Actually I am sort of a newbie in Drupal and more so in the Panles module. So not really sure if my requirement is feasible in the first place.

Thanks in advance...

2

There are 2 answers

0
jerrylow On

Understanding your question here I'll try to break it down. In order to use a panel layout for node add/edit you can chose to create the layout under /admin/structure/panels

Panels node add/edit option

Then you create a new variant. In the variant's [context] tab you'll add the context rule "Node add form", don't worry about the edit form aspect. The Node add form will cover the edit form and the additional contextual rule is to target a specific node. Then you can customize your layout and add in all the form fields in the content tab. Don't forget to add in the node submit button. Now after you've created more than one variant you can enable, disable and order them as you like which covers the specific layout for node type.

The panels layout will order it as you like. If you want control the theming from a non-administrative theme perspective you can disable general admin theme forms in /admin/appearance by unchecking "Use the administration theme when editing or creating content" at the bottom or targeting specific node types by creating a module and having:

<?php
/**
 * @file
 */

/**
 * Implements hook_admin_paths_alter().
 */
function disable_admin_theme_paths_alter(&$paths) {
  $paths['/node/add/node-type-name-here'] = FALSE;
}

Assuming your module's name is disable_admin_theme.

1
TheodorosPloumis On

You can do this by adding a field in your Content type for example of type List (text) > Select list. Each list item will represent a Panels display.

Then create a Panel display variant to override the node template (/node/%node) where you have to add the Selection rules: "YOUR List(text) field". So each variant will display if user selects the connected list option.

If you want to see the selected display online without clicking the Save button you will need probably an ajax effect.