Here are Some Product Theming Tips/ Snippets....

Posts: 30
Joined: 03/25/2008

So Far:
1. Using TABS
2. Displaying Taxonomy by Vocab
3. Theming Listed Taxonomy Tagged Nodes
4. Coming soon.... Taxonomy menus.

I wanted to drop some of my thoughts and some tips that I ended up using the last week while themeing my product page.

First off, if you don't already know. To get started. Duplicate your node.tpl.php file and call it node-product.tpl.php.

(For more information on these things... http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p.... )

On to the interesting bits....

USING TABS

Tabs = Cool... but hard to get going on 5.10 with Jquery 2. (Or at least without a little guide anyways)

STEP 1. Install Jquery Update:
http://drupal.org/project/jquery_update

STEP 2. Install JsTools (Jstools contains the tabs function).
http://drupal.org/project/jstools

STEP 3. Apply Jstools patch (the last one) if you are using the newest version of jquery (such a pain).
http://drupal.org/node/171234

STEP 4. head over to the admin module page and active jquery, tabs and jstools. Follow the jquery instructions of copying files to your root/misc folder. (I think most people have already updated jquery in the past?).

STEP 5. Decide what the heck you want to put into your tabs. In my case. I wanted some CCK field and my comments. Using tabs is not dependent on CCK, but it does make it a whole lot more useful.

STEP 6. Drop the following code into your node-product.tpl.php you created where you want the tabs to appear.

(I cant say I actually understand php or this snippet 100%, but ill do my best to break it down on how to use it.)

<div id="tabs-1" class="drupal-tabs">

   <ul class="anchors">
<li><a href="#tabs-1-1">About</a></li>
<li><a href="#tabs-1-2">Preview</a></li>
  </ul>


<div id="tabs-1-1" class="fragment">
<h2 class="drupal-tabs-title" >Body</h2>
             <?php print $node->content['body']['#value'] ?>
  </div>
<div id="tabs-1-2" class="fragment">
<h2 class="drupal-tabs-title" >Preview</h2>
              <?php echo $node->field_preview[0]['view'];?>
 
  </div>
</div>

Ok. This makes 2 tabs. tabs-1-1 and tabs-1-2. If you want more tabs, just copy and paste and keep naming the same way. ie tabs-1-3. You will also notice that you need to change the name in two places. Once in the href (starts with #), and once in the class.

This is the output of the first tab. Meaning this is what is inside the tab when you click on it.

<?php print $node->content['body']['#value'] ?>

This one prints out the whole body of the node (everything that you put into the body on product). If you don't want a whole body, but some of your cck, use the following:

<?php echo $node->field_preview[0]['view'];?>

Where it says field_preview, replace it with the name of your cck. You can find this by going administer >> content types >> choose edit for the type you want (probably products in this case) >> manage fields.

You will see most of the new cck fields you added, will start with field_XXXXX under the column "Name". Take the field name you want and replace my field_preview.

Be forewarned. Some CCK types are printed differently, such as address or date. Search the CCK handbook on drupal.org to learn more about printing CCK field types. Maybe try this first with just text fields or links.

That should do it. Test it out and see how it goes.

For extra points.....

Use the following snippet to put your comments into a tab. This was not easy to figure out/ find (I didn't write this snippet). If not your comments will end up at the very bottom of the page like normal.

<?php if ($links): ?>
    <div class="links">&raquo; <?php print $links; ?></div>
  <?php endif; ?>
<?php
if (function_exists('comment_render') && $node->comment) {
   print
comment_render($node, $node->cid);
  
$node->comment = NULL;
}
?>

I hope this made sense. Ill post my next tip soon!

Posts: 141
Joined: 08/07/2007

Thank you so much! This is exactly what i needed Smiling

Posts: 208
Joined: 12/28/2007
Uber DonorBug Finder

Yes, thank you very much for taking the time to post this kind of detailed and valuable information, highly appreciated! ...for sure this would be nice to found in contributions as well.

Great stuff!

Posts: 30
Joined: 03/25/2008

Im glad you found it usefull. So many people on drupal and here at ubercart have been great at answering questions. I felt like I needed to start posting some help for other people where I could.

So... #2.

-- TAXONOMY DISPLAY ON YOUR PRODUCT PAGE --

The back story

My site is not currently up, so I cannot point to an example. However, I wanted more than one taxonomy vocab for each product. So far, no problem. Just heard over to the taxonomy module, make some new vocabs, add some terms, associate with the node type product. Great.

For example. I am selling online courses.

I want a vocab of Authors (Tom, Dick, Harry), Type of Course (Online, Distance Education, Live) and Catalog (Courses about Internal Medicine, Surgery and Orthopedics).

The Problem

All the terms are mashed together on my product page. I want it to look like this:

Author: Tom
Type of Course: Online
Catalog: Surgery.

Not like this:

Tom, Online, Surgery.

Plus, I wanted authors at the top of the page, and catalog at the bottom.

This way, when people are surfing my products, if they find a course by Tom, they can just click his name, and it shows all the courses tagged as Tom. This is a great way to group products by Brand, Colors, Sizes, Mens and Women, etc etc. You get the idea.

The Solution

Listing each Vocab by its VID. (Vocabulary ID Number).

STEP 1.

Head over to YOURSITE/admin/content/taxonomy and click the link edit vocabulary . Now check your http: location. Should be something like admin/content/taxonomy/edit/vocabulary/5

Take that very last number. That is your VID.

STEP 2.

Post the following code into your node-product.tpl.php

  <?php
$terms
= taxonomy_node_get_terms_by_vocabulary($node->nid, 7);
foreach (
$terms as $term) {
 
$tagsOne[] = l($term->name, taxonomy_term_path($term));
    }
print
t("Author") . ": " . implode(' | ', $tagsOne);
?>

STEP 3.

Where it says ($node->nid, 7); add your own VID instead of the 7.

STEP 4.

Change the word "Author" to be whatever you want your Vocab to be name on your product pages. It will look like "Author: YOUR TERMS HERE". Try it out and see. You can write anything really.

Step 5.

If you want more than one Vocab, copy and paste the code again and you must change the words "TagsOne" to be "TagsTwo", "TagsThree", and so on. (OK, you dont need to number them that exact way, but I do suggest you do. Keep track of things folks).

Notice "TagsOne" is written twice. Don't forget to change both instances or it won't work.

For example:

<?php
$terms
= taxonomy_node_get_terms_by_vocabulary($node->nid, 5);
foreach (
$terms as $term) {
 
$tagsTwo[] = l($term->name, taxonomy_term_path($term));
    }
print
t("Approved") . ": " . implode(' | ', $tagsTwo);
?>

<br />

  <?php
$terms
= taxonomy_node_get_terms_by_vocabulary($node->nid, 6);
foreach (
$terms as $term) {
 
$tagsThree[] = l($term->name, taxonomy_term_path($term));
    }
print
t("Pending") . ": " . implode(' | ', $tagsThree);
?>
 

Final Notes

In my experience, this will not work with any special CCK - Taxonomy modules. Why.. no clue. Just doesnt output properly. PS, those modules destroyed my catalog page and terms. Use them with caution for sure. I couldnt fix it afterwards either. Live and Learn

Thats it...

Posts: 30
Joined: 03/25/2008

Short one this time. Works great with the suggestion above.

I dont even know what this list is called: Theming Listed Taxonomy Tagged Nodes... er list? Let me know someone!

Problem

When I click on a term on any page (esp my products), I get a list of teasers tagged with that term. Ie, I click the term "Tom", I get all the Tom pages listed by its teasers. Lame! Especially for a store site.

I want a nice table view. (or even a grid view).

Solution

Use the Views Module. I only just learned this one. And im glad I did.

Step 1.

Install the view module.

Step 2.

Go to admin/build/views

Step 3.

Look for the view called "taxonomy_term". This one is pre installed with the module. Just choose add/enable. From now on, all the terms lists will be themed by this View. (SWEET). Note: This will not mess up your catalog... well, it didnt for me anyways.

Step 4.

Edit the view as you please. Try the table view if you please. I like to list my terms, image, price, product name on my view. And then make it sortable by price.

Final Note

Get the views bonus pack module for even more views!

Next mini guide. Adding onto the last two mini guides, make a mini menu in a block called "shop by". Ie, shop by brand > shows all the brands > click nike, and it shows all the Nike Products in a view (like above). All in a cool little menu!

Posts: 143
Joined: 04/05/2008
Bug Finder

mach5_kel wrote:

Problem
When I click on a term on any page (esp my products), I get a list of teasers tagged with that term. Ie, I click the term "Tom", I get all the Tom pages listed by its teasers. Lame! Especially for a store site.

I want a nice table view. (or even a grid view).

Solution
Use the Views Module. I only just learned this one. And im glad I did.

Step 1.
Install the view module.

Step 2.
Go to admin/build/views

Step 3.
Look for the view called "taxonomy_term". This one is pre installed with the module. Just choose add/enable. From now on, all the terms lists will be themed by this View. (SWEET). Note: This will not mess up your catalog... well, it didnt for me anyways.

Step 4.
Edit the view as you please. Try the table view if you please. I like to list my terms, image, price, product name on my view. And then make it sortable by price.

Good suggestion!
The default "Teaser List" view type usually sucks. I think "Table View" with the fields we want is so much better.

Now i would be interested on how to theme/customize the output. Make the table or list view more purty.

Posts: 143
Joined: 04/05/2008
Bug Finder

mach5_kel wrote:

Final Notes

In my experience, this will not work with any special CCK - Taxonomy modules. Why.. no clue. Just doesnt output properly. PS, those modules destroyed my catalog page and terms. Use them with caution for sure. I couldnt fix it afterwards either. Live and Learn

Thats it...

Why would this make permanent damages
You're just changing the output on a template page, right?
Is there a workaround?

Because this is definitely a good idea and i'm sure many people could use it.

Posts: 30
Joined: 03/25/2008

The cck - taxonomy modules make changes to your database, which can be permanent if you don't know how to fix it. They don't uninstall very clean. These modules work just fine normally, but the don't work in my experience WITH the catalog module of Ubercart.

Try the module "backup and migrate" first to make a backup of your site before you install them. Then you can restore you site if things dont work out ok.