I would like to do a bit more theming than is possible right now with the template file, because its pretty hard to overwrite the table content. So I would need a drupal_alter before passing the theme variables to the template.
And to get even more freedom for themers who like to work directly in template-files I would suggest to also provide the table render array in the template to make it possible to create the table in the template if needed.
I'm going to attach a patch.
Thanks for the great module!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | implement_drupal_alter-2365599-2.patch | 2.05 KB | nebel54 |
| #1 | implement_drupal_alter-2365599-1.patch | 2.06 KB | nebel54 |
Comments
Comment #1
nebel54Comment #2
nebel54I introduced too many empty lines in my patch… just removed them.
Comment #3
subhojit777Theme templates are used for cart block so that developers can alter it using theme preprocess functions. Usage of drupal_alter() is not required here as we already have theme preprocess functions to do so.
I agree on using a template variable that show product list information in array. There is also another issue #2363335: Please print product price total per each line item? that need this.
According to your patch, header and rows can be altered as they have known keys, but there is no clean way to alter product prices, name, quantity in
$row.Solution/Suggestion:
Create a template variable (associative array would be best) that stores product prices, quantity, name, etc. The array will be used to render block. The block HTML will be stored in
$variables['products_list_html']as before.Comment #4
discipolo commentedIt should be possible to show the product / line item rendered in a display mode imho.
But still get the remove button
Comment #5
nebel54@subhojit777: You are right preprocess functions should be sufficient. So we just need to add associative keys to the array and pass the array to the template. I will provide a new patch.
Comment #6
nebel54@discipolo leveraging view-modes would be great. I did replace the line-item title in a preprocess function with a rendered representation of it. It would be nice if there was an UI to select a view-mode for products in the cart. We should discuss this in a follow-up…
Comment #7
subhojit777Comment #9
subhojit777@Nebel54 I have updated the code and have added render array. Now the the cart will be fully rendered using the template file, earlier the table was rendered in the preprocess function, which is not a good approach. Now the template file will handle the rendering process. The preprocess function only adds additional values for rendering. @Nebel54 could you please the latest dev version of the code.
The teaser block and add to cart message templates are alright, therefore I am marking this issue as "Fixed". Please feel free to re-open if you face any problem.
Although this is a major change in module, but I am not releasing it in 2.x branch because it is just a change in rendering process, there is no major change in the implementation of the module.
@discipolo Please create a new issue for the view mode, we will discuss it over there.
@Nebel54++ thanks for raising this issue :)