Martinus Posted August 25, 2022 Posted August 25, 2022 (edited) How shall I explain ... I display products per child-page (from category or department or seller or vendor or anything else). I am using a browse.php template file for all. This works great. My first page is 'all-products' and inside the products I can click a category, department, seller, vendor, etc. This click, brings me to the child page, using the same template file. So far so good. The childs parent-page is a problem. It is actually using another template (name, let's say 'parent'). Another template, because I cannot display products where seller='seller': it would need to be seller=child-page-name. So, all works great for child pages, but not for parent pages. On the parent pages, let's say 'departments' I need to display the following... All departments on the website. I used this code: $depts = $pages->find("parent=/departments/"); foreach($depts as $dept) { echo $dept->department->title; Within all departments, the category (where there are products to find). I used this code: $cats = $pages->find("parent=/products", department=$dept"); foreach($cats as $cat){ echo $cat->category->title; Display the qty of products to find in this particular category. I used this code: $qty = $selector->count("parent="products", department=$dept, category=$cat"); But it's not working. I am really lost in this. Please, could someone give me a hand in this? Edited August 26, 2022 by Martinus dropped $dept and count.
MarkE Posted August 26, 2022 Posted August 26, 2022 It’s quite difficult to debug code from a few snippets (maybe someone smarter than me can…). I suggest you install the TracyDebugger module and insert some bd() statements to see what is going wrong. 1
DaveP Posted August 26, 2022 Posted August 26, 2022 I don't know if you copy/pasted your code into your question, but three instances of a double quote on a line is rarely successful and you have that twice above. 1
Martinus Posted August 26, 2022 Author Posted August 26, 2022 Hi DaveP, what do you mean by double quote on a line? $depts = $pages->find("parent=/departments/"); foreach($depts as $dept) { echo $dept->title; $cats = $pages->find("parent=/products/, department=$dept"); foreach($cats as $cat) { echo $dept->title; $cat->title; $total = $pages->count("parent=/products/, department=$dept, category=$cat"); echo $total; } } ;?> This is what I have so far.
DaveP Posted August 27, 2022 Posted August 27, 2022 On 8/25/2022 at 10:40 PM, Martinus said: $cats = $pages->find("parent=/products", department=$dept"); I take back the 'twice' (apologies), but there are three double quotes (") in the selector quoted above.
Martinus Posted August 28, 2022 Author Posted August 28, 2022 @DaveP Ooh, I see. My mistake. Could be, it did not work because of that ? But never mind. I dropped the Department already. Thanks anyway.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now