Community Forums

RC6 Category.php

Enter all OpenCart 0.x bugs here

RC6 Category.php

Postby bthirsk » Thu Jan 08, 2009 3:27 am

In version RC6
catalog/controller/ catagory.php

Code: Select all
             foreach ($results as $result) {
                   $category_data[] = array(
                     'name'        => $result['name'],
                     'href'        => $url->href('category', FALSE, array('path' => ($request->gethtml('path')) ? $request->gethtml('path') . '_' . $result['category_id'] : $result['category_id'])),
                        'thumb'       => (isset($result['filename']) && file_exists(DIR_IMAGE . $result['filename'])) ? $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')) : NULL
                   );
              }


Missing description assignment,  Should be

Code: Select all
          foreach ($results as $result) {
                   $category_data[] = array(
                     'name'  => $result['name'],
                     'href'  => $url->href('category', FALSE, array('path' => ($request->gethtml('path')) ? $request->gethtml('path') . '_' . $result['category_id'] : $result['category_id'])),
                        [color=red]'description' => $result['description'],[/color]
                  'thumb' => (isset($result['filename']) && file_exists(DIR_IMAGE . $result['filename'])) ? $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')) : NULL
                   );
              }
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: RC6 Category.php

Postby Qphoria » Thu Jan 08, 2009 4:10 am

How do you figure?
The category description is at the top of the category. We don't want to show the description under the thumbnail for each sub category. We only want to show the description for the currently opened category.

See here to understand how it works:
http://forum.opencart.com/index.php/top ... l#msg13572

Moving this out of bug reports
Last edited by Qphoria on Thu Jan 08, 2009 4:17 am, edited 1 time in total.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18199
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: RC6 Category.php

Postby bthirsk » Thu Jan 08, 2009 12:47 pm

Ok, I get it.
I just did the up data to RC6 and got this error.
Notice: Undefined index: description in www\catalog\template\alternate\content\category.tpl on line 16

I added that code to make it go away.
I'll have to look at it further.
Thanks
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: RC6 Category.php

Postby bthirsk » Thu Jan 08, 2009 1:42 pm

This Problem Only occurs when you have Child categories. It will not occur in top level categories.
This is how I fixed it. Category.tpl

Code: Select all
<div class="categories">
  <?php if ($category['thumb'] != NULL) { ?>
    <a href="<?php echo $category['href']; ?>">
    <img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>">
    </a><br>
  <?php } ?>
  <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
[color=red]  <?php if (isset($category['description'])){
      echo $category['description'];
    } ?>[/color]
</div>
Last edited by Anonymous on Thu Jan 08, 2009 2:32 pm, edited 1 time in total.
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: RC6 Category.php

Postby Qphoria » Thu Jan 08, 2009 2:47 pm

ah ok i see the problem, it is a bug. I was at one point going to add the description to the thumbnail.. then i removed the code but didnt remove the tpl call.

But then I see there was a bigger problem, the description call was only being called if the category had products, not subcats.

So the proper fix in SVN r319 is:

delete:
Code: Select all
<?php echo $category['description']; ?>


Move:
Code: Select all
<?php if ($description) { ?>
<div id="category_description"><?php echo $description; ?></div>
<?php } ?>


Under:
Code: Select all
<div class="breadcrumb">
  <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
  <?php } ?>
</div>


OR
Use the fixed attached file.


Thanks for finding this one bthirsk :)
Attachments
fixed_category_tpl.zip
(693 Bytes) Downloaded 293 times
Last edited by Qphoria on Thu Jan 08, 2009 2:50 pm, edited 1 time in total.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18199
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: RC6 Category.php

Postby bthirsk » Thu Jan 08, 2009 3:27 pm

Looking at the code you did, I assume it should now give a main category description when only displaying subcategories.

That is a good idea.
Thanks
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: RC6 Category.php

Postby Qphoria » Thu Jan 08, 2009 3:47 pm

Yea it will only show the Parent category's description at the top of the page for each level
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18199
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: RC6 Category.php

Postby bthirsk » Fri Jan 09, 2009 2:17 pm

I modified my code to match yours. It works great.
On small modification.
Code: Select all
<?php if ($description) { ?>
<div id="category_description"><?php echo $description; ?>[color=red]</div>[/color]
<?php } ?>

move
, It creates HTML errors

Code: Select all
<?php if ($description) { ?>
<div id="category_description"><?php echo $description; ?>
<?php } ?>[color=red]</div>[/color]
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada

Re: RC6 Category.php

Postby Qphoria » Fri Jan 09, 2009 2:25 pm

ermm no. because if description is null, then you are going to add an extra unneeded
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18199
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: RC6 Category.php

Postby hm2k » Fri Jan 09, 2009 6:17 pm

In future, please report the actual problem not just the solution.

Thanks!
UK Web Hosting
And Gadgets - LIVE and OpenCart powered!

Have we helped you? please donate
User avatar
hm2k
Global Moderator
 
Posts: 583
Joined: Tue Mar 11, 2008 1:06 am
Location: UK

Re: RC6 Category.php

Postby bthirsk » Fri Jan 09, 2009 7:05 pm

Sorry.
The problem is HTML errors on Category.tpl.
The errors are on lines:






It wants:






So if you find that in the category.tpl:
Code: Select all
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
      <select name="page" onchange="this.form.submit();">
        <?php foreach ($pages as $pages) { ?>
        <?php if ($pages['value'] == $page) { ?>
        <option value="<?php echo $pages['value']; ?>" SELECTED><?php echo $pages['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $pages['value']; ?>"><?php echo $pages['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </form>


Change to:

Code: Select all
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
      [color=red]<div>[/color]
      <select name="page" onchange="this.form.submit();">
        <?php foreach ($pages as $pages) { ?>
        <?php if ($pages['value'] == $page) { ?>
        <option value="<?php echo $pages['value']; ?>" SELECTED><?php echo $pages['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $pages['value']; ?>"><?php echo $pages['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
      [color=red]</div>[/color]
    </form>


It should work fine

Unrelated to the category descriptions tho
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18199
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: RC6 Category.php

Postby hm2k » Mon Jan 12, 2009 6:36 pm

Are these issues related to the original bug report?
UK Web Hosting
And Gadgets - LIVE and OpenCart powered!

Have we helped you? please donate
User avatar
hm2k
Global Moderator
 
Posts: 583
Joined: Tue Mar 11, 2008 1:06 am
Location: UK

Re: RC6 Category.php

Postby bthirsk » Mon Jan 12, 2009 9:19 pm

No, these are solved.
The original should be closed. It is also fixed
Brent
User avatar
bthirsk
 
Posts: 121
Joined: Wed Sep 03, 2008 3:33 am
Location: Canada


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

Hosted by Arvixe Web Hosting