1

I am new to drupal, I wished to view the contents using custom modules. For that, I have created custom content type and added some contents. Now I want to create a module to display all the contents that are created by those content types, in a page. Contents should have title, image, description, date field. How can I do that.?

1

You can use Views to list content of custom content type.

Update(Programmatically load nodes):

<?php
$type = "custom_content_type";
$nodes = node_load_multiple(array(), array('type' => $type));
foreach($nodes as $node):
?>
<?php print $node->nid; ?>
<?php print $node->title; ?>
<?php endforeach; ?>

Ref: https://api.drupal.org/api/drupal/modules!node!node.module/function/node_load_multiple/7

  • I have already tried that and got succeeded. But, now I wished to bring all those contents using my custom module. So, how can I do.? – karthik Mar 4 '15 at 10:21
  • You can use node_load_multiple function to list all nodes of custom content type. See updated answer – Vishal Patil Mar 4 '15 at 10:24
  • @karthik you won't find someone to write your code for you here, it's too broad of a request and would only be useful to you, not future visitors. have a look at the module developers guide on Drupal.org and ask a specific question when you get stuck – Clive Mar 4 '15 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.