goldoi Posted September 20, 2011 Posted September 20, 2011 Hello everyone, I have added two fields in my table sql categories to add two more images 2&3. My sql categories look like this, the admin part works wel, i can add pictures: categories.php: <? if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.categories_image_2, c.categories_image_3, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.categories_image_2, c.categories_image_3, c.parent_id 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 sort_order, cd.categories_name"); } ...... // AND DISPLAY THEM USING <td class="pageHeading" align="right"> <?php if (tep_not_null($category['categories_image']) && (file_exists(DIR_WS_IMAGES . $category['categories_image'])) ) { echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); } ?> </td> <td class="pageHeading" align="center"> <?php if (tep_not_null($category['categories_image']) && (file_exists(DIR_WS_IMAGES . $category['categories_image'])) ) { echo tep_image(DIR_WS_IMAGES . $category['categories_image_2'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); } ?> </td> <td class="pageHeading" align="left"> <?php if (tep_not_null($category['categories_image']) && (file_exists(DIR_WS_IMAGES . $category['categories_image'])) ) { echo tep_image(DIR_WS_IMAGES . $category['categories_image_3'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); } ?> </td> The function which manage the pictures into : <? function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { return false; } This works: echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); This doesn't work, how to fix this ? echo tep_image(DIR_WS_IMAGES . $category['categories_image_2'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); Thx Goldoi
multimixer Posted September 20, 2011 Posted September 20, 2011 Do you query for the additional images in index.php? My community profile | Template system for osCommerce - New: Responsive | Feedback channel
multimixer Posted September 21, 2011 Posted September 21, 2011 What up? Instead of bumping you could post the query that you have in index.php that is supposed to get the images My community profile | Template system for osCommerce - New: Responsive | Feedback channel
goldoi Posted September 21, 2011 Author Posted September 21, 2011 <? if ($category_depth == 'nested') { $category_query = tep_db_query("select cd.categories_name, c.categories_image, c.categories_image_2, c.categories_image_3 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query) or die('Erreur SQL !<br>'.$category_query.'<br>'.mysql_error()); ?> <h1><?php echo $category['categories_name']; ?></h1> <div class="contentContainer"> <div class="contentText"> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <?php if (isset($cPath) && strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.categories_image_2, c.categories_image_3, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.categories_image_2, c.categories_image_3, c.parent_id 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 sort_order, cd.categories_name"); } $number_of_categories = tep_db_num_rows($categories_query); $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } The code that i give on my first post come from index.php not categories.php, i have made a mistake and we couldn't edit message. I have put here the full code that i'am using from index.php. Thx you.
goldoi Posted September 22, 2011 Author Posted September 22, 2011 up! I try to do this but it doesn't work! <? $sql = 'SELECT categories_image_2,categories_image_3 FROM categories'; $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); if (tep_not_null($req['categories_image_2']) && (file_exists(DIR_WS_IMAGES . $req['categories_image_2'])) ) { echo tep_image(DIR_WS_IMAGES . $req['categories_image_2'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.