![]() |
$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 --> 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.) |
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
|
Re: $cat.category..........desc?
Thanks for the lead! I'll take a look at this right away
|
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) { 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'); 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? |
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
|
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? |
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 |
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 |
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].*"; } |
Re: $cat.category..........desc?
1 Attachment(s)
Ummm... Where would I place that... -_-
(out for 40 minutes -_-) |
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"; 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"; |
Re: $cat.category..........desc?
include/func/func.category.php
|
Re: $cat.category..........desc?
And I'm back
|
Re: $cat.category..........desc?
huh?
|
Re: $cat.category..........desc?
Quote:
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. |
Re: $cat.category..........desc?
Quote:
I'm sorry. I meant where in func.category.php -_- |
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. -_-
|
Re: $cat.category..........desc?
$cat.category.something will not work. With the code in your first post you have to use $cat.category_descr.
|
Re: $cat.category..........desc?
Quote:
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 -_- |
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} |
Re: $cat.category..........desc?
Quote:
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? |
Re: $cat.category..........desc?
did you try $cat.description?
|
Re: $cat.category..........desc?
Yep. Definitely tried { $cat.description }
|
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
|
Re: $cat.category..........desc?
|
Re: $cat.category..........desc?
1 Attachment(s)
Quote:
Code:
{$current_category}Array (18) 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. |
Re: $cat.category..........desc?
Quote:
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 |
Re: $cat.category..........desc?
What you are showing is $currect_category.description. Looking at your debug file for $cat you have just 155
|
Re: $cat.category..........desc?
Quote:
O_O It worked straight from Copy and Paste on your site but not on mine!?? Are you -expletive-ing me!? |
Re: $cat.category..........desc?
Quote:
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"> |
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 |
Re: $cat.category..........desc?
1 Attachment(s)
Quote:
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? |
Re: $cat.category..........desc?
This is part of the debug window
Code:
{$categories} Array (14) I assume you are trying to get this code to work Code:
<div class="bot_cat" align="left"> |
Re: $cat.category..........desc?
Quote:
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? |
Re: $cat.category..........desc?
See earlier posts. categories.php probably but just read through the thread
|
Re: $cat.category..........desc?
Quote:
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. |
Re: $cat.category..........desc?
Quote:
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) { with Code:
if ($short_list) { I'm sorry if I wasn't listening clearly in the beginning. Thank you once again guys! |
Re: $cat.category..........desc?
DERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR!!!!! glad you got it!!
|
Re: $cat.category..........desc?
derrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrr
|
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.