3

i'm trying to create a module that adds a 'new' class to a row based on the date it was published.

So i thought of doing something like

if ($data > 10 days ago){
  $this_row addclass new
}

But whats the best way to do this? I would like to put this in a module so i can simply turn it on and off and avoid problems with template files from ds.

I can only find a way using hook_views_pre_render to add a class to all the rows, but nothing about adding it to one specific row. Maybe i need to use another hook?

1 Answer 1

1

Writing a view handler would be the perfect way to do this. The handler itself will be almost as simple as your example code.

However getting everything right to get the handler called from views isn't easy. A good example to learn from is the maillog module. It integrates its log table with views and adds a custom handler.

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.