6 replies [Last post]
paulgrimshaw's picture
Offline
Joined: 05/19/2008
Juice: 91
Was this information Helpful?

Hi,

I am finding the learning curve on theming ubercart pretty tough. I am theming the product page ok now, but I am having trouble with the catalog. At the top of each page you get:

<img class="category" width="133" height="100" title="Canon" alt="Canon" src="***/files/imagecache/uc_thumbnail/canon-logo.jpg"/>
All our Canon compatible printer cartridges are guaranteed to work - please check carefully that your specific printer is listed in the compatibility section of each item.

How do you theme this? There is no wrapping around it or specific css attached to the description. Any suggestions would be much appreciated. Can the rest of the page be themed (e.g. changing the order of fields etc) or is it only css that you can change (e.g. is there a ubercart-catalog.tpl or views?).

Thanks,
Paul.

paulgrimshaw's picture
Offline
Joined: 05/19/2008
Juice: 91
Hi, Anyone have any

Hi,

Anyone have any suggestions for this? Do I need to hack the ubercart modules to add a wrapper around this somehow? I looked through the module and couldn't find anything.

Thanks,
Paul.

paulgrimshaw's picture
Offline
Joined: 05/19/2008
Juice: 91
Fixed

For anyone who comes across this, I changed the uc_catalog.page.inc file, don't know if this should be done in something like template.php instead, but I will just remember to update it each time ubercart gets a new version. I think it would be very useful for lot of people if certain parts of the theming had a bit more css as default. Anyway, here is what I did, it works for me.

Find this:

if (!empty($catalog->image)) {
    if (module_exists('imagecache')) {
      $output .= theme('imagecache', 'uc_thumbnail', $catalog->image['filepath'], $catalog->name, $catalog->name, array('class' => 'category'));
    }
    else {
      $output .= theme('image', $catalog->image['filepath'], $catalog->name, $catalog->name, array('class' => 'category'));
    }
  }

and replace with:

  /* START CAT HEADER */
  $output .= '<div class="cat-desc">';
  if (!empty($catalog->image)) {
    $output .='<div class="img">';
    if (module_exists('imagecache')) {
      $output .= theme('imagecache', 'uc_thumbnail', $catalog->image['filepath'], $catalog->name, $catalog->name, array('class' => 'category'));
    }
    else {
      $output .= theme('image', $catalog->image['filepath'], $catalog->name, $catalog->name, array('class' => 'category'));
    }
    $output .='</div>';
  }
  $output .= '<h2>'.$catalog->name.'</h2><p>'.$catalog->description.'</p>';
  $output .= '</div>';
  /* END CAT HEADER */

You can see I now have a single CSS div for the whole description, a P wrap around the text, a div around the image and I added a h2 title, but that's optional obviously (not by default). I combined the two headers for my catalog subcat page and catalog product page so won't suit everyone if you have more clever theming.

Then simply remove this in two places later on.

$output .= $catalog->description;

You can see mine working as I need it here: http://89.200.137.245/shop/online/gadget-protection/laptop-sleeves

Thanks,
Paul.

justageek's picture
Offline
Bug Finder
Joined: 10/29/2008
Juice: 189
probably only option

Given what you wanted to add, then what you did was indeed probably the best option. The only thing to do differently is as you mentioned to copy the function itself into your template.php file rather then updating the core UC file. That way when you upgrade UC you don't have to do anything to keep your custom code intact. Simply copy the entire function into template.php and that should do it.

It probably would be a good idea to have some configuration options for adding other fields, but this works too.

paulgrimshaw's picture
Offline
Joined: 05/19/2008
Juice: 91
Thanks

Hi,

Just upgraded to v2 official and took the opportunity to move these out now. upgrade was seemless and working aok in the template. Make life easier later Smiling.

Thanks,
Paul.

Unarmed's picture
Offline
Joined: 08/07/2009
Juice: 141
Re: Thanks

This is almost exactly what i was looking for =] Just one thing, do u know how i would go about giving each item in the catalog a unique css id or class?

tigerfist's picture
Offline
Joined: 05/07/2010
Juice: 21
THANK YOU!

Awesome!

I was looking for this exact solution all day, and was almost about to give up. I added this code to my template.php and it works perfectly!!