How do I add the comments form (of the comments module) programmatically in a custom-made module?
In other words, what proper code should be added to your module code to add a complete "Post New Comment" form (of the Comments core module)?
That said, how do I force the installation of the Comment module with the installation of your own module?
I'm re-asking my question in an edited version with some new results i've reached :).
I've created a custom menu in a custom module of mine, with items of course.
I wanted to add the comment form (of the Comment module) to the page that my item takes me to.
The problem is that the page i'm redirected to is not a node, but it is a render-able page that displays the data according to it's 'page_arguments'.
It is as follows:
$items['car/%'] = array( 'title' => 'Cars', 'page callback' => 'car_page', 'page arguments' => array(1), 'access callback' => TRUE, 'type' => MENU_CALLBACK, );
I want to attach the comment form (of the Comment Module) to that page.
I used the following code:
module_load_include('module', 'contact'); $build = array( 'header_text' => array( '#type' => 'markup', '#markup' => 'Building comments in page.', ), 'the_form' => drupal_get_form('comment_form', ''), ); return $build;
All is correct code.
But the problem is that the comment form and the posted comments are loaded depending on the node Id (nid), and in my case there is no node Id (nid)!
How could i assign a specific identifier of that custom page so that the comment form functions correctly and comments related to that page are correctly loaded?!
And in the code above, i managed to call the form using drupal_get_form(), and assigned an empty second argument! I don't think that's right, right?