Catalog description

Contrib type: 
Code/CSS Snippet
Status: 
Complete and working

Downloads


Compatibility: 
Ubercart 1.x

I searched the site and did not see this anywhere else, so I am posting here in the event it might help someone.

Essentially, by adding some text in the UC catalog.module, you can provide to customers a description of your /store/catalog page above the Catalog display itself.

1. Open uc_catalog.module in a text editor.

2. Find line 501 or thereabouts (turn off line wrapping).

3. Look for the following bit of code:

<?php
 
else {
   
$tid = 0;
   
$name = variable_get('uc_catalog_name', t('Catalog'));
   
$description = '';
  }
?>

4. In between the two little quotation marks after the <$description => you can insert some text the describes what the customer sees and how to navigate the catalog to go to the desired product page. You can use basic html tags (table, strong, etc.) to format the text. Don't get too fancy, because only filtered html will show up, as far as I know.

5. This is a nice addition, in my opinion; otherwise the customer sees a page which says Catalog and a display of product categories without any introduction whatsoever. Enjoy!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Catalog description

It strikes me that this could be accomplished without hacking a core module (even if it's just a minor hack) by using a module to add help text to those pages. I made a custom one for a site a while back, but you may be able to use this module:

http://drupal.org/project/helptip

Then again... maybe not. Sticking out tongue

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6855
Re: Re: Catalog description

Because of this contribution, I've already gone and hacked core myself. In addition to changing the name of the Catalog, there is now a setting to change it's description. Thanks, bwv.

TutusForToddlers's picture
Offline
Joined: 11/17/2007
Juice: 158
Re: Re: Re: Catalog description

Where do I need to go in Alpha 8 to change the catalog description?

Thanks,
Claire
Tutus for Toddlers sells Tutus using UberCart for e-commerce with Drupal.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6855
Re: Re: Re: Re: Catalog description

Edit the Catalog vocabulary under Content management. It's the same place where you set the vocabulary's name and allowed node types.

kasperjames's picture
Offline
Joined: 11/17/2007
Juice: 52
thank you very much...

for including:

1. Open uc_catalog.module in a text editor.

2. Find line 501 or thereabouts (turn off line wrapping).

3. Look for the following bit of code:

why? becuase all over drupal and ubercart it doesnt explain how to do such functions.

i think this is what ive been trying to figure out: re: how to edit the script/php code ect..

however...

when saving the settings, after editing...what are the donts?
do i just hit save? or do i have to use a particular editor with certain file name extentions? ie:

".module"

obviously its not ".txt", sorry if this is small compaired to other questions, but im off on the right foot i think.

thanks,

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: thank you very much...

If I understand you right, the main reason Drupal/Ubercart don't tell people where to find and modify pieces of code is because we don't want it to happen. Smiling When code is modified, that instantly breaks any sort of update process... at the very best requiring you to remember any custom changes you've made and duplicate them with each update. With Ubercart as young as it is, that's going to get old fast.

It's best to come up with a solution that either involves using a settings form or making a custom module that hooks into the code at appropriate places to change things.

The short answer to your question is just save it as a text file and keep the extension intact and you'll be alright. Eye-wink

kasperjames's picture
Offline
Joined: 11/17/2007
Juice: 52
note pad?

so...note pad is ok? nvu? editplus? are these ok to edit in?
save via? .txt

is this something to point to a skilled individual to troble shoot?
ive been saving a hook log. but thats for what? when i upgrade?

ok so....if its not best to take this sort of action, then what?
dont save a hook log....just, what? take another form of action to insure that upgrades/updates are performed in a more efficient action?

got a doc for me to read on this?

kasperjames

THANK VERY MUCH! I APPRECIATE IT!

venkat-rk@drupal.org's picture
Offline
Joined: 03/19/2008
Juice: 205
Re: Catalog description

Since the ubercart catalog is basically a drupal taxonomy vocabulary, an easier way to add the description may be the taxonomy_intro module which lets you add and display a description for each term in the vocabulary.

wporrasq's picture
Offline
Joined: 06/14/2010
Juice: 11
Catalog with category description

Catalog with category description

Hi,
I have a solution that I found quite effective,

must add this code in the function function THEME_uc_catalog_browse in file
uc_catalog/uc_catalog.pages.inc

Change "Theme" by the name of the theme you are using.

All this function must be copied into the template.php of the item being used.

Replace this code:
$ Cell_link = $ image..'' l ($ child-> name, uc_catalog_path ($ child)).'';
if (variable_get ('uc_catalog_show_subcategories', TRUE)) (
$ Cell_link .= "." implode ('', $ grandchildren). "\ n";
)
$ Child_list [] = $ cell_link;

WITH This another code

/ / This code displays each category name and details with image
$ Cell_link = $ image..'' l ($ child-> name, uc_catalog_path ($ child)). '-'. l ($ child-> description, uc_catalog_path ($ child)).'';
if (variable_get ('uc_catalog_show_subcategories', TRUE)) (
$ Cell_link .= "." implode ('', $ grandchildren). "\ n";
)
$ Child_list [] = $ cell_link;

You can see the result in www.enersyscr.com / catalog

ALL CODE

function THEME_uc_catalog_browse($tid = 0) {
drupal_add_css(drupal_get_path('module', 'uc_catalog') .'/uc_catalog.css');

$output = '';
$catalog = uc_catalog_get_page((int)$tid);

//nombre de cada pagina
drupal_set_title(check_plain($catalog->name));
drupal_set_breadcrumb(uc_catalog_set_breadcrumb($catalog->tid));
$types = uc_product_types();
$links = array();
$child_list = array();
foreach ($catalog->children as $child) {
if (!empty($child->nodes)) {
$links[] = array('title' => $child->name . (variable_get('uc_catalog_breadcrumb_nodecount', FALSE) ? ' ('. $child->nodes .')' : ''), 'href' => uc_catalog_path($child),
'attributes' => array('rel' => 'tag'),
);
}

//Creo que es la imagen p
if (!empty($child->image)) {
$image = '';
if (module_exists('imagecache')) {
$image .= l(theme('imagecache', 'uc_category', $child->image['filepath']), uc_catalog_path($child), array('html' => TRUE));
}
else {
$image .= l(theme('image', $child->image['filepath']), uc_catalog_path($child), array('html' => TRUE));
}
$image .= '';
}
else {
$image = '';
}
$grandchildren = array();
$j = 0;
$max_gc_display = 3;
foreach ($child->children as $i => $grandchild) {
if ($j > $max_gc_display) {
break;
}
$g_child_nodes = 0;
foreach ($types as $type) {
$g_child_nodes += taxonomy_term_count_nodes($grandchild->tid, $type);
}
if ($g_child_nodes) {
//$grandchildren[$i] = l($grandchild->name, uc_catalog_path($grandchild), array('class' => 'subcategory'));
$grandchildren[$i] = l($grandchild->name, uc_catalog_path($grandchild), array('class' => 'subcategory'));
$j++;
}
}
//$grandchildren = array_slice($grandchildren, 0, intval(count($grandchildren) / 2) + 1, TRUE);
if ($j > $max_gc_display) {
array_push($grandchildren, l(t('Ver mas...'), uc_catalog_path($child), array('class' => 'subcategory')));
}
if ($child->nodes) {

//Este codigo despliega cada categoria con imagen nombre y detalle
$cell_link = $image .''. l($child->name, uc_catalog_path($child)) . ' - ' . l($child->description, uc_catalog_path($child)) .'';
if (variable_get('uc_catalog_show_subcategories', TRUE)) {
$cell_link .= "". implode(', ', $grandchildren) ."\n";
}
$child_list[] = $cell_link;

}
}
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'));
}
}

// Build an ORDER BY clause for the SELECT query based on table sort info.
if (empty($_REQUEST['order'])) {
$order = 'ORDER BY p.ordering, n.title, n.nid';
}
else {
$order = tapirsort_sql(uc_product_table_header());
}

$sql = "SELECT DISTINCT(n.nid), n.sticky, n.title, n.created, p.model, p.sell_price, p.ordering
FROM {node} n
INNER JOIN {term_node} tn ON n.vid = tn.vid
INNER JOIN {uc_products} AS p ON n.vid = p.vid
WHERE tn.tid = %d AND n.status = 1
AND n.type IN (". db_placeholders($types, 'varchar') .") ". $order;

$sql_count = "SELECT COUNT(DISTINCT(n.nid))
FROM {node} n
INNER JOIN {term_node} tn ON n.vid = tn.vid
INNER JOIN {uc_products} AS p ON n.vid = p.vid
WHERE tn.tid = %d
AND n.status = 1
AND n.type IN (". db_placeholders($types, 'varchar') .")";

$sql = db_rewrite_sql($sql);
$sql_count = db_rewrite_sql($sql_count);
$sql_args = array($catalog->tid);
foreach ($types as $type) {
$sql_args[] = $type;
}

$catalog->products = array();
$result = pager_query($sql, variable_get('uc_product_nodes_per_page', 12), 0, $sql_count, $sql_args);
while ($node = db_fetch_object($result)) {
$catalog->products[] = $node->nid;
}
if (count($catalog->products)) {
if (count($links)) {
$output .= theme('links', $links, array('class' => 'links inline uc-categories')) ."\n";
}
$output .= $catalog->description;
$output .= theme('uc_catalog_products', $catalog->products);
$output .= theme('pager');
}
else {
// Display table of child categories similar to an osCommerce site's front page.
$columns = variable_get('uc_catalog_category_columns', 3);
$cat_rows = array();
$row = array();
$i = 1;
foreach ($child_list as $cell) {
$row[] = array('data' => $cell, 'class' => 'category');
if ($i % $columns == 0) {
$cat_rows[] = $row;
$row = array();
}
$i++;
}
if (count($row) > 0 && count($row) < $columns) {
if (count($cat_rows) >= 1) {
$row = array_merge($row, array_fill(count($row), $columns - count($row), array('data' => ' ', 'class' => 'category')));
}
$cat_rows[] = $row;
}

$output .= $catalog->description;
$output .= theme('table', array(), $cat_rows, array('class' => 'category'));
}

return $output;
}