0

I am trying to print uc-auction bid table separately in product node template. I have printed the add-to-cart button separately like this in the node--product.tpl.php.

<?php 
 print drupal_render(drupal_get_form('uc_product_add_to_cart_form_'.$node->nid, $node));
?>

Similarly how can i print uc_auction form(uc-auction-bid-table-form) separately. I can't able to print like above for uc-auction because it doesn't have any nids associated it. Any help will be really appreciated.

Thanks in advance.

5
  • And what happens if you try to simply replicate your older solution and modify it for new problem?
    – Mołot
    Oct 4, 2013 at 10:32
  • please edit your question when providing codes :)
    – Mołot
    Oct 4, 2013 at 10:57
  • Just a comment here. I strongly recommend that you do not user drupal_get_form in the theme layer. It will have an impact on your site performance.
    – awm
    Oct 7, 2013 at 14:44
  • @arsenelupin: Then how do i print separately the add-to-cart form and uc-acution form. any suggestions?
    – Ram
    Oct 8, 2013 at 2:45
  • In a module use hook_node_load to add proper elements to the node object and hook_node_view to render the output. Look at the comment module and how it does it; namely comment_node_load and comment_node_view.
    – awm
    Oct 8, 2013 at 16:17

1 Answer 1

0
+50

In your module which implements hook_node_view, to accomplish this, do something along these lines:

   function module_node_view($node, $view_mode, $langcode) {
      // Do business logic here like if these node should have the form then...
      $node->content['your_from'] = array(
        '#markup' => drupal_render(drupal_get_form('uc_auction_bid_table_form')),
        '#weight' => 10,
        // you may or may not need this based on your implementation : '#theme' => 'theme_uc_auction_bid_table',
      );
    }

Drupal 6: use hook_nodeapi

function modulename_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {   
    case 'view':
      // Do business logic here like if these node should have the form then...
      $node->content['uc_auction_bid_table'] = array(
        // Try drupal_render if theme does not work            
       '#value' => theme('uc_auction_bid_table', drupal_get_form('uc_auction_bid_table_form')),
        '#weight' => 10,
      );
      break;
  }
}
1
  • Thank you very much. I'm also looking for option to render this form in block (in product node page). Is it possible? Have u tried anything like that?
    – pown
    Oct 15, 2013 at 6:50

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.