Forums / Templates, Stylesheets, Page Layout / category descriptions on index page

category descriptions on index page

Locked

Started by crackwilding on 17 Oct 2007, 3:45 AM · Views: 2,798

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
17 Oct 2007, 3:45 AM
#1
crackwilding avatar

crackwilding

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

category descriptions on index page

Hi all,

I have all my categories listed on the index page, but I need the category descriptions there as well. The categories_description variable only seems to be available on the specific category pages. Is there any way around this?

Cheers,
cw

17 Oct 2007, 3:58 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: category descriptions on index page

You would need to customize the categories row module to include descriptions ...

Note: be sure to use your templates and overrides on this ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Oct 2007, 8:25 PM
#3
crackwilding avatar

crackwilding

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: category descriptions on index page

Well, that's what I figured, but in that file, the $categories object doesn't contain the description (object shown below). How can I access the description within the category_row file?

The object as it appears in category_row:

queryFactoryResult Object
(
[is_cached] =>
[resource] => Resource id #218
[cursor] => 0
[EOF] =>
[fields] => Array
(
[categories_id] => 2
[categories_name] => Curettes
[categories_image] => thumb-placeholder.jpg
[parent_id] => 0
)
)

20 Oct 2007, 8:49 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: category descriptions on index page

Probably in the category_row.php as suggested might be red text and in an order that you prefer

//    $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);

    $list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
                                           'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_description'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories->fields['categories_name'] . '</a>');

Zen-Venom Get Bitten

24 Oct 2007, 12:39 AM
#5
crackwilding avatar

crackwilding

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: category descriptions on index page

I'll give that a try. Thanks.

25 Oct 2007, 1:55 AM
#6
crackwilding avatar

crackwilding

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: category descriptions on index page

Alright, I plugged that in, didn't work -- $categories->fields['categories_description'] returns nothing. As I wrote above, categories_description is not part of the categories object. Whatever code is generating the object is not in category_row.php, and it seems to default to not tapping the categories_description table when the page is the index page, but does for individual category pages. I'm stumped.

Anyone have any further suggestions?

Cheers,
cw

25 Oct 2007, 3:46 AM
#7
crackwilding avatar

crackwilding

New Zenner

Join Date:
Oct 2007
Posts:
9
Plugin Contributions:
0

Re: category descriptions on index page

Alright, so I poked around and figured my best bet was to run my own query. So I did this:

$categories_description_query = "SELECT categories_description
FROM categories_description
WHERE categories_id = :categoriesID";

$categories_description_query = $db->bindVars($categories_description_query,
':categoriesID', $categories->fields['categories_id'], 'integer');
$categories_description = $db->Execute($categories_description_query);

Then later I can call $categories_description->fields['categories_description']

Hope this helps anyone else stuck with the same problem.

Cheers,
cw

30 Oct 2007, 2:16 PM
#8
littler avatar

littler

New Zenner

Join Date:
Oct 2007
Posts:
23
Plugin Contributions:
0

Re: category descriptions on index page

You put that query in categories_row? (I've been trying to get this to work as well, I'm not sure how I missed your post. I think I've looked at all the others that are close...) :P

Forgive my ignorance, but don't you have to have passwords to access the DB information?

I will play with this, but if someone knows WHY it works and would share that knowledge, it would be a boon to the tiny bit of my brain that tries to program...

Thanks

30 Oct 2007, 2:53 PM
#9
littler avatar

littler

New Zenner

Join Date:
Oct 2007
Posts:
23
Plugin Contributions:
0

Re: category descriptions on index page

I've tried to run your query, and I cannot figure out where to put it to make it work. :(

30 Oct 2007, 7:39 PM
#10
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: category descriptions on index page

Forgive my ignorance, but don't you have to have passwords to access the DB information?
ZenCart provides the opening of the DB with the credentials that are in your configure.php file.

there is a division between files that obtain data (categories_row.php & others) and files that use this information for display - mostly tpl_ files. So this is 2 step. Insure that the data has been made available. Then in aas associated tpl_ file display this data.

Zen-Venom Get Bitten

30 Oct 2007, 8:17 PM
#11
littler avatar

littler

New Zenner

Join Date:
Oct 2007
Posts:
23
Plugin Contributions:
0

Re: category descriptions on index page

That is what I needed. Thanks!

10 Nov 2007, 7:23 PM
#12
magneteye avatar

magneteye

Zen Follower

Join Date:
Mar 2007
Location:
Portland, OR
Posts:
163
Plugin Contributions:
0

Re: category descriptions on index page

So what was the final solution to accomplish this?

20 Dec 2007, 5:22 PM
#13
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: category descriptions on index page

Has anyone actually gotten this working yet?

9 Jan 2008, 9:04 PM
#14
sam_m avatar

sam_m

New Zenner

Join Date:
Nov 2007
Posts:
71
Plugin Contributions:
0

Re: category descriptions on index page

Ditto and just bumping up the thread

24 Feb 2008, 5:26 AM
#15
avarshav avatar

avarshav

New Zenner

Join Date:
Feb 2008
Posts:
24
Plugin Contributions:
0

Re: category descriptions on index page

Yeah me too, I'd love an answer to this as this is stumping me and I haven't gotten it to work. In which file and where do you put the query?


"I'm ready for the weekend, dude."

www.theclassicarchives.com

16 Apr 2008, 12:50 AM
#16
littler avatar

littler

New Zenner

Join Date:
Oct 2007
Posts:
23
Plugin Contributions:
0

Re: category descriptions on index page

I did not notice the bumps on this, sorry.

In category_row.php, around line 40, you will find something like this code (I'll call this "firstbit" for reference):

$list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .' '. $categories->fields['categories_name'] . '</a><br />');

Right above the "firstbit", paste these 3 lines from CrackWilding:

$categories_description_query = "SELECT categories_description FROM categories_description WHERE categories_id = :categoriesID";

$categories_description_query = $db->bindVars($categories_description_query,':categoriesID', $categories->fields['categories_id'], 'integer');

$categories_description = $db->Execute($categories_description_query);

**Then you will need to change the "firstbit" to display the description like so:
**
$list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => '<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) .' '. $categories->fields['categories_name'] . '</a><br />'. $categories_description->fields['categories_description'].'<br />');

Does that help?

29 Dec 2010, 4:28 AM
#17
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: category descriptions on index page

You should be able to get the categories_description field in $categories by adding it to the original query in /includes/modules/pages/index/main_template_vars.php (no override path available).
Add , cd.categories_description to the query in two places, line 96 and line 110:```
$categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, cd.categories_description

You should now be able to use $categories->fields['categories_description']


Note that the previous standalone query in posts 7 & 16 would not work if your database has table prefixes, or you use multiple languages. The query in main_template_vars accounts for those cases.