Browsing through categories
Good morning.
This is probably a very simple change but I'm stuck at the moment!
On our book library we have Genres (Categories) which have sub-categories for authors (manufacturers) so when you use the drop-down select a genre it then displays all the authors held within that genre. Selecting an author displays all their books.
We would like an option to simply browse all books regardless of the author by selecting a genre.
Any help would be greatly appreciated.
Thanks
Re: Browsing through categories
This is related to Bookx module .... or Book by moku ?
However I didn't quite understood the issue. You can try to post in the Bookx thread, maybe the author Philou will come up.
I use a lot this module, so more or less I'm very familiar with the code, but when you say we have Genres (Categories) which have sub-categories for authors (manufacturers) I got lost
Genres don't have tree relations, they work like tags.
So maybe you mean Categories with subCategories and somehow you are using authors as manufactures ?
So the filter you are using is the author's filter or manufacturer filter ?
Anyway, Have you tried the option turn off the multiple filter ( if this is bookx related) ?
Sorry, didn't really understood.
Re: Browsing through categories
Quote:
Originally Posted by
mesnitu
This is related to Bookx module .... or Book by moku ?
However I didn't quite understood the issue. You can try to post in the Bookx thread, maybe the author Philou will come up.
I use a lot this module, so more or less I'm very familiar with the code, but when you say we have Genres (Categories) which have sub-categories for authors (manufacturers) I got lost
Genres don't have tree relations, they work like tags.
So maybe you mean Categories with subCategories and somehow you are using authors as manufactures ?
So the filter you are using is the author's filter or manufacturer filter ?
Anyway, Have you tried the option turn off the multiple filter ( if this is bookx related) ?
Sorry, didn't really understood.
Hi.
OK this is not BookX or Book by Moku. I tried BookX a long while back and it completely destroyed my database!!
The way we use the system is based on the original V1.5.1 installation with a lot of bespoking. So where Zen-Cart has:
Top-level category ==> Manufacturer ==> sub-categories
we renamed it all to Genre (Top-level category) ==> Author (Manufacturer) ==> Book Series (sub-category).
Does that help at all?
Re: Browsing through categories
Where could one see this in real time?
4 Attachment(s)
Re: Browsing through categories
Hi All
I have been following similar threads where people are having the same issue. Logically it should be simple enough but I am struggling to find the correct solution.
To simplify my query:
I have a list of Top-Level Categories at the top of each page:
Attachment 18313
Clicking on 'Adult' takes me to http://digibooks.org.uk/db_155/index...index&cPath=31 (Adult has the categories_id of 31)
This gives me a list of Authors under Top-Level category Adult:
Attachment 18314
Clicking on 'A J Carella' takes me to http://digibooks.org.uk/db_155/index...x&cPath=31_589 (where A J Carella is sub-catory 589)
A J Carella has one series so clicking on that takes me to http://digibooks.org.uk/db_155/index...ath=31_589_590 (The Game Series)
Attachment 18315
Attachment 18316
The first Book 'The Game' links to http://digibooks.org.uk/db_155/index...oducts_id=6377 and so on.
OK most of our users quite like this technique. They can see a list of series for any given author under a specific category. They can also pull up all books by A J Carella by using the drop-down menu in the Manufacturers sidebox.
A lot of users simply want to browse all books listed under 'Adult' So here is where my question comes in. Is there any way through an adjusted hyperlink that clicking on 'Adult' at Top-Level could simply display all books that are associated with Top_Level categories_id=31 irrespective of author or series?
If there is I then understand that we lose the display of series listings per author. So maybe there might also be a way by maybe adding a field in the database of creating a drop-down sidebox for Series per Top-Level category?
I know that there is a specific BookX template (still in Beta I believe) that I tried a couple of years ago and it completely destroyed my databases!! I am therefore not confident enough to try that again.
This website is just a test site getting V155 ready for production so does look messy but is accessible by all.
Thanks for any advice that you may be able to give me.
Re: Browsing through categories
So, basically, you want to link to the last subcat no matter what ?
That would be in your:
\zencart\includes\modules\categories_tabs.php ( I've checked on zc 156)
Just for test purposes, try this. At least will give you an idea.
This is for the top tab category list
If cpath is not set it will link to the last child.
If is set, it will link to the top category ( I guess ... didn't test all )
that $subcategories_array has the child's categories ID.
Maybe this works, if you follow the same category configuration.
PHP Code:
while (!$categories_tab->EOF) {
$path = $categories_tab->fields['categories_id'];
// currently selected category
if ((int) $cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
$subcategories_array = array();
zen_get_subcategories($subcategories_array, $categories_tab->fields['categories_id']);
if (!empty($subcategories_array)) {
$path = $categories_tab->fields['categories_id'] . '_' . implode('_', $subcategories_array);
}
}
// create link to top level category
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $path) . '">' . $categories_tab_current . '</a> ';
//$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
$categories_tab->MoveNext();
}
And ofcourse , as always, probably there is a better way
Re: Browsing through categories
But this is very restrictive If you need to use something else on those tabs ( some other cat path)
Re: Browsing through categories
Thanks. I will give that a try.
I think the problem is that with the conglomeration of Zen-Cart contributors, the databases have been maybe over-complicated.
I was brought up 40 years ago on a mainframe programming simple database relationships.
In this case I would have:
Top-Level categories
Sub-Categories
Manufacturers
Series
Products
Just 5 database tables with all the information.
I am thinking that I may create these tables .. export the data and then try to integrate them into Zen-Cart.
I cannot get my head around why we have products .. products descriptions ... products to descriptions etc. There should be ... from past programming .. one products file with all the information???
Please don't get me wrong .. I love Zen-Cart but just think that the database structure is totally wrong causing difficulties in trying to make the system customised.
Re: Browsing through categories
normally tables like products_descriptions have languages.
So product_id is not unique because the description can exist in various languages
On products table , the pID is unique.
You've made a very specific workaround to get things done for your needs.
So, you have to tweak a bit
Re: Browsing through categories
Quote:
Originally Posted by
mesnitu
So, basically, you want to link to the last subcat no matter what ?
That would be in your:
\zencart\includes\modules\categories_tabs.php ( I've checked on zc 156)
Just for test purposes, try this. At least will give you an idea.
This is for the top tab category list
If cpath is not set it will link to the last child.
If is set, it will link to the top category ( I guess ... didn't test all )
that $subcategories_array has the child's categories ID.
Maybe this works, if you follow the same category configuration.
PHP Code:
while (!$categories_tab->EOF) {
$path = $categories_tab->fields['categories_id'];
// currently selected category
if ((int) $cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
$subcategories_array = array();
zen_get_subcategories($subcategories_array, $categories_tab->fields['categories_id']);
if (!empty($subcategories_array)) {
$path = $categories_tab->fields['categories_id'] . '_' . implode('_', $subcategories_array);
}
}
// create link to top level category
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $path) . '">' . $categories_tab_current . '</a> ';
//$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
$categories_tab->MoveNext();
}
And ofcourse , as always, probably there is a better way
Thanks, But this doesn't work in 155 just a white screen
Re: Browsing through categories
Quote:
Originally Posted by
DigiBooks
Thanks, But this doesn't work in 155 just a white screen
There may have been a typo. Whenever a whitescreen occurs, there likely is an error log generated: http://www.zen-cart.com/content.php?124-blank-page
Re: Browsing through categories
Ok thanks
I am getting:
WARNING: An Error occurred, please refresh the page and try again.
WARNING: An Error occurred, please refresh the page and try again.
Re: Browsing through categories
Quote:
Originally Posted by
DigiBooks
Ok thanks
I am getting:
WARNING: An Error occurred, please refresh the page and try again.
WARNING: An Error occurred, please refresh the page and try again.
So, not a blank screen, but same basic troubleshooting process: https://www.zen-cart.com/content.php...-and-try-again
Re: Browsing through categories
Oh, wait. I forgot that ZC 1.5.1 doesn't give as much resolution detail as more recent if not modern versions of ZC. If the issue is related to a SQL query, then will need to install mydebug backtrace in order to get some useful information about the problem.
Re: Browsing through categories
Quote:
Originally Posted by
mc12345678
Oh, wait. I forgot that ZC 1.5.1 doesn't give as much resolution detail as more recent if not modern versions of ZC. If the issue is related to a SQL query, then will need to install mydebug backtrace in order to get some useful information about the problem.
I'm testing this on a newly installed V1.5.5 - that's where I am getting the error message. This is what the error log reads:
[04-Feb-2019 20:04:58 Europe/London] Request URI: /db_155/index.php?main_page=index&cPath=31, IP address: 81.154.21.188
#1 mysqli_query() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php:45]
#2 queryFactory->query() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php:261]
#3 queryFactory->Execute() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/functions/functions_categories.php:159]
#4 zen_get_subcategories() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/functions/functions_categories.php:164]
#5 zen_get_subcategories() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/modules/categories_tabs.php:33]
#6 include(/home/sites/digibooks.org.uk/public_html/db_155/includes/modules/categories_tabs.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/template_default/templates/tpl_modules_categories_tabs.php:14]
#7 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/template_default/templates/tpl_modules_categories_tabs.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_header.php:133]
#8 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_header.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_main_page.php:119]
#9 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_main_page.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/index.php:97]
[04-Feb-2019 20:04:58 Europe/London] PHP Warning: mysqli_query(): (HY000/2008): Out of memory in /home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php on line 45
[04-Feb-2019 20:04:58 Europe/London] Request URI: /db_155/index.php?main_page=index&cPath=31, IP address: 81.154.21.188
#1 trigger_error() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/functions/functions_categories.php:159]
#5 zen_get_subcategories() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/functions/functions_categories.php:164]
#6 zen_get_subcategories() called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/modules/categories_tabs.php:33]
#7 include(/home/sites/digibooks.org.uk/public_html/db_155/includes/modules/categories_tabs.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/template_default/templates/tpl_modules_categories_tabs.php:14]
#8 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/template_default/templates/tpl_modules_categories_tabs.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_header.php:133]
#9 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_header.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_main_page.php:119]
#10 require(/home/sites/digibooks.org.uk/public_html/db_155/includes/templates/responsive_classic/common/tpl_main_page.php) called at [/home/sites/digibooks.org.uk/public_html/db_155/index.php:97]
[04-Feb-2019 20:04:58 Europe/London] PHP Fatal error: 2008:Out of memory :: select categories_id
from categories
where parent_id = '6122' ==> (as called by) /home/sites/digibooks.org.uk/public_html/db_155/includes/functions/functions_categories.php on line 159 <== in /home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php on line 171
[04-Feb-2019 20:04:58 Europe/London] PHP Fatal error: Out of memory (allocated 15466496) (tried to allocate 2787 bytes) in /home/sites/digibooks.org.uk/public_html/db_155/includes/classes/db/mysql/query_factory.php on line 171
Re: Browsing through categories
Just looking at the out of memory error message and wondering if the patch you posted is trying to browse the entire catalog or just a selected Top-level category?
The Adult category does not have that many books linked to it but guessing this could be a problem later with things like Thrillers. At present we hold nearly 24,500 books on file so maybe the server will never be able to handle these quantities.
If that is the case then would it be possible to browse in a similar way as the New Products sidebox but to restrict that to the selected Top-Level Category?
Re: Browsing through categories
Well, as I said, that was just a example to link the first category to the last.
Ex: 36_34_56 ( 36 will link to 56)
But I only tested with one product with a similar categories structure.
If you remove that piece of code and everything is ok again, well, something is wrong inside that while loop.
However, more or less, that's the process needed. This has some comments.
Try to check that $subcategories_array with a print_r($subcategories_array) , or using a die(), to debug.
Or maybe I did somthing wrong, but I can't test it write now.... and I don't have 24000 products to list
PHP Code:
while (!$categories_tab->EOF) {
$path = $categories_tab->fields['categories_id'];
// currently selected category
if ((int) $cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
$subcategories_array = array(); // this is gathering all subcategories in a array
// using zen_get_subcategories
zen_get_subcategories($subcategories_array, $categories_tab->fields['categories_id']);
if (!empty($subcategories_array)) { // if there is a subcat
// create a new path ex: 36_35_54 , so it will link to the last subcat found
$path = $categories_tab->fields['categories_id'] . '_' . implode('_', $subcategories_array);
}
}
// create link to according to the path
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $path) . '">' . $categories_tab_current . '</a> ';
//$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
$categories_tab->MoveNext();
}
Re: Browsing through categories
Quote:
Originally Posted by
mesnitu
Well, as I said, that was just a example to link the first category to the last.
Ex: 36_34_56 ( 36 will link to 56)
But I only tested with one product with a similar categories structure.
If you remove that piece of code and everything is ok again, well, something is wrong inside that while loop.
However, more or less, that's the process needed. This has some comments.
Try to check that $subcategories_array with a print_r($subcategories_array) , or using a die(), to debug.
Or maybe I did somthing wrong, but I can't test it write now.... and I don't have 24000 products to list
PHP Code:
while (!$categories_tab->EOF) {
$path = $categories_tab->fields['categories_id'];
// currently selected category
if ((int) $cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
$subcategories_array = array(); // this is gathering all subcategories in a array
// using zen_get_subcategories
zen_get_subcategories($subcategories_array, $categories_tab->fields['categories_id']);
if (!empty($subcategories_array)) { // if there is a subcat
// create a new path ex: 36_35_54 , so it will link to the last subcat found
$path = $categories_tab->fields['categories_id'] . '_' . implode('_', $subcategories_array);
}
}
// create link to according to the path
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $path) . '">' . $categories_tab_current . '</a> ';
//$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
$categories_tab->MoveNext();
}
Thanks very much for taking another look at this. I am a little confused though. The Adult category currently starts off with 56 sub-categories so I put a counter in to ensure I wasn't stuck in an infinite loop and the count stopped at 53 before crashing with the exception errors.
I have explored the various products tables trying to identify the top-level category but none of the tables show a link back to Adult Top-Level category #31. I guess that it is a case of top-level passing to sub-category downwards etc.
Thinking out of the box I am considering making an amendment to the Add / Edit products routine. At the top of the page it will show for example:
Adult ==> A J Carella ==> The Game
so Top-Level has already been identified somewhere along the line so if I can grab Top-Level #31 (for example) and automatically populate the Model No. field with that then I should be able to make a definite correlation between Top-Level and Products contained at bottom level.
I will explore the coding and see if I can write a patch script to populate model for all products and see where that goes.
Re: Browsing through categories
That piece of code was to add a link in the index page. So one could return to the adult category.
If you want to always link the first to the last, then instead try the changes below.
Testing on a clean zc156 and replicating the adult category, for me works fine.
If I click on "software" category that has more subcats, I'll go from 2 to 20. ( main_page=index&cPath=2_18_19_20)
But there is no link back. Only breadcrumbs is available to list those subcats in the middle.
PHP Code:
while (!$categories_tab->EOF) {
$path = $categories_tab->fields['categories_id'];
// currently selected category
$subcategories_array = array();
zen_get_subcategories($subcategories_array, $categories_tab->fields['categories_id']);
if (!empty($subcategories_array)) {
$path = $categories_tab->fields['categories_id'] . '_' . implode('_', $subcategories_array);
}
if ((int) $cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
// etc, etc,
}
But with thousands of products maybe is not the best way....
Re: Browsing through categories
Quote:
Originally Posted by
DigiBooks
Thanks very much for taking another look at this. I am a little confused though. The Adult category currently starts off with 56 sub-categories so I put a counter in to ensure I wasn't stuck in an infinite loop and the count stopped at 53 before crashing with the exception errors.
I have explored the various products tables trying to identify the top-level category but none of the tables show a link back to Adult Top-Level category #31. I guess that it is a case of top-level passing to sub-category downwards etc.
Thinking out of the box I am considering making an amendment to the Add / Edit products routine. At the top of the page it will show for example:
Adult ==> A J Carella ==> The Game
so Top-Level has already been identified somewhere along the line so if I can grab Top-Level #31 (for example) and automatically populate the Model No. field with that then I should be able to make a definite correlation between Top-Level and Products contained at bottom level.
I will explore the coding and see if I can write a patch script to populate model for all products and see where that goes.
Note, product won't be directly linked to a some top category from a sub-category. Going back to table relationships: product are assigned to a master category (this is primarily to support sale discounts). To support a one to many relationship they are related to a category: products_to_categories table. If the product exists in two categories then it is considered linked to the non-master category.
Then categories have a parent. If the parent is 0 then the category is a main category at the top of the store. Otherwise, the category is a sub-category.
So looking at a product, it can have one or more "parent" categories depending on if it is linked; however, the convention is to base the product in the master category as far as html identification of the canonical link so that search engines don't consider the displayed page a duplicate page. When the product appears in some other category then there is a separate "path" to get to it and it could have a different tree available.
So in your search/review, would want to look at products_to_categories, products and categories tables.