Make Product Teaser viewable in grid under images

Contrib type: 
Code/CSS Snippet
Status: 
Initial upload

Downloads


Compatibility: 
Ubercart 1.x

Hello,

I've seen a few posts in which people have requested that a teaser be made viewable in the catalog. While I'm pretty new to the Drupal/Ubercart community, AFAIK there's no way to do this with any version of Ubercart and I haven't seen anybody post any code, so I thought I post what I worked out to make teasers viewable in grid mode. It was amazingly simple! When using this code I put in tags in product descriptions to make it look how I wanted. You could likely make some similar easy changes to the code if you want the whole description to be visible.

To make teasers visible:

Around line 630 of uc_catalog/uc_catalog.module add:

variable_get('uc_catalog_grid_display_teaser', true) ?
t('Every cell on the grid will display Teasers.') :
t('Cells on the grid will not display Teasers.'),

~line 1149:
if (variable_get('uc_catalog_grid_display_teaser', TRUE)) {
$product_table .= ''. node_teaser($product->body) .'';
}

~line 1321:
$form['catalog-grid']['uc_catalog_grid_display_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Display product teaser'),
'#default_value' => variable_get('uc_catalog_grid_display_teaser', true),
);

Now you'll have to go into the grid view configuration menu and enable it.

Any reason why this feature isn't available?

acdtrp's picture
Offline
Joined: 03/16/2008
Juice: 60
I wonder the same thing

It would be much easier if we had the option to add more columns to the uc_product_table for example or in the grid display, especially the teaser (even from the excerpt module).

by the way i wanted to try this solution but it would be better to explain where to insert the snippets, in which function etc. not only about line xxx because this is really confusing.

slip's picture
Offline
Joined: 07/01/2008
Juice: 31
More information on where to put the code

acdtrp: hope this helps.

I've posted my edited version of uc_catalog/uc_catalog.module

Also. here's a better description of what to change:

1) in function uc_catalog_settings_overview()
add:

variable_get('uc_catalog_grid_display_teaser', true) ?
t('Every cell on the grid will display Teasers.') :
t('Cells on the grid will not display Teasers.'),

to the $sections[] with title 'Products grid settings'

2) in function theme_uc_catalog_product_grid($products)
add:
if (variable_get('uc_catalog_grid_display_teaser', TRUE)) {
$product_table .= ''. node_teaser($product->body) .'';
}
after the if statement: if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) { ... }

3) in function uc_catalog_grid_admin_form()
add:
$form['catalog-grid']['uc_catalog_grid_display_teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Display product teaser'),
'#default_value' => variable_get('uc_catalog_grid_display_teaser', true),
);
after $form['catalog-grid']['uc_catalog_grid_display_title'] is set.

AttachmentSize
uc_catalog.module.txt 62.77 KB
viktormas's picture
Offline
Joined: 12/20/2008
Juice: 8
Re: More information on where to put the code

Thank you so much for your kindness.

Although I am not a programmer, following your description made it easy to place the code and get the teaser in the grid view.

This little code is a true valuable contribution and should be included in the official uc_catalog (with a teaser on/off tick I guess?).

Thanks again.

Viktor

slip's picture
Offline
Joined: 07/01/2008
Juice: 31
updated for ubercart 2.0 beta5

Another client needed this so here's a patch for newer Ubercarts (2.0 beta 5 specifically). Let me know if there are any issues.

AttachmentSize
uc-5395-4-display_teasers.patch 1.64 KB
AkkuDreamz's picture
Offline
Joined: 04/13/2009
Juice: 7
Thanks a lot, that helps

Thanks, this really helped me alot, i spent some time looking for a feature like that in the settings.
I wonder why this small code edit isnt provided in the UC release itself.

Chad_Dupuis@drupal.org's picture
Offline
Joined: 08/28/2007
Juice: 56
Updated for latest 5.x branch

Hello,

Thanks for figuring this out. I've updated this patch for the latest 5.x branch (at this point 5.x-1.6).

Chad J. Dupuis
Yin Yang House Media Services Group

AttachmentSize
catalog-grid-teaser-d5x.patch 1.27 KB
bballard's picture
Offline
Joined: 07/17/2009
Juice: 2
Ubercart 2.0 beta5 patch

Slip, thanks a bunch for that patch. I also had to add the new line for the .module file to the template.php file for the theme, but it works great. I'm just wondering if it's possible to actually have that field teasered or if some maximum character limit can be set. We have fairly large descriptions, but if we can set a character limit on the catalog page, there'd be no need to cut the description down. Any help would be much appreciated. Thanks once again for the patch.

slip's picture
Offline
Joined: 07/01/2008
Juice: 31
Re: Ubercart 2.0 beta5 patch

bballard, sorry about the delayed response, I don't get notified on replies to this post....

I'm not sure I understand what you mean. The patch I submitted allows the teaser to be displayed. If you have a long description, you can manually add a tag in the place you'd like it to break. Also, you can set Drupal's teaser length setting to the desired character limit.

You could set a specific length for the product content type with this module http://drupal.org/project/teaserbytype

Otherwise you'd have to use some php to do it. http://drupal.org/node/46391 might help...

slip's picture
Offline
Joined: 07/01/2008
Juice: 31
Same result by overriding ubercart's theme function

I wrote a brief blog post on how to do a similar thing by overriding ubercart's theme function after somebody in IRC wanted this functionality. I'd still like for my patch to make it into core. However, for now it's a cleaner solution for a developer to override the function so he or she won't have to reapply the patch each time ubercart is upgraded.

http://www.left-click.us/node/9707

ubcrt's picture
Offline
Joined: 12/21/2009
Juice: 22
Thanks for this one! I'm

Thanks for this one!

I'm looking for the same possiblities. But unstead of the description teaser, i'm trying to put a CCK field in to the product grid. Do you know this is possible with editting template.php? If so, can you help me with what code I need to insert. The name of the field I want to add is: cck_brand.

Thanks in advance

slip's picture
Offline
Joined: 07/01/2008
Juice: 31
Re: Thanks for this one! I'm

In my code on my blog $product is a fully loaded node so you can dump that to see what's available and use content_format to display it correctly.

You can also get similar results with Views.