Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List view produce output even if no products #58

Open
webian opened this issue May 17, 2020 · 8 comments
Open

List view produce output even if no products #58

webian opened this issue May 17, 2020 · 8 comments

Comments

@webian
Copy link
Contributor

webian commented May 17, 2020

This commit f683f82 added lines from

$subpartArray=array();
to that are unnecessary and instead produce output in list view when there are no products to display.

@franzholz
Copy link
Owner

Maybe it is unnecessary in your case. However other websites need it this way.
All the parts inside of the subpart ###ITEM_CATEGORY_AND_ITEMS### will be emptied when no product has been found. The outer parts however are shown because of this patch.

@webian
Copy link
Contributor Author

webian commented May 22, 2020

Not to be stubborn but just to understand... in which use case is needed to show what's inside ###ITEM_LIST_TEMPLATE### if there are no products to display?

By instance: in the template shipped with tt_products, inside ###ITEM_LIST_TEMPLATE### and before ###ITEM_CATEGORY_AND_ITEMS### there is the list browser. But there's no need to display a list browser if there are no product to browse. In fact, using tt_products shipped templates with this patch and with no products, it outputs a meaningless [] (plus all the table code that's not visible to the user).

If a website needs to display something when there's no product in a list there's the template ###ITEM_LIST_EMPTY###.

So I can't imagine a use case where this patch is needed. Can you make an example please?

@webian
Copy link
Contributor Author

webian commented May 22, 2020

I add that with that patch there's no way to avoid to output what's between ###ITEM_LIST_TEMPLATE### and ###ITEM_CATEGORY_AND_ITEMS###.

In one of my use case I output the products in a table. This table has a header (column names) and it's between ###ITEM_LIST_TEMPLATE### and ###ITEM_CATEGORY_AND_ITEMS###.

After this patch the user sees only the header when the page has no products.

@franzholz
Copy link
Owner

All these subparts are emptied:

###ITEM_CATEGORY_AND_ITEMS###, ###LINK_PREV###, ###LINK_NEXT###

This marker gets empty:

###BROWSE_LINKS###

There is a case when a message has been written on the top of the list view. It is not wanted to write the same text again if there is an empty product list.

Maybe another new subpart shall be added, e.b. ###ITEMS_FOUND###

@webian
Copy link
Contributor Author

webian commented May 23, 2020

There is a case when a message has been written on the top of the list view. It is not wanted to write the same text again if there is an empty product list.

I don't understand this use case. When is this message displayed?

  1. When there are products?
  2. When there are no products?
  3. In both cases?

Solutions:

  1. put the message inside ###ITEM_LIST_TEMPLATE###
  2. put the message inside ###ITEM_LIST_EMPTY###
  3. use a custom marker like ###TOP_LIST_MESSAGE### to use in both ##ITEM_LIST_TEMPLATE### and ###ITEM_LIST_EMPTY###

In any case there's no need of this patch. Or am I missing something?

@franzholz
Copy link
Owner

This patch will not be removed any more. This would break some shops. Only a new patch with conditions can be added.

The ###ITEM_LIST_EMPTY### subpart is appended to the ##ITEM_LIST_TEMPLATE### subpart now.

@webian
Copy link
Contributor Author

webian commented May 23, 2020

Ok, I got it.
What about a TS config like emptyListTemplateIfNoProd, off by default?
And then an if (!$this->conf['emptyListTemplateIfNoProd']) in those lines 2425-2433.
(or the opposite)

@franzholz
Copy link
Owner

franzholz commented May 23, 2020

Make a simpler name as a proposal for TypoScript.

 conf.tt_products.LIST.addEmptyList = 1

This will give the current behaviour. If no product is found, then the empty list will be added, If it is not set, then the empty list will be the only output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants