155f - Show Categories on Main Page issue - Breaks Page
1.5.5f Westminster New template
when setting admin >> configuration >> layout_settings >> Categories - Always Show on Main Page, everything on the home page below the slider/homeads disappears, i.e. only content which is included in includes/languages/english/html_includes/westminster_new/define_main_page.php is showing - footer is gone, featured products is gone, editable middlebox is gone. (turned editable_middlebox off to test if there was a conflict - no problem) - admin >> configuration >> layout_settings >> Main Page Opens with a Category, is set to default '0' so should show top level categories
no error log generated so I am not sure where to start looking for a fix - if required use this site as an example www.harmonyball.net.au (is happening on 5 sites all configured the same with the same plugins)
I would appreciate some assistance.
thanks,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
On my mobile the entire page rendered. When a partial blank page doesn't generate a mydebug-xxx log, the next thing to see is where the page content ended. Ie. Did all of the content get pushed to the browser but perhaps something else prevented the display of the rest of it.
Putting the page through a validator there were errors that should be fixed: https://validator.w3.org/check?uri=h...Inline&group=0
Re: 155f - Show Categories on Main Page issue - Breaks Page
Quote:
Originally Posted by
mc12345678
On my mobile the entire page rendered. When a partial blank page doesn't generate a mydebug-xxx log, the next thing to see is where the page content ended. Ie. Did all of the content get pushed to the browser but perhaps something else prevented the display of the rest of it.
Putting the page through a validator there were errors that should be fixed:
https://validator.w3.org/check?uri=h...Inline&group=0
Many thanks for your reply MC ..... yes the page would have rendered in full because show categories is currently set to 0 because the site is live - it is when I try to set it to 1 that the page does not fully load. I have no idea where to start to try to ascertain what may be causing the page not to load fully when this setting is changed.
I will try to replicate it on a test site and post that test site address with the setting set to 1 if that would help?
In respect to the errors shown in validator I will address those however I doubt any of these would be causal would they?
cheers,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
Quote:
Originally Posted by
shags38
Many thanks for your reply MC ..... yes the page would have rendered in full because show categories is currently set to 0 because the site is live - it is when I try to set it to 1 that the page does not fully load. I have no idea where to start to try to ascertain what may be causing the page not to load fully when this setting is changed.
I will try to replicate it on a test site and post that test site address with the setting set to 1 if that would help?
In respect to the errors shown in validator I will address those however I doubt any of these would be causal would they?
cheers,
Mike
Hello MC - I don't know why I didn't do this in the first place, I will claim a seniors moment - here is a test store with 'show categories on main page' switched on
www.cliponearrings.net.au/teststore/ ..... only the index page is affected.
cheers,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
Quote:
Originally Posted by
shags38
Many thanks for your reply MC ..... yes the page would have rendered in full because show categories is currently set to 0 because the site is live - it is when I try to set it to 1 that the page does not fully load. I have no idea where to start to try to ascertain what may be causing the page not to load fully when this setting is changed.
I will try to replicate it on a test site and post that test site address with the setting set to 1 if that would help?
In respect to the errors shown in validator I will address those however I doubt any of these would be causal would they?
cheers,
Mike
Hello MC - I don't know why I didn't do this in the first place, I will claim a seniors moment - here is a test store with 'show categories on main page' switched on
www.cliponearrings.net.au/teststore/ ..... only the index page is affected.
cheers,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
MC ... searched Google and found this thread of a similar nature that you were involved in so just wondering if that thread has something relative to my issue??
https://www.zen-cart.com/showthread....p-on-home-page
thanks,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
Quote:
Originally Posted by
shags38
Hello MC - I don't know why I didn't do this in the first place, I will claim a seniors moment - here is a test store with 'show categories on main page' switched on
www.cliponearrings.net.au/teststore/ ..... only the index page is affected.
cheers,
Mike
please use this site now as the site with categories on main page switched on >> https://www.treeoflifejewellery.com.au/teststore/
I switched template to Responsive Classic and the categories did show on the main page so I can only assume the issue I have will be a template one?
thanks,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
That last bit is good to know and good information. What it means is that yes somewhere in the files is something related to the template that is causing the issue.
So, now to or perhaps back to the methods of determining where or what the issue is.
First of all and just generally speaking. When I had looked at the html source code generated on the test site, there was a comment identifying the bof for categories (or something similar) but no ending marker. Also, I think it was in the original message stated that no error logs were being generated.
So, either of two things are potentially expected. Either the start comment is provided and an ending comment is not, or there is an error occurring that is not captured by the ZC error logging process.
Pick your poison of tracking down either/both conditions.
For the bof/eof part, would use the developers tool kit to search for the bof section and be sure that are looking at the fileset for the template. Then try to determine if/where the eof is for that content and why it is not pushed to the browser.
For the error message logging, would check to see if any/which errors can be logged. For example if you create a file that has a poorly formed SQL statement and execute it, the error log should be generated. If it doesn't get generated, then it's an indication that something further needs to be investigated. If it does, then the files are suspect and may have an error that doesn't get logged by ZC, but is logged by the server. (server logs may need to be requested from the host if not able to access them.)
A file method test could be to create a file in the root of the store with a name of your choosing ending with .php and containing the following incorrect sql statement:
Code:
<?php
require 'includes/application_top.php';
$db->Execute('SELECT customers_id FROM ' . TABLE_CUSTOMERS . 'WHERE customers_id = 1 LIMIT 1');
This should at least throw an error because of the missing space before the WHERE portion.
Re: 155f - Show Categories on Main Page issue - Breaks Page
Hi MC - so following one of your suggestions I used cPanel to access error logs as a validator per se and whilst the latest errors shown in logs using my ftp client were dated 10 August there were errors generated right up until today's date in the file manager in cPanel - I have no idea what may be causing this but will ask my host.
Anyway here is the latest error with Categories - Always show on main page switched to 'on'
Code:
[12-Sep-2018 10:51:36 Australia/Melbourne] Request URI: /teststore/, IP address: 203.63.42.62
#1 zen_categories_ul_generator->buildBranch() called at [/home/treeofl3/public_html/teststore/includes/classes/categories_ul_generator.php:85]
#2 zen_categories_ul_generator->buildTree() called at [/home/treeofl3/public_html/teststore/includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php:27]
#3 require(/home/treeofl3/public_html/teststore/includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php) called at [/home/treeofl3/public_html/teststore/includes/templates/westminster_new/common/tpl_header.php:134]
#4 require(/home/treeofl3/public_html/teststore/includes/templates/westminster_new/common/tpl_header.php) called at [/home/treeofl3/public_html/teststore/includes/templates/westminster_new/common/tpl_main_page.php:182]
#5 require(/home/treeofl3/public_html/teststore/includes/templates/westminster_new/common/tpl_main_page.php) called at [/home/treeofl3/public_html/teststore/index.php:97]
[12-Sep-2018 10:51:36 Australia/Melbourne] PHP Warning: A non-numeric value encountered in /home/treeofl3/public_html/teststore/includes/classes/categories_ul_generator.php on line 58
[12-Sep-2018 10:51:36 Australia/Melbourne] PHP Fatal error: Uncaught Error: Cannot use string offset as an array in /home/treeofl3/public_html/teststore/includes/modules/westminster_new/category_row.php:39
Stack trace:
#0 /home/treeofl3/public_html/teststore/includes/templates/template_default/templates/tpl_modules_category_row.php(14): require()
#1 /home/treeofl3/public_html/teststore/includes/templates/westminster_new/templates/tpl_index_categories.php(107): require('/home/treeofl3/...')
#2 /home/treeofl3/public_html/teststore/includes/modules/pages/index/main_template_vars.php(236): require('/home/treeofl3/...')
#3 /home/treeofl3/public_html/teststore/includes/templates/westminster_new/common/tpl_main_page.php(253): require('/home/treeofl3/...')
#4 /home/treeofl3/public_html/teststore/index.php(97): require('/home/treeofl3/...')
#5 {main}
thrown in /home/treeofl3/public_html/teststore/includes/modules/westminster_new/category_row.php on line 39
here are the two files highlighted as php warnings;
includes/classes/categories_ul_generator.php
Code:
<?php
//placeholder21// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright(c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright(c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: categories_ul_generator.php 2004-07-11 DrByteZen $
// based on site_map.php v1.0.1 by networkdad 2004-06-04
//
class zen_categories_ul_generator {
var $root_category_id = 0,
$max_level = 0,
$data = array(),
$parent_group_start_string = '<ul%s>',
$parent_group_end_string = '</ul>',
$child_start_string = '<li%s>',
$child_end_string = '</li>',
$spacer_string = '
',
$spacer_multiplier = 1;
var $document_types_list = ' (3) ';
// acceptable format example: ' (3, 4, 9, 22, 18) '
function zen_categories_ul_generator($load_from_database = true)
{
global $languages_id, $db;
$this->data = array();
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
" order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
while (!$categories->EOF) {
$this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
$categories->MoveNext();
}
}
function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
{
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
if (($this->data[$parent_id])) {
foreach($this->data[$parent_id] as $category_id => $category) {
$category_link = $parent_link . $category_id;
if (($this->data[$category_id])) {
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
$result .= sprintf($this->child_start_string, '');
}
$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
$result .= $category['name'];
$result .= '</a>';
if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
$result .= $this->buildBranch($category_id, $level+1, $submenu, $category_link . '_');
}
$result .= $this->child_end_string;
}
}
$result .= $this->parent_group_end_string;
return $result;
}
function buildTree($submenu=false)
{
return $this->buildBranch($this->root_category_id, '', $submenu);
}
}
?>
includes/module/westminster_new/category_row.php
Code:
<?php
/**
* index category_row.php
*
* Prepares the content for displaying a category's sub-category listing in grid format.
* Once the data is prepared, it calls the standard tpl_list_box_content template for display.
*
* @package page
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: category_row.php 4084 2006-08-06 23:59:36Z drbyte $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$title = '';
$num_categories = $categories->RecordCount();
$row = 0;
$col = 0;
$list_box_contents = '';
if ($num_categories > 0) {
if ($num_categories < MAX_DISPLAY_CATEGORIES_PER_ROW || MAX_DISPLAY_CATEGORIES_PER_ROW == 0) {
$col_width = floor(100/$num_categories);
} else {
$col_width = floor(100/MAX_DISPLAY_CATEGORIES_PER_ROW);
}
while (!$categories->EOF) {
if (!$categories->fields['categories_image']) !$categories->fields['categories_image'] = 'pixel_trans.gif';
$cPath_new = zen_get_path($categories->fields['categories_id']);
// strip out 0_ from top level cats
$cPath_new = str_replace('=0_', '=', $cPath_new);
// $categories->fields['products_name'] = zen_get_products_name($categories->fields['products_id']);
$list_box_contents[$row][$col] = array('params' => 'class="categoryListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => '<div class="common-wrap"><a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories->fields['categories_name'] . '</a></div>');
$col ++;
if ($col > (MAX_DISPLAY_CATEGORIES_PER_ROW -1)) {
$col = 0;
$row ++;
}
$categories->MoveNext();
}
}
?>
Hopefully this will help you to help me solve the problem.
cheers,
Mike
Re: 155f - Show Categories on Main Page issue - Breaks Page
While I didn't go through and "count" each line some of the code is familiar and has been updated in the 1.5.6 distribution as well as published but not released 1.5.5
For example, would suggest changing or adding to the following
Code:
function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
{
To be like:
Code:
function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
{
$level = (int)$level;
And for the second file changing $list_box_contents from being defined as a string to a proper array by changing:
Code:
$list_box_contents = '';
to:
Code:
$list_box_contents = array();