0

I'm creating a Drupal module and I would like to know how to build the admin panel table with the list of each items that I've been created with the module.

What is the hook to use ? and/or the API function... ? I did not found it.

All the tutorials that I read on the web explain how to create a form for submitting content but no one explain how to create the list of the content that have been submitted with the form.

You can see in the joined picture two examples of that I want to do.

create drupal admin items list

1 Answer 1

3

I think you have at least two possibilities to proceed.

First, you can use "Views" module to display a list of whatever you want (you can easily configure it to display all contents of a certain content-type that the user currently seeing the page created, etc, etc). You can inspire yourselft with this article about creating an administration page with Views 2 (http://zugec.com/2010/08/create-administration-pages-views-2). It is not very different.

If you want to do it programmatically, you can always create a "page" that displays whatever you want using hook_menu(). Just set the path under "admin/" and permissions the way you want. Use the page callback function to make the appropriate query (select the nodes you want, created by the current user, order them, sort them, etc...) and to display the results.

If you want more explanations about one of the two solutions provided up there, just ask and I'll develop deeper :-)

8
  • Hello Djouuuuh, Thank you for the answer. I don't wanna use Views module, I just wanna build my own module admin page. I already use "hook_menu()" for the form of the module. I hoped that there's a function that build the table of entries, a function that can do this without having to rewrite all the code, such as "drupal_admin_form" function to build a form, but maybe I'm wrong...
    – MOWebCreation
    Sep 11, 2014 at 7:11
  • No I think there is no such thing and that you have to make that list and form manually. If you don't want to use Views, well good luck with your code :-) else, you can try with Views and Views Bulk Operations modules.
    – Djouuuuh
    Sep 11, 2014 at 8:10
  • I found the solution for build my table, I use "theme_table()" function. Now I've a problem with my edit link. For each item I make a link to an edit form. I would like to know how can i pass variables to my "items/edit" page, I try "items/edit/?var=value", but It doesn't work... How can I do this ??
    – MOWebCreation
    Sep 11, 2014 at 10:00
  • Here is how you can pass parameters with the l() function: l('Edit link', 'node/123/edit', array('query' => array('param' => 'value')));
    – Djouuuuh
    Sep 11, 2014 at 10:08
  • That's working good ! Thank you... I've another little problem, I would like to add a class to a link, so I do this : l('Informations & Documentation', 'admin/config/tamtamimporter/infos-doc', array('class' => array('module-link-help'))) , but It doesn't work
    – MOWebCreation
    Sep 11, 2014 at 12:40