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 -_-)


All times are GMT -8. The time now is 12:01 AM.

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