3

I'm trying to build a page in my site where users can create a new project (fill out a few text boxes to give the project a title/description), see a list of all of their projects, and edit any of those projects.

I've created a new content type called "Projects" that includes all the text fields needed for creating a new project. And I've figured out how to use Views to display a list of user projects. I've tried to display these 2 elements together using Panels, but that means I need to create a new Variant for both the Node View and the Node Edit pages, which feels clumsy in terms of development. And the end result on the web site is 3 slightly different pages (one to create a new project, one when you click on a particular project to view it, one when you edit the project). But ideally, it would feel like one slick page.

Am I taking the right approach with using Panels, or is there another module or approach that is better?

2
  • Hello Erin, and welcome on Drupal Answers. To which Drupal version are you interested?
    – avpaderno
    Commented Apr 22, 2011 at 14:15
  • I'm using 6 right now.
    – Erin
    Commented Apr 23, 2011 at 15:16

1 Answer 1

1

Hey Erin, certainly a good way to build customized pages is use Context module instead of Panels... (Context allows you to manage contextual conditions and reactions for different portions of your site. You can think of each context as representing a "section" of your site. For each context, you can choose the conditions that trigger this context to be active and choose different aspects of Drupal that should react to this active context. Link: Context).

In addition of that, you can create a block (be sure to have PHP Filter enabled), and include the following code.

For a existing node edit form:

//you should have your nid (May be loaded by a custom arg or even a given GET variable)
$nid = 99;
$node = node_load($nid);
//load needed file from node module
module_load_include('inc','node','node.pages');
//load node edit form
$form = drupal_get_form($new_node->type . '_node_form', $node);
//print the form you have loaded
echo($form);

In case you want to load a fresh node add form, instead of loading a node with node_load, you should create a stdClass object, and give the type name just as bellow:

//load the current user info
global $user;
//empty object for node
$new_node = new stdClass();
// your machine name content type
$node->type = 'page';
// set the author for the node to be created
$node->name=  $user->name;
//load needed file from node module
module_load_include('inc','node','node.pages');
//load node edit form
$form = drupal_get_form($node->type . '_node_form', $node);
//print the form you have loaded
echo($form);

Actually it may not be the best way to do that, but certainly is a functional method.

1
  • Good point. Worked for me. tks Commented Apr 22, 2011 at 3:56

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.