samedi 22 mai 2010

[drupal][Views] Display a view Total Rows

Using the views module is always a cool and funny experience but when you have to display the number of rows/results and a counter for each row then you stop smiling :-/.

I finally found how to do it in a simple way :-) Here we go ...
(I assume you know how to ovewrite a theme file and to display a view using the Table styling)
1- Enable the pagination (without this you won't get the $view->total_rows value)
2- Copy and the file 'views-view-table.tpl.php' in your theme folder (themes/garland or sites/all/themes/my_theme for example)3- Rebuild the theme registry to enable your new table_theme file
4- Adding the total by displaying the $view->total_rows variable

TOTAL : total_rows ; ?>
and that's it !!

PS: As far as the line number counter all you need is to define a variable ($counter) that you increment in the foreach loop.

jeudi 20 mai 2010

[Drupal][Admin_menu] Missing argument system_clear_cache_submit

I was getting this warning message

warning: Missing argument 1 for system_clear_cache_submit(), called in My_website_path\sites\all\modules\admin_menu\admin_menu.inc on line 522 and defined in My_website_path\modules\system\system.admin.inc on line 1367.


since a while. I was feeling lazy to check the cause of it, all i have to do is to reload the home page of the drupal project.

Finally I fixed it by defining an empty array in the admin_menu.inc file:

$form_state = array();
$form_array = array();
system_clear_cache_submit($form_state, $form_array);