X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   $cat.category..........desc? (https://forum.x-cart.com/showthread.php?t=49520)

cowsdonthack 09-03-2009 10:36 AM

$cat.category..........desc?
 
So I'm developing a dynamic section that loads all the categories from $categories

And it's going perfectly. It loads the link, it loads the category picture. And I've figured out a way to make it so that the description COULD load next to it and still remain dynamic and neat and pretty.

Der Problem

How do I load the description? I'm pretty sure there's a variable like the variable categoryid. Only I need categorydesc. I tried taking the code from main/subcategories.tpl ( {$current_category.description} )

But unfortunately it doesn't load

Der Info

This is the code I have so far and the example is here (scroll to the bottom)

Code:

<!-- Pulls the bot_cat class to make sure it stays within 900px -->
<div class="bot_cat" align="left">

<!-- Creates an Array from $categories and classifies it as "cat" -->
{foreach from=$categories item=cat}

<!-- Pulls the bot_products class to make sure each item stays in 200px -->
<!-- The link comes from here -->
<a class="bot_products" href="home.php?cat={ $cat.categoryid }">

<!-- The image is pulled from here -->
<img src="{$xcart_web_dir}/image.php?id={ $cat.categoryid }&amp;type=C" alt="" />

<!-- Ending statements -->
</a>
{/foreach}
</div>


Class bot_cat is just to make sure it wraps at 900px
Class bot_products is the size 200px 12px margin for both sides
(completely irrelevant to the problem)

Der Request

I want the text to load to the right of the Category Images.

But I can't seem to load the descriptions... At all. Not even a little.

Does anyone know what variable string it might be? or another solution?

Also... Could I find this if I had DB access? (my boss isn't letting me have that access, but he might let me if I tell him I have to find it from there.)

cflsystems 09-03-2009 10:57 AM

Re: $cat.category..........desc?
 
You probably have to edit php file responsible for writing the $category array and include description in the query. It just depends where you are doing this but take a look at function func_get_category_data($cat) in include/func/func.category.php

cowsdonthack 09-03-2009 10:58 AM

Re: $cat.category..........desc?
 
Thanks for the lead! I'll take a look at this right away

cowsdonthack 09-03-2009 11:18 AM

Re: $cat.category..........desc?
 
Der Find

So I went into *.*/include/func/func.category.php

Unfortunately, there is no func_get_category_data($cat)
However I did find func_get_category_parents down below

Code:

function func_get_category_parents($categoryid) {
    global $sql_tbl;

    if (!is_array($categoryid))
        $categoryid = array($categoryid);

    $res = db_query("SELECT categoryid_path FROM $sql_tbl[categories] WHERE categoryid IN ('".implode("','", $categoryid)."')");
    if (!$res)
        return false;

    $cats = array();
    while ($c = db_fetch_row($res)) {
        $cats = array_unique(func_array_merge($cats, explode("/", array_pop($c))));
    }
    db_free_result($res);

    return $cats;
}


I created a Test Variable to try and find where in the Database they placed the Descriptions in hopes of finding it. I'm not sure if this will help, but I figured it points to the location of where the descriptions are.

Code:

INSERT INTO xcart_categories_lng VALUES ('US', 167, 'Door Closers', 'test 03');

INSERT INTO xcart_categories VALUES (167, 0, '167', 'Door Closers', 'test 03', '', 'Y', 347, 0, 3, 66, '');


Test 03 is where the information was placed.

---

Is there someway that I could develop the functionality for xcart to get the information from where the description would be, if I copied the code for where it gets categoryid, and point it to where test 03 currently is?

cflsystems 09-03-2009 11:22 AM

Re: $cat.category..........desc?
 
Ok I just saw you are on 4.1 and this was for 4.2. Sorry. The fuction for 4.1 is in include/categories.php

cowsdonthack 09-03-2009 11:26 AM

Re: $cat.category..........desc?
 
Wow, you really know where everything in xCart is. I found it and I'm looking for where I might find a variable for the description and if not, where it's getting categoryid so that I might be able to copy that functionality.

Any ideas on where to go from here while I'm searching?

cflsystems 09-03-2009 11:32 AM

Re: $cat.category..........desc?
 
This query is in there

Code:

$to_search .= ",IF(($sql_tbl[categories_lng].category IS NOT NULL AND $sql_tbl[categories_lng].category != ''), $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category, IF(($sql_tbl[categories_lng].description IS NOT NULL AND $sql_tbl[categories_lng].description != ''), $sql_tbl[categories_lng].description, $sql_tbl[categories].description) as description, $sql_tbl[categories].category as category_name_orig";

The code is from 4.1.11 so don't just copy/paste

cowsdonthack 09-03-2009 11:40 AM

Re: $cat.category..........desc?
 
Very cool

I found this code in include/categories.php although I'm not sure how to utilize it.

To me it seems what I want is $categories.description or $category.description

But unfortunately neither of those seem to work. Description seems to be the variable, since they seem to use categoryid similarly

I'm pretty lost

ARW VISIONS 09-03-2009 11:41 AM

Re: $cat.category..........desc?
 
try this...


if ($short_list === X_CATEGORIES_FOR_SELECT_BOX) { added description to 3
$to_search = "$sql_tbl[categories].description, $sql_tbl[categories].categoryid as cid, $sql_tbl[categories].categoryid, $sql_tbl[categories].parentid, $sql_tbl[categories].categoryid_path, $sql_tbl[categories].category";

} elseif ($short_list) {
$to_search = "$sql_tbl[categories].description, $sql_tbl[categories].categoryid as cid, $sql_tbl[categories].categoryid, $sql_tbl[categories].parentid, $sql_tbl[categories].categoryid_path, $sql_tbl[categories].category, $sql_tbl[categories].avail, $sql_tbl[categories].order_by";

} else {
$to_search = "$sql_tbl[categories].description, $sql_tbl[categories].categoryid as cid, $sql_tbl[categories].*";
}

cowsdonthack 09-03-2009 11:51 AM

Re: $cat.category..........desc?
 
1 Attachment(s)
Ummm... Where would I place that... -_-

(out for 40 minutes -_-)

cflsystems 09-03-2009 11:57 AM

Re: $cat.category..........desc?
 
Replace this
Code:

$to_search .= ",IF(($sql_tbl[categories_lng].category IS NOT NULL AND $sql_tbl[categories_lng].category != ''), $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category, IF(($sql_tbl[categories_lng].description IS NOT NULL AND $sql_tbl[categories_lng].description != ''), $sql_tbl[categories_lng].description, $sql_tbl[categories].description) as description, $sql_tbl[categories].category as category_name_orig";
with this
Code:

  $to_search .= ",IF(($sql_tbl[categories_lng].category IS NOT NULL AND $sql_tbl[categories_lng].category != ''), $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category, IF(($sql_tbl[categories_lng].description IS NOT NULL AND $sql_tbl[categories_lng].description != ''), $sql_tbl[categories_lng].description, $sql_tbl[categories].description) as description, $sql_tbl[categories].category as category_name_orig, $sql_tbl[categories].description as category_descr";
and then in the template call it like this $current_category.category_descr or $category.category_descr or $cat.category_descr and see what happens

ARW VISIONS 09-03-2009 12:38 PM

Re: $cat.category..........desc?
 
include/func/func.category.php

cowsdonthack 09-03-2009 12:41 PM

Re: $cat.category..........desc?
 
And I'm back

ARW VISIONS 09-03-2009 12:54 PM

Re: $cat.category..........desc?
 
huh?

cowsdonthack 09-03-2009 12:59 PM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by cflsystems
Replace this
Code:

$to_search .= ",IF(($sql_tbl[categories_lng].category IS NOT NULL AND $sql_tbl[categories_lng].category != ''), $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category, IF(($sql_tbl[categories_lng].description IS NOT NULL AND $sql_tbl[categories_lng].description != ''), $sql_tbl[categories_lng].description, $sql_tbl[categories].description) as description, $sql_tbl[categories].category as category_name_orig";
with this
Code:

  $to_search .= ",IF(($sql_tbl[categories_lng].category IS NOT NULL AND $sql_tbl[categories_lng].category != ''), $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category, IF(($sql_tbl[categories_lng].description IS NOT NULL AND $sql_tbl[categories_lng].description != ''), $sql_tbl[categories_lng].description, $sql_tbl[categories].description) as description, $sql_tbl[categories].category as category_name_orig, $sql_tbl[categories].description as category_descr";
and then in the template call it like this $current_category.category_descr or $category.category_descr or $cat.category_descr and see what happens


DER PROGRESS!

Ok, it may not be success, but it's definitely very cool

I tried these three to no avail
$current_category.category_descr
$category.category_descr
$cat.category_descr

But then I realized, that "cat" was the item holding the description.

So I tried
{$cat.category.category_descr}

What you did must have worked somewhat. It loads "something"

http://frozeninksecret.com/tmp/que.gif

Some coincidences... There are 14 Categories that it loads, and fourteen 14 Images.

Whatever {$cat.category.category_descr} pulls is 14 Characters. So what I'm thinking is that it's pulling one letter of something from the DB.

cowsdonthack 09-03-2009 01:00 PM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by Ashley
include/func/func.category.php


I'm sorry. I meant where in func.category.php -_-

cowsdonthack 09-04-2009 05:02 AM

Re: $cat.category..........desc?
 
Oh wait... No, it doesn't matter what I put after $cat.category.whatever it'll always pull up those fourteen characters. Nevermind. -_-

cflsystems 09-04-2009 05:12 AM

Re: $cat.category..........desc?
 
$cat.category.something will not work. With the code in your first post you have to use $cat.category_descr.

cowsdonthack 09-04-2009 07:15 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by cflsystems
$cat.category.something will not work. With the code in your first post you have to use $cat.category_descr.


Ok, a couple more testing. When I use $cat.categoryid it does pull up the IDs however $cat.category_descr does not work after I placed the code. Although when I placed the code, the website functioned but Search and Checkout didn't work.

This is really a head scratcher it is, thanks for all of your help so far, it's much appreciated.

Ashley --> I added the code to func.php (tested both solutions separately and together) but it also doesn't seem to be pulling anything from $cat.description

I also tried changing the [category] to [category_lng] just in case it might be asking for a different database.

No such luck -_-

ChristineP 09-04-2009 07:49 AM

Re: $cat.category..........desc?
 
Though I don't know exactly what script you're needing, take a look at this post
http://forum.x-cart.com/showthread.php?t=41665&page=2 post #17, and you'll find
{$current_category.description}

cowsdonthack 09-04-2009 08:21 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by ChristineP
Though I don't know exactly what script you're needing, take a look at this post
http://forum.x-cart.com/showthread.php?t=41665&page=2 post #17, and you'll find
{$current_category.description}


Thanks a lot ChristineP, that's very close to what I'm looking for

Unfortunately, I'm trying to get it load outside of that page. (The home front page)

Whenever I tried to load $current_category.description foreach category. It won't load.

It will load the IDs which concurrently allows the images and the links to load. But the description doesn't load and I'm wondering how to get that to work. Any ideas?

ARW VISIONS 09-04-2009 09:26 AM

Re: $cat.category..........desc?
 
did you try $cat.description?

cowsdonthack 09-04-2009 09:59 AM

Re: $cat.category..........desc?
 
Yep. Definitely tried { $cat.description }

cflsystems 09-04-2009 10:22 AM

Re: $cat.category..........desc?
 
1 Attachment(s)
Rename the attached file to 'debug_templates.tpl' and replace the original in skin1. Open the client's side with webmaster mode enable and search in the debug window for $cat, $categories and see if description is in the arrays and what the variable name is

ARW VISIONS 09-04-2009 11:11 AM

Re: $cat.category..........desc?
 
this worked. {$cat.description}

http://www.arwvisions.com/test2/xcart/

cowsdonthack 09-08-2009 05:51 AM

Re: $cat.category..........desc?
 
1 Attachment(s)
Quote:

Originally Posted by cflsystems
Rename the attached file to 'debug_templates.tpl' and replace the original in skin1. Open the client's side with webmaster mode enable and search in the debug window for $cat, $categories and see if description is in the arrays and what the variable name is


Code:

{$current_category}Array (18)
categoryid => "155"
parentid => "0"
categoryid_path => "155"
category => "Access Control Hardware"
description => "test 01"
meta_descr => ""
avail => "Y"
views_stats => "256"
order_by => "0"
threshold_bestsellers => "1"
product_count => "59"
meta_keywords => ""
is_icon => "Y"
image_path => "./images/C/01.gif"
subcategory_count => "4"
category_name_orig => "Access Control Hardware"
category_location => Array (1)
  0 => Array (2)
    0 => "Access Control Hardware"
    1 => "home.php?cat=155"
icon_url => "http://www.qualitydoor.com/images/C/0..."


This is what I got, it seems to be "description" but { $cat.description } doesn't work. I'll use this information to experiment s'more

Enclosed is the entire statistics for this one page.

cowsdonthack 09-08-2009 05:51 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by Ashley
this worked. {$cat.description}

http://www.arwvisions.com/test2/xcart/


I see that, which makes me think, maybe the variable is rewritten in mine or something... Thanks for going to such lengths to help me out

cflsystems 09-08-2009 05:55 AM

Re: $cat.category..........desc?
 
What you are showing is $currect_category.description. Looking at your debug file for $cat you have just 155

cowsdonthack 09-08-2009 05:58 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by Ashley
this worked. {$cat.description}

http://www.arwvisions.com/test2/xcart/


O_O It worked straight from Copy and Paste on your site but not on mine!??

Are you -expletive-ing me!?

cowsdonthack 09-08-2009 06:01 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by cflsystems
What you are showing is $currect_category.description. Looking at your debug file for $cat you have just 155


Yeah... I tried placing { $current_category.description } and { $cat.current_category.description } within the foreach tags.

Thought it might have a chance.

So... Is there anyway I could define the current code that I have within $current_category?

I tried setting {foreach from=$current_category item=cat} but then it wouldn't show the images or the descriptions.

Code is still

Code:

<div class="bot_cat" align="left">
{foreach from=$categories item=cat}
<a class="bot_products" href="home.php?cat={ $cat.categoryid }"><img src="{$xcart_web_dir}/image.php?id={ $cat.categoryid }&amp;type=C" alt="" />{ $cat.categoryid }
</a>{/foreach}
</div>


cflsystems 09-08-2009 06:14 AM

Re: $cat.category..........desc?
 
You are trying to list more then one category - currect_category is just what it says and applies to currect category you are in and is only one category. This {foreach from=$current_category item=cat} will list individual properties under currect category and nothing else. Not sure yet where are you trying all of this and what variable are available. Try this
{foreach from=$categories key=c item=i}
$i.category : $i.description
{/foreach}
but looking at your debug file attached here you still don't have description included in categories arrays. You need to edit php file and include it

cowsdonthack 09-08-2009 06:20 AM

Re: $cat.category..........desc?
 
1 Attachment(s)
Quote:

Originally Posted by cflsystems
You are trying to list more then one category - currect_category is just what it says and applies to currect category you are in and is only one category. This {foreach from=$current_category item=cat} will list individual properties under currect category and nothing else. Not sure yet where are you trying all of this and what variable are available. Try this
{foreach from=$categories key=c item=i}
$i.category : $i.description
{/foreach}
but looking at your debug file attached here you still don't have description included in categories arrays. You need to edit php file and include it


Oh sorry about that, it's on the home_list.tpl which loads up in the home page. Ashley has the code working on his website.

The debug file attached is when you go into the category which is where the variable was original taken from and is working. But it doesn't work in home_list.tpl

Very sorry about that confusion.

---
Update
---

I tried changing the code you mentioned. What php did you think I should edit and include.

When I changed the code I realized it was also pulling up another variable and displaying it. Which was Category.

So that's neat, it can display the ID and the Category as well. But not the description? How do we make the array begin from Current_Category?

cflsystems 09-08-2009 06:28 AM

Re: $cat.category..........desc?
 
This is part of the debug window
Code:

{$categories} Array (14)
155 => Array (11)
  parentid => "0"
  categoryid_path => "155"
  category => "Access Control Hardware"
  avail => "Y"
  order_by => "0"
  subcategory_count => "4"
  product_count => "59"
  is_icon => "Y"
  image_path => "./images/C/01.gif"
  categoryid => 155
  icon_url => "http://www.qualitydoor.com/images/C/0..."
9 => Array (11)
  parentid => "0"
  categoryid_path => "9"
  category => "Bathroom Accessories"
  avail => "Y"
  order_by => "0"
  subcategory_count => "16"
  product_count => "173"
  is_icon => "Y"

as you can see there is no description in categories arrays. Edit php file as posted earlier so you can get the descr to show in arrays, then you will be able to access it
I assume you are trying to get this code to work
Code:

<div class="bot_cat" align="left">
{foreach from=$categories item=cat}
<a class="bot_products" href="home.php?cat={ $cat.categoryid }"><img src="{$xcart_web_dir}/image.php?id={ $cat.categoryid }&amp;type=C" alt="" />{ $cat.categoryid }
</a>{/foreach}
</div>

after you edit the php file and have descr in cat arrays they yes it will be {$cat.description} inside that code

cowsdonthack 09-08-2009 06:34 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by cflsystems
This is part of the debug window
Code:

{$categories} Array (14)
155 => Array (11)
  parentid => "0"
  categoryid_path => "155"
  category => "Access Control Hardware"
  avail => "Y"
  order_by => "0"
  subcategory_count => "4"
  product_count => "59"
  is_icon => "Y"
  image_path => "./images/C/01.gif"
  categoryid => 155
  icon_url => "http://www.qualitydoor.com/images/C/0..."
9 => Array (11)
  parentid => "0"
  categoryid_path => "9"
  category => "Bathroom Accessories"
  avail => "Y"
  order_by => "0"
  subcategory_count => "16"
  product_count => "173"
  is_icon => "Y"

as you can see there is no description in categories arrays. Edit php file as posted earlier so you can get the descr to show in arrays, then you will be able to access it
I assume you are trying to get this code to work
Code:

<div class="bot_cat" align="left">
{foreach from=$categories item=cat}
<a class="bot_products" href="home.php?cat={ $cat.categoryid }"><img src="{$xcart_web_dir}/image.php?id={ $cat.categoryid }&amp;type=C" alt="" />{ $cat.categoryid }
</a>{/foreach}
</div>

after you edit the php file and have descr in cat arrays they yes it will be {$cat.description} inside that code


Thank you so much for bringing that up, I didn't even know that the webmaster mode was giving me ALL the variables for each thing, that's very helpful

But when you mean editing the PHP file did you mean -->
func.category.php
categories.php
or the index or home_list?

cflsystems 09-08-2009 06:39 AM

Re: $cat.category..........desc?
 
See earlier posts. categories.php probably but just read through the thread

cowsdonthack 09-08-2009 06:52 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by Ashley
this worked. {$cat.description}

http://www.arwvisions.com/test2/xcart/


Hey, Ashley, if there's no problem with it, could you attach your categories.php to me? I'm going to compare it to the one that I have. And since I know the one you have is working, it would really help.

cowsdonthack 09-08-2009 08:44 AM

Re: $cat.category..........desc?
 
Quote:

Originally Posted by cflsystems
See earlier posts. categories.php probably but just read through the thread


DER SUCCESS!

THANK YOU CFL and Ashley! Yeah, so I went into the categories.php I don't know if this was modified but you were absolutely right. I cross referenced with what Ashley said, and figured that it had nothing to do with the home_list page.

These were the exact lines that needed to be changed.

Code:

    if ($short_list) {
        $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
    } else {
        $to_search = "$sql_tbl[categories].*";
    }


with

Code:

    if ($short_list) {
        $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].description,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
    } else {
        $to_search = "$sql_tbl[categories].*";
    }


I'm sorry if I wasn't listening clearly in the beginning.

Thank you once again guys!

ARW VISIONS 09-08-2009 08:57 AM

Re: $cat.category..........desc?
 
DERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR!!!!! glad you got it!!

cowsdonthack 09-08-2009 09:15 AM

Re: $cat.category..........desc?
 
derrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrr

cflsystems 09-08-2009 10:09 AM

Re: $cat.category..........desc?
 
Keep on reading, you will get a lot more :)


All times are GMT -8. The time now is 11:01 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.