Drupal Archive Tree Module

If you ever needed to create a blog fro your client running Drupal, you can’t help to wish certain aspects of WordPress would be part of Drupal. Undeniably one of those items is archive. Now granted WordPress has many widget extensions to make the archive look many different ways, the problem is, in Drupal there is no basic to base it on…

Archive Block

So recently i had a client who wanted to have an accordion archive tree for their website. they were using Drupal 7 and the previous developer after struggling with it for a while just gave up…


My first inclination was to just write it into the theme, but them mentioning that they plan to swap themes for different seasons, made this not sustainable solution. So i decided to create a custom PHP block, that way we could reuse it in any theme.

As you could see from the code we are using the ui.accordion from the  jQuery UI which since Drupal 7 release is being included in the core.

Then my curiosity coupled with the fact that i had few more similar projects lined up won me over. I wanted to see if i could make it into Drupal module.

And “surprise” i have created the module learning few things along the way and breaking some drupal rules along the way… So here is how i have done it:

Step 1: create .info file, here is mine: (archive_accordion.info)

Step 2: Now that info file is created lets create the module file:(archive_accordion.module)

If you will look at the last part of the code above, you will notice that there is a reference to views api. the reason is that i also built a view that goes with it. (This was the easiest part, as all i had todo is export the view to code.) So here is the 3rd file in the folder (archive_accordion.views_default.inc)

Hope you enjoyed this brief tutorial, if you have any questions or suggestions please feel free to leave a comment.

, , , , , , , , ,

Related Posts

3 Comments. Leave new

  • Thank You So much!! you are my saviour!

  • chitra sreenivas
    November 29, 2016 10:25 pm

    Hi, im getting some errors like these.
    Notice: Undefined variable: archive_tree in archive_accordion_block_view() (line 98 of C:wampnewwwwdrupalsitesallmodulesarchive_accordionarchive_accordion.module).
    Warning: Invalid argument supplied for foreach() in archive_accordion_block_view() (line 98 of C:wampnewwwwdrupalsitesallmodulesarchive_accordionarchive_accordion.module).
    Notice: Undefined variable: output in archive_accordion_block_view() (line 129 of C:wampnewwwwdrupalsitesallmodulesarchive_accordionarchive_accordion.module).

    Please tell me how to correct it?…im not good with programming.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.