Jump to content
kymation

[Contribution] Categories Images Box support thread

Recommended Posts

The Categories Images Box is a box on the main (index) page of your site that shows an image (and optional text) for each of your top-level categories.

 

The categories can be diplayed in a grid (like the New Products box) or in rows like the Category product list. Images can be different than the images at the top of each category page. Images, the category name, and the text can be separately enabled in the admin.

 

The box itself can look the same as all other osCommerce boxes (Stock), a plain outline box with no header (Simple), or as plain text/images with no borders at all (Plain).

 

Screenshots are included in the contribution download for each of the above styles and for the admin functions.

 

The contribution is here.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Very Nice Contrib

 

can the Catagory main page show the sub images on the bottom meaning I use the maim image on top and the sub pages ( dresses tops etc on the bottom be the second image in your contribution Ive enclosed screen capture

 

also can I make the colums 4 instead of 3?

 

Thank You

Ss7.jpg

Share this post


Link to post
Share on other sites

If I'm understanding you correctly here, the answer is yes, you can make your index page look like that screenshot. You would need to put your main image in the define for TEXT_MAIN, or modify the page to insert it directly. This contribution will take care of the images for each of the main categories below that.

 

And yes, you can set the number of columns in the Admin. It's a puzzle to me why this wasn't done throughout osCommerce.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hello,

 

I've installed the contribution, but since i had a few mods done to the index page i just patch the files, as per instructed, but now i have the following error

 

Warning: Division by zero in /includes/modules/categories_images.php on line 72

 

Any ideas ? , i've gone through the files three times and found no error, plus the error is on the file i just uploaded to the /includes/modules/categories_images.php

 

 

Thank you and great contribution

Share this post


Link to post
Share on other sites

Congratulations, you've found a bug. Change Line 72 of that file to:

		  $width = (floor (100 / CATEGORIES_IMAGES_BOX_COLUMNS) );

Sorry for the inconvenience. That's what I get for trying to reuse code and forgetting to change all of the constants.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

And the forum codebox completely fails to work. Again. That's such a mess that I'm having trouble seeing anything at all in it. Winmerge just throws up all over the page.

 

What I can see is messed-up inserts like this:

/*** Begin Header Tags SEO ***/
$categories_htc_title_array = $HTTP_POST_VARS['categories_htc_title_tag'];
$categories_htc_desc_array = $HTTP_POST_VARS['categories_htc_desc_tag'];
$categories_htc_keywords_array = $HTTP_POST_VARS['categories_htc_keywords_tag'];
$categories_htc_description_array = $HTTP_POST_VARS['categories_htc_description'];
/*** End Header Tags SEO ***/

$language_id = $languages[$i]['id'];

/*** Begin Header Tags SEO ***/
$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]),
'categories_htc_title_tag' => (tep_not_null($categories_htc_title_array[$language_id]) ? tep_db_prepare_input($categories_htc_title_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_desc_tag' => (tep_not_null($categories_htc_desc_array[$language_id]) ? tep_db_prepare_input($categories_htc_desc_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_keywords_tag' => (tep_not_null($categories_htc_keywords_array[$language_id]) ? tep_db_prepare_input($categories_htc_keywords_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_description' => tep_db_prepare_input($categories_htc_description_array[$language_id]));
/*** End Header Tags SEO ***/

// Start Categories images box
$categories_description_front_array = $_POST['categories_description_front'];
$sql_data_array = array ('categories_name' => tep_db_prepare_input ($categories_name_array[$language_id] ),
'categories_description_front' => tep_db_prepare_input ($categories_description_front_array[$language_id] ) );
// End Categories images box

should be this

/*** Begin Header Tags SEO ***/
$categories_htc_title_array = $HTTP_POST_VARS['categories_htc_title_tag'];
$categories_htc_desc_array = $HTTP_POST_VARS['categories_htc_desc_tag'];
$categories_htc_keywords_array = $HTTP_POST_VARS['categories_htc_keywords_tag'];
$categories_htc_description_array = $HTTP_POST_VARS['categories_htc_description'];
/*** End Header Tags SEO ***/
// Categories images box
$categories_description_front_array = $_POST['categories_description_front'];

$language_id = $languages[$i]['id'];

/*** Begin Header Tags SEO ***/
// Start Categories images box
$sql_data_array = array ('categories_name' => tep_db_prepare_input ($categories_name_array[$language_id] ),
'categories_description_front' => tep_db_prepare_input ($categories_description_front_array[$language_id] ) );
// End Categories images box
'categories_htc_title_tag' => (tep_not_null($categories_htc_title_array[$language_id]) ? tep_db_prepare_input($categories_htc_title_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_desc_tag' => (tep_not_null($categories_htc_desc_array[$language_id]) ? tep_db_prepare_input($categories_htc_desc_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_keywords_tag' => (tep_not_null($categories_htc_keywords_array[$language_id]) ? tep_db_prepare_input($categories_htc_keywords_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_description' => tep_db_prepare_input($categories_htc_description_array[$language_id]));
/*** End Header Tags SEO ***/

The blank page is the result of having error messages turned off. You need to turn errors back on so you can see where the problem is. Problems, more than likely, since this is almost certainly not the only one.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Many thanks. I'm a bit of a beginner, so is there any chance you can give me an idea of a process I should be using when inserting your code into the Header Tags SEO - I would have no idea how you decided to include that bit where you did :blush: ;):rolleyes:


hor-i-zon

Share this post


Link to post
Share on other sites

Actually, I probably messed up that bit. I did it in a hurry, and the code was messy, so I didn't look at it very carefully. Sorry.

 

The rules for PHP are a bit odd. Lines of code end with a semicolon or a closing brace (; or }). Nothing else counts.* So, if you see a line ending with a comma, or a period, or just about anything else, it's not really the end of the staement. So if you see something like this

$sql_data_array = array ('categories_name' => tep_db_prepare_input ($categories_name_array[$language_id] ),
'categories_description_front' => tep_db_prepare_input ($categories_description_front_array[$language_id] ),
'categories_htc_title_tag' => (tep_not_null($categories_htc_title_array[$language_id]) ? tep_db_prepare_input($categories_htc_title_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_desc_tag' => (tep_not_null($categories_htc_desc_array[$language_id]) ? tep_db_prepare_input($categories_htc_desc_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_keywords_tag' => (tep_not_null($categories_htc_keywords_array[$language_id]) ? tep_db_prepare_input($categories_htc_keywords_array[$language_id]) : tep_db_prepare_input($categories_name_array[$language_id])),
'categories_htc_description' => tep_db_prepare_input($categories_htc_description_array[$language_id]));

that's all one statement. It defines an array of 6 elements. So you can add an additional element or five to the array (the original version of this contained only one element), but you can't add other statements in the middle of this one.

 

Yes, I know this is confusing. PHP is not the easiest language to code in, but you'll just have to learn some of it in order to get by. If it helps, I had to do the same thing, under a deadline, and learn osCommerce and mySQL at the same time, just like you're doing. It can be done.

 

To make it easier, get a good merge/compare tool. I use Winmerge, but you may find something else that you like better. That will show you where the changes need to be made. A good editor will also help a lot. I use EasyEclipse for PHP. It flags most errors for you, so you know there's a problem before you upload to your site. If you install a server (such as XAMPP) you can test everything locally as well.

 

Error messages are controlled in your php.ini. If you're on a hosted server and don't have access to this, you may be able to override this in your .htaccess. You really need to talk to your hosting service about that; some of them get testy about overriding settings, and some just plain won't allow it. Testing locally will get around most of this.

 

Regards

Jim

 

*Like most rules, there are exceptions to this one. The for() statement has semicolons inside it, and the case statement ends with a colon. Bah.


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hello,

 

Everything is working fine, one thing though, the image for the category does not show on the box, you can take a look if you like, Katomy , if you click on the category, you are redirected and the Logo for the image is shown, also on the properties of the image on the categories box, the path is http://www.katomy.com/images/ that's it, i have a subdirectory on images for the logos, is there the problem?

 

 

Thank you

Temo

Katomy.com

Share this post


Link to post
Share on other sites

Thanks for this contribution, it is exactly what i need except for one thing. I would like to add this grid to the subcatagories also. On the top catagories, the grid is there but when you click one of the catagories it takes you to the subcatagories in the regular format. If you can tell me how to add this contribution to the subcatagories i would be grateful. I know the subcatagories is about the same without this grid but i want it to keep the same look, and it works better with the design of my site.

 

Thanks!

Share this post


Link to post
Share on other sites
nevermind......after a few hours of fooling around i finally did it myself.

 

I'm interested in the same functionality. How did you get it to work?

 

thanks,

 

LUis

Share this post


Link to post
Share on other sites

Great contribution - however, when i go into admin to add my category image and description details I add the data in and then click update but it doesnt get put into the database. It doesnt add the fields.

 

I can go straight into phpmyadmin and add the content manually but when i do it through admin it doesnt work.

 

Would anyone know where i might be going wrong?

Share this post


Link to post
Share on other sites
Great contribution - however, when i go into admin to add my category image and description details I add the data in and then click update but it doesnt get put into the database. It doesnt add the fields.

 

I can go straight into phpmyadmin and add the content manually but when i do it through admin it doesnt work.

 

Would anyone know where i might be going wrong?

 

I do have header tags controller... so that may be causing a prob?

Share this post


Link to post
Share on other sites

You probably missed an edit to catalog/admin/categories.php. Check in the top half of the file. Header tags controller makes changes to this file as well, so check for conflicts between the two. I recommend a good file comparison utility such as Winmerge, Beyond Compare, etc.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hi

I have installed this contribution and it looks great but i am having a few teething problems. I have installed all the files correctly i believe and everything works ok apart from creatin a new category. i then realised i had not run the sql code. when i do this i get the error message below. I am using os2.2rca and mysql-front v5. everything has been working ok up to now.i am new to oscommerce and databases so please take it easy on me if i have left any info out. thanks in advance.

 

mysql-front error

 

sql execution error # 1109. response from the database:

unknown table 'categories' in information_schema

Share this post


Link to post
Share on other sites
<snipped>

mysql-front error

 

sql execution error # 1109. response from the database:

unknown table 'categories' in information_schema

It sounds like you tried to update the schema instead of the database. This is a new problem for MySQL 5.x.

 

If you are using phpMyAdmin, check the pulldown menu at the top of the left column. Select the one that has your database name in it, not the one that says information schema.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hello, great contribution. I think I've got it all working except for this only section of code in the admin/categories.php file. I've got the "HeaderTags SEO v3" running, and I'm trying to figure out how to put in the "Categories Images Box" code into the already modified code in categories.php.

 

This section of admin/categories.php below is what I already have. The next section of code in my following post is what the "Categories Images Box" needs, but when I put it where I think it is supposed to go, my catalog admin page goes blank.

 

_______________________________

<?php

$categories_count = 0;

$rows = 0;

if (isset($HTTP_GET_VARS['search'])) {

$search = tep_db_prepare_input($HTTP_GET_VARS['search']);

 

 

/*** Begin Header Tags SEO ***/

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, cd.categories_htc_title_tag, cd.categories_htc_desc_tag, cd.categories_htc_keywords_tag, cd.categories_htc_description from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");

 

} else {

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, cd.categories_htc_title_tag, cd.categories_htc_desc_tag, cd.categories_htc_keywords_tag, cd.categories_htc_description from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");

 

/*** End Header Tags SEO ***/

 

 

}

while ($categories = tep_db_fetch_array($categories_query)) {

$categories_count++;

$rows++;

 

// Get parent_id for subcategories if search

if (isset($HTTP_GET_VARS['search'])) $cPath= $categories['parent_id'];

 

if ((!isset($HTTP_GET_VARS['cID']) && !isset($HTTP_GET_VARS['pID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $categories['categories_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {

$category_childs = array('childs_count' => tep_childs_in_category_count($categories['categories_id']));

$category_products = array('products_count' => tep_products_in_category_count($categories['categories_id']));

 

$cInfo_array = array_merge($categories, $category_childs, $category_products);

$cInfo = new objectInfo($cInfo_array);

}

 

if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) {

echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($categories['categories_id'])) . '\'">' . "\n";

} else {

echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n";

}

?>

Share this post


Link to post
Share on other sites

This is the section of code that the "Categories Images Box" needs. But I can't get it to play well with the HeaderTags SEO v3. It looks like they are both requesting from the database, so do I combine what they are both requesting?

 

Thank you,

 

Jason

 

________________________

 

// Categories images box

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_description_front, c.categories_image, c.categories_image_front, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");

} else {

// Categories images box

Share this post


Link to post
Share on other sites

Yes, both contributions modify the same lines, so you need to merge the changes. Your code should probably look like this:

/*** Begin Header Tags SEO ***/

// Categories images box
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_description_front, c.categories_image, c.categories_image_front, c.parent_id, c.sort_order, c.date_added, c.last_modified, cd.categories_htc_title_tag, cd.categories_htc_desc_tag, cd.categories_htc_keywords_tag, cd.categories_htc_description from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");

} else {

// Categories images box
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_description_front, c.categories_image, c.categories_image_front, c.parent_id, c.sort_order, c.date_added, c.last_modified, cd.categories_htc_title_tag, cd.categories_htc_desc_tag, cd.categories_htc_keywords_tag, cd.categories_htc_description from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");

/*** End Header Tags SEO ***/

I didn't test that, so beware typos. At least it should give you the right idea.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

IT WORKS IT WORKS!!!

 

Thanks Jim,

 

one more thing, the images that this contribution requests are not working.

 

The images for my categories work just fine when normally requested by the standard side box, but when the images are requested by the "Categories Images Box" on the main section of my site, the links work, but the images are not appearing.

 

Could this be a permissions issue?

 

Thank you again,

 

Jason

 

www.oldfoundry.com

Edited by rustyclockwork

Share this post


Link to post
Share on other sites

Hi

 

Thanks for your reply. Can i change this setting in mysql-front? or how do i do it? do i need to speak to my hosting company? sorry if it is a stupid question.

 

many thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×