0

mymodule.module

function mymodule_theme() {
return array(
    'mymodule_results' => array(
        'variables' => array('var1' => null, 'continent' => null, 'country' => null, 'location' => null, 'query' => null, 'total' => null,'comments'=>null),
        'template' => 'templates/mymodule_results'
    ),
    }

mymodule.pages.inc

function mymodule_details($beaches = null) {
 drupal_set_title('Beaches Details');
 if (!isset($beaches->comment_count))
    $beaches->comment_count = 0;
return array(
    '#theme' => 'mymodule_results',
    '#beaches' => $beaches,
    '#attached' => array(
        'library' => array(
            array('iks_libraries', 'jquery.tinycarousel'),
        ),
    ),
);
}

mymodule_results.tpl.php

<?php if ($comments): ?>
<?= render($comments) ?>

I need to include the comment form in the template page, But i have not created a content/node type for this. I'm displaying the results in the template page.

1 Answer 1

0

Comments needs to be attached to a content. If you want to use built-in comments module, you need to:

  • Use "simple page" content type to create dummy nodes, or create similar one
    • it might be wise to strip your dummy content type from everything except title and comments
    • revoke edit and delete rights, no one should be able to do it
  • In your module's install file, make sure this content type is enabled and create a dummy node for each of pages you need comments on
  • Set node's paths to match paths of the pages, so people cannot access them directly
  • Setup Global Redirect or similar to always redirect from /node/$nid to path
  • In your module load node and pass it to theme so you could render comments in tpl.php file

That would be about it, if you need more details on any of these points, I guess it'll be worth a separate question.

1
  • thank you molot, but i need more info regarding this issue. open it as a seperate question
    – Ajmal
    Commented Jul 31, 2013 at 7:33

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.