Drop the Product Details tab when it has nothing to show - #236
Draft
boo-code wants to merge 1 commit into
Draft
Conversation
Every block in product-details.tpl is conditional except product_out_of_stock, which emitted its wrapper even when no module answered actionProductOutOfStock. A product with no manufacturer, no reference, hidden quantities, no availability date, no features, no specific references and no condition therefore produced a Product Details tab whose whole content was one empty div - and the tab itself was rendered unconditionally, unlike Description and Attachments which are both guarded. The out-of-stock block is now guarded the way its six siblings are, and the partial publishes whether it has any content so product.tpl can drop the nav item too. When there is no description the pane is kept even when empty, because it is the one carrying `active`. The decision travels as a variable rather than as "is the rendered include empty": in debug mode SmartyDevTemplate wraps every include in <!-- begin --> comments, so a caller testing the markup would find it non-empty on every dev shop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
product-details.tplis wrapped in an{if}exceptproduct_out_of_stock, which emitted<div class="product-out-of-stock">even when no module answeredactionProductOutOfStock. A product with no manufacturer, no reference, hidden quantities, no availability date, no features, no specific references and no condition therefore produced a Product Details pane whose entire content was that one empty div - and the tab itself is rendered unconditionally, unlike Description and Attachments which are both guarded. The out-of-stock block is now guarded the way its six siblings are, and the partial publishes whether it has any content soproduct.tplcan drop the nav item as well.div. After it, the tab is not rendered at all and Description stays selected. A product with any of those fields set is unchanged.Verified against PrestaShop's own Smarty
Both templates compile, and the partial was rendered in the running shop for the three cases that matter.
flagisproduct_details_has_content, the variableproduct.tplnow reads; the pane column has thedebug comments stripped:
Why the decision travels as a variable and not as "is the include empty"
The obvious shape is to
{capture}the include inproduct.tpland test the captured markup. That is wronghere, and the render test is what caught it: in debug mode
SmartyDevTemplate::fetch()wraps every includein
<!-- begin ... -->/<!-- end ... -->, so the capture is never empty on a dev shop. The guard wouldhave looked correct, passed a compile check, worked in production and silently done nothing for every
developer. The partial therefore decides for itself and publishes the answer with
scope='root'.The third case, and why the tab is not always dropped
product.tplgivesactiveto Description when there is one and to Product Details otherwise. Dropping thetab whenever it is empty would leave a product with no description and no details with no active pane at
all, and any Attachments or extra tab would render hidden. So an empty pane is still kept when there is no
description - it is the only thing that can carry
active. The reported scenario has a description, so itis fixed.
Scope
Classic theme only. Hummingbird has no
product_out_of_stockblock in itsproduct-details.tpl, so it doesnot carry this defect.
assets/is untouched, as the theme requires.