Jump to content

Recommended Posts

Posted (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 by Martinus
dropped $dept and count.
  • Martinus changed the title to I am at a full stop
Posted

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. 

  • Like 1
Posted

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.  

  • Like 1
Posted

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.

  • Martinus changed the title to [closed] I am at a full stop
Posted
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.

Posted

@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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...