Hi
I'm trying to add an handler to a module specific view.
The new (customized) handler is : views_handler_argument_category_depth
Here's the content of the sites\all\modules\views\modules\category.views.inc
function category_views_data() {
$data = array();
...
$data['category_node']['cid'] = array(
'title' => t('ID'),
'help' => 'The category ID.',
'argument' => array(
'handler' => 'views_handler_argument_category_depth',
),
);
...
function category_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'views') . '/modules/category',
),
'handlers' => array(
'views_handler_argument_category_depth' => array(
'parent' => 'views_handler_argument',
),
),
);
}
for now the views_handler_argument_category_depth is just a std handler renamed with a slight change in order to just attach the argument to the new handler.
The argument is recognized, in the views UI I can add it but then I have the following error :
Error: handler for category_node > cid doesn't exist!
I tried also to add it to the handlers directory in the views module, without sucsess.
I emptying the cache after every change, also restarted the apache server.
Can anybody help ?
Thanks
Nissim
Comments
Comment #1
dawehnerCool, someone with a real question. It does motivate much more to answer API questions :)
Do you have views_handler_argument_category_depth.inc in your module? There you also have to define this class, and extend views_handler_argument.
Comment #2
merlinofchaos commentedAs a start, that error indicates that, for whatever reason, the handler was not instantiated.
'path' => drupal_get_path('module', 'views') . '/modules/category',That looks like a problem, since I don't think your module is the Views module. Marking this fixed since I bet this is the problem.
Comment #3
nissiml commentedHi , thanks for replying.
I did have such a file, in views/modules/category
and it indeed extends from the correct parent.
Comment #4
merlinofchaos commentedUh. You're not supposed to put your handlers in the views module. Are you actually editing views module code? If so, you really need to go back and read Drupal's best practices.
Comment #5
nissiml commentedI'm not changing the view core module code, just enhancing the view functionality of the category module which is very basic.
I don't care about the location of the file that holds the view hooks implementation.
Actually, I tried also to put the code in the category module itself without success.
Btw, views/modules contains such extensions for many modules.
Can you state the required and precise steps to add an handler ?
Comment #6
merlinofchaos commentedIf you put *any* file in the 'views' directory, that is editing the module. Yes, Views ships with a bunch of stuff on behalf of core modules. I don't understand why you think it's okay to put your files there. It's an upgrade nightmare.
Comment #7
nissiml commentedI'm not changing the view core module code, just enhancing the view functionality of the category module which is very basic.
I don't care about the location of the file that holds the view hooks implementation.
Actually, I tried also to put the code in the category module itself without success.
Btw, views/modules contains such extensions for many modules.
Can you state the required and precise steps to add an handler ?
Comment #8
nissiml commentedOk, thanks I solved the issue.
I have now a handler for category views that includes depth (based on taxonomy depth handler)
and it works !!
Comment #9
dawehnerNevertheless whether it works or not, its just not nice, if the handler is still in the views directory.
Comment #10
nissiml commentedDo not worry, It's in the category module now, not in the views module code.