includes/modules/pages/index/header.php causes empty homepage
The site I'm working on uses quite an old theme (all business). After upgrading to Zen Cart 1.5.7b, the homepage is empty; whereas previously it would display the categories in a grid.
I've tracked the error down to changes in the file /includes/modules/pages/index/header_php.php (sorry about typo in name of this thread)
My question: how can I over-ride this file? Or if that's not the right approach, how can I display a grid of categories on the homepage? With the old file v1.5.6 it worked fine.
The commit that seems to cause the blank page is https://github.com/zencart/zencart/c...d185756fe99be6
Many thanks, Edith
Re: includes/modules/pages/index/header.php causes empty homepage
That particular page is certainly quite different from prior versions.
No you can't "override" that file. Better to identify what's different about it and re-apply those differences to the new version in whatever way is appropriate for the new version.
You can add more header_php_xyz.php files if you want to do more things. This is rarely the best option though.
Chances are the "empty" (most likely "partial blank page") is the result of a PHP error being triggered ... and those log details will be recorded as new files at /logs/myDebug-xxxxxxxx.log ... and using the actual error details will help you sort out what needs fixing, or you can post the details here for further help.
Re: includes/modules/pages/index/header.php causes empty homepage
Thank you! Yes, it's not a blank page, no Fatal PHP error. Just the category grid is missing. Logs are not recording anything unfortunately.
Thank you for confirming that over-ride of header_php.php is not possible. I will give this another go on Monday & post an update.
Regards, Edith
Re: includes/modules/pages/index/header.php causes empty homepage
Doing a quick cursory review I discovered that All Business appears to have the "column-grid-layout" mod integrated for its product listing. It could be that that's clashing with other things. Fortunately the responsive_classic in v157b has already integrated the column-layout features, so you might consider using the /includes/modules/responsive_classic/product_listing.php and /includes/templates/responsive_classic/templates/tpl_modules_product_listing.php files as a base for a replacement.
The All Business template also won't work on PHP 7.2+ due to old syntax used in its files.
Re: includes/modules/pages/index/header.php causes empty homepage
Yes, the "all business" is pretty old. I did update it so it runs fine on PHP 7.3, but I appreciate it's on borrowed time.
I've traced the issue back to the "status" check. On the homepage, the category ID = 0; which isn't in the database and hasn't got a status. So the status check fails; and defaults to $current_category_not_found.
My fix is to change header_php.php on line 33 from:
PHP Code:
if ($category_status->EOF ) {
$current_category_not_found = true;
}
to
PHP Code:
if ($category_status->EOF && $current_category_id !== 0 ) {
$current_category_not_found = true;
}
Hope this helps others who want to show a category grid on the homepage.