I am trying to create a custom module to manage a slider.

After install my current-development module, I have:

  • a slider content-type
  • a slider view defined to show Content (Full Content) of the content-type slider with Unformatted list format
  • a node--slider template that renders the slider node as a li element

EDIT: Code updated You can check the module code here: https://github.com/jmvelasco/drupal

I wonder how could I add a wrapper that contains all nodes of this content-type and call to render each node using the template defined.

The idea I have in mind is define a block like:

<div id="wrapper" class="slider">

So the end rendering will be somethink like:

<div id="wrapper" class="slider">
        <li> slider content 1 </li>
        <li> slider content 2 </li>
        <li> slider content N </li>

But I don't know how to manage this even if I am pretty sure this is completely possible to achieve.

The accepted answer points to the right direction, from the current state of development, now I'd like to know if I can improve the slider_block_view

https://github.com/jmvelasco/drupal/blob/master/slider.module (line 101-124)

using a templete file defined in the module instead code the html inside a function module. I want also to attach a css and js files when rendering this view.

I'll appreciate any kind of help here.

Thanks for the reading.

1 Answer 1


If you want to just use the views module. Set your view to use fields. Filter by content type and set your display to using HTML List style. Pickout the fields you want to display (Image, Title). You can then add your custom javascript through a module or your theme so that it actually runs as a slideshow.

There are other modules that can handle this as well like views_slideshow and owlcarousel.

If you want to keep the code all in your own module, you may want to take a look at this article:


It shows you how to create your block, how to query the database, how to use the theme('item_list', $theme_args). It should be straightforward.


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.