How to rename the product detail tab title, and display as the last tab?Magento 2: Override XML file from vendor folder to app folder doesn't work/updateHow to change the review tab title and content in product page?Add new tab on product detail page Magento 2Magento2: How to rename the Details tab on the product details page, via overwriting layout file?Why Getting categories and names on product view page Magento 2 fails?Magento 2 Add new field to Magento_User admin formAdding second attribute into product detail description tab via LayoutSales products list layeredMagento 2.2.5: Add, Update and Delete existing products Custom OptionsHow can i display attribute on Detail tab?Magento 2.3.0 - Create Product Page H1 title with product name and attribute name
Latest web browser compatible with Windows 98
Single word request: Harming the benefactor
What is the likely impact of grounding an entire aircraft series?
Making a sword in the stone, in a medieval world without magic
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
Is there an equal sign with wider gap?
Unreachable code, but reachable with exception
What is the chance of making a successful appeal to dismissal decision from a PhD program after failing the qualifying exam in the 2nd attempt?
Solving "Resistance between two nodes on a grid" problem in Mathematica
Why is Beresheet doing a only a one-way trip?
Is "history" a male-biased word ("his+story")?
They call me Inspector Morse
Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?
What to do when during a meeting client people start to fight (even physically) with each others?
Why is this plane circling around the Lucknow airport every day?
Good allowance savings plan?
Built-In Shelves/Bookcases - IKEA vs Built
Force user to remove USB token
Peter's Strange Word
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
Low budget alien movie about the Earth being cooked
Replacing Windows 7 security updates with anti-virus?
Do Bugbears' arms literally get longer when it's their turn?
Things to avoid when using voltage regulators?
How to rename the product detail tab title, and display as the last tab?
Magento 2: Override XML file from vendor folder to app folder doesn't work/updateHow to change the review tab title and content in product page?Add new tab on product detail page Magento 2Magento2: How to rename the Details tab on the product details page, via overwriting layout file?Why Getting categories and names on product view page Magento 2 fails?Magento 2 Add new field to Magento_User admin formAdding second attribute into product detail description tab via LayoutSales products list layeredMagento 2.2.5: Add, Update and Delete existing products Custom OptionsHow can i display attribute on Detail tab?Magento 2.3.0 - Create Product Page H1 title with product name and attribute name
How to rename the product detail tab title, and display as the last tab?
This is what i added, but didn't make any effect.
the file is at the following location:
/app/design/frontend/Infortis/ultimo/Amasty_Faq/layout/catalog_product_view.xml
I added:
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
and
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
to the original xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Amasty_Faq::js/section/product-url.js"/>
</head>
<body>
<referenceBlock name="product.info.details">
<block class="AmastyFaqBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
update:
I found out the tab title is set in this file. how do i override this block .php?
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
I tried to extends the Tab.php by creating a module, but didnt' work
/app/code/Kw/Renametab/Block/Catalog/Product/Tab.php
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace KwRenametabBlockCatalogProduct;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockCatalogProductTab
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Q&A') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
Amasty_Faq::product/questions_tab.phtml
looks like this
<?php
/**
* @var AmastyFaqBlockCatalogProductTab $block
*/
?>
<div class="amfaq-product-tab">
<div class="block-title">
<!--<strong><?//= $block->escapeHtml(__('Question')); ?></strong>-->
</div>
<?php
echo $block->getChildHtml('amasty_faq_questions');
if ($block->showAskQuestionForm())
echo $block->getChildHtml('amasty_faq_ask_question_form');
?>
</div>
The
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
looks like this, i'm not sure how to override the function, so i edit the original file for the mean time
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace AmastyFaqBlockCatalogProduct;
use AmastyFaqModelConfigProvider;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockAbstractBlock implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var ConfigProvider
*/
private $configProvider;
/**
* Tab constructor.
*
* @param TemplateContext $context
* @param ConfigProvider $configProvider
* @param array $data
*/
public function __construct(
TemplateContext $context,
ConfigProvider $configProvider,
array $data = []
)
parent::__construct($context, $data);
$this->configProvider = $configProvider;
/**
* @return int
*/
public function getShortAnswerBehavior()
return (int)$this->configProvider->getProductPageShortAnswerBehavior();
/**
* @return bool
*/
public function showAskQuestionForm()
return $this->configProvider->isShowAskQuestionOnProductPage();
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Product Questions') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
return [AmastyFaqModelResourceModelQuestionCollection::CACHE_TAG];
/app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/view/details.phtml
look like this
<?php
// @codingStandardsIgnoreFile
?>
<?php
$theme = $this->helper('InfortisBaseHelperData');
$innerContainerClasses = '';
$jsScriptInit = '';
$mode = $theme->getCfg('product_page/tabs');
$openedTab = $theme->getCfg('product_page/opened_tab');
$jsOpenedTab = '';
if ($openedTab !== null)
$jsOpenedTab = ', "active": ' . $openedTab;
else
$jsOpenedTab = ', "active": null';
switch ($mode)
case 1:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style') . ' show-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
case 2:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style');
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
default:
$innerContainerClasses = 'product data items style1 stacked-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true';
break;
?>
<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
<?php//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'amasty_faq_product_tab')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<div class="product info detailed collateral-container">
<?php $layout = $block->getLayout(); ?>
<div class="<?php echo $innerContainerClasses; ?>" <?php if ($jsScriptInit): ?>data-mage-init='<?php echo $jsScriptInit; ?>'<?php endif; ?>>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html))
continue;
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title">
<strong><?php /* @escapeNotVerified */ echo $label; ?></strong>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
</div>
</div>
<?php endif; ?>
magento2 layout overrides extend
add a comment |
How to rename the product detail tab title, and display as the last tab?
This is what i added, but didn't make any effect.
the file is at the following location:
/app/design/frontend/Infortis/ultimo/Amasty_Faq/layout/catalog_product_view.xml
I added:
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
and
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
to the original xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Amasty_Faq::js/section/product-url.js"/>
</head>
<body>
<referenceBlock name="product.info.details">
<block class="AmastyFaqBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
update:
I found out the tab title is set in this file. how do i override this block .php?
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
I tried to extends the Tab.php by creating a module, but didnt' work
/app/code/Kw/Renametab/Block/Catalog/Product/Tab.php
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace KwRenametabBlockCatalogProduct;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockCatalogProductTab
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Q&A') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
Amasty_Faq::product/questions_tab.phtml
looks like this
<?php
/**
* @var AmastyFaqBlockCatalogProductTab $block
*/
?>
<div class="amfaq-product-tab">
<div class="block-title">
<!--<strong><?//= $block->escapeHtml(__('Question')); ?></strong>-->
</div>
<?php
echo $block->getChildHtml('amasty_faq_questions');
if ($block->showAskQuestionForm())
echo $block->getChildHtml('amasty_faq_ask_question_form');
?>
</div>
The
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
looks like this, i'm not sure how to override the function, so i edit the original file for the mean time
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace AmastyFaqBlockCatalogProduct;
use AmastyFaqModelConfigProvider;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockAbstractBlock implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var ConfigProvider
*/
private $configProvider;
/**
* Tab constructor.
*
* @param TemplateContext $context
* @param ConfigProvider $configProvider
* @param array $data
*/
public function __construct(
TemplateContext $context,
ConfigProvider $configProvider,
array $data = []
)
parent::__construct($context, $data);
$this->configProvider = $configProvider;
/**
* @return int
*/
public function getShortAnswerBehavior()
return (int)$this->configProvider->getProductPageShortAnswerBehavior();
/**
* @return bool
*/
public function showAskQuestionForm()
return $this->configProvider->isShowAskQuestionOnProductPage();
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Product Questions') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
return [AmastyFaqModelResourceModelQuestionCollection::CACHE_TAG];
/app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/view/details.phtml
look like this
<?php
// @codingStandardsIgnoreFile
?>
<?php
$theme = $this->helper('InfortisBaseHelperData');
$innerContainerClasses = '';
$jsScriptInit = '';
$mode = $theme->getCfg('product_page/tabs');
$openedTab = $theme->getCfg('product_page/opened_tab');
$jsOpenedTab = '';
if ($openedTab !== null)
$jsOpenedTab = ', "active": ' . $openedTab;
else
$jsOpenedTab = ', "active": null';
switch ($mode)
case 1:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style') . ' show-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
case 2:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style');
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
default:
$innerContainerClasses = 'product data items style1 stacked-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true';
break;
?>
<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
<?php//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'amasty_faq_product_tab')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<div class="product info detailed collateral-container">
<?php $layout = $block->getLayout(); ?>
<div class="<?php echo $innerContainerClasses; ?>" <?php if ($jsScriptInit): ?>data-mage-init='<?php echo $jsScriptInit; ?>'<?php endif; ?>>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html))
continue;
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title">
<strong><?php /* @escapeNotVerified */ echo $label; ?></strong>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
</div>
</div>
<?php endif; ?>
magento2 layout overrides extend
Can you provide the content ofAmasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'
– Matthias_CompactCode
Mar 8 at 10:55
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday
add a comment |
How to rename the product detail tab title, and display as the last tab?
This is what i added, but didn't make any effect.
the file is at the following location:
/app/design/frontend/Infortis/ultimo/Amasty_Faq/layout/catalog_product_view.xml
I added:
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
and
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
to the original xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Amasty_Faq::js/section/product-url.js"/>
</head>
<body>
<referenceBlock name="product.info.details">
<block class="AmastyFaqBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
update:
I found out the tab title is set in this file. how do i override this block .php?
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
I tried to extends the Tab.php by creating a module, but didnt' work
/app/code/Kw/Renametab/Block/Catalog/Product/Tab.php
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace KwRenametabBlockCatalogProduct;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockCatalogProductTab
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Q&A') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
Amasty_Faq::product/questions_tab.phtml
looks like this
<?php
/**
* @var AmastyFaqBlockCatalogProductTab $block
*/
?>
<div class="amfaq-product-tab">
<div class="block-title">
<!--<strong><?//= $block->escapeHtml(__('Question')); ?></strong>-->
</div>
<?php
echo $block->getChildHtml('amasty_faq_questions');
if ($block->showAskQuestionForm())
echo $block->getChildHtml('amasty_faq_ask_question_form');
?>
</div>
The
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
looks like this, i'm not sure how to override the function, so i edit the original file for the mean time
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace AmastyFaqBlockCatalogProduct;
use AmastyFaqModelConfigProvider;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockAbstractBlock implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var ConfigProvider
*/
private $configProvider;
/**
* Tab constructor.
*
* @param TemplateContext $context
* @param ConfigProvider $configProvider
* @param array $data
*/
public function __construct(
TemplateContext $context,
ConfigProvider $configProvider,
array $data = []
)
parent::__construct($context, $data);
$this->configProvider = $configProvider;
/**
* @return int
*/
public function getShortAnswerBehavior()
return (int)$this->configProvider->getProductPageShortAnswerBehavior();
/**
* @return bool
*/
public function showAskQuestionForm()
return $this->configProvider->isShowAskQuestionOnProductPage();
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Product Questions') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
return [AmastyFaqModelResourceModelQuestionCollection::CACHE_TAG];
/app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/view/details.phtml
look like this
<?php
// @codingStandardsIgnoreFile
?>
<?php
$theme = $this->helper('InfortisBaseHelperData');
$innerContainerClasses = '';
$jsScriptInit = '';
$mode = $theme->getCfg('product_page/tabs');
$openedTab = $theme->getCfg('product_page/opened_tab');
$jsOpenedTab = '';
if ($openedTab !== null)
$jsOpenedTab = ', "active": ' . $openedTab;
else
$jsOpenedTab = ', "active": null';
switch ($mode)
case 1:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style') . ' show-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
case 2:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style');
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
default:
$innerContainerClasses = 'product data items style1 stacked-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true';
break;
?>
<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
<?php//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'amasty_faq_product_tab')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<div class="product info detailed collateral-container">
<?php $layout = $block->getLayout(); ?>
<div class="<?php echo $innerContainerClasses; ?>" <?php if ($jsScriptInit): ?>data-mage-init='<?php echo $jsScriptInit; ?>'<?php endif; ?>>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html))
continue;
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title">
<strong><?php /* @escapeNotVerified */ echo $label; ?></strong>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
</div>
</div>
<?php endif; ?>
magento2 layout overrides extend
How to rename the product detail tab title, and display as the last tab?
This is what i added, but didn't make any effect.
the file is at the following location:
/app/design/frontend/Infortis/ultimo/Amasty_Faq/layout/catalog_product_view.xml
I added:
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
and
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
to the original xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Amasty_Faq::js/section/product-url.js"/>
</head>
<body>
<referenceBlock name="product.info.details">
<block class="AmastyFaqBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
update:
I found out the tab title is set in this file. how do i override this block .php?
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
I tried to extends the Tab.php by creating a module, but didnt' work
/app/code/Kw/Renametab/Block/Catalog/Product/Tab.php
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace KwRenametabBlockCatalogProduct;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockCatalogProductTab
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Q&A') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
Amasty_Faq::product/questions_tab.phtml
looks like this
<?php
/**
* @var AmastyFaqBlockCatalogProductTab $block
*/
?>
<div class="amfaq-product-tab">
<div class="block-title">
<!--<strong><?//= $block->escapeHtml(__('Question')); ?></strong>-->
</div>
<?php
echo $block->getChildHtml('amasty_faq_questions');
if ($block->showAskQuestionForm())
echo $block->getChildHtml('amasty_faq_ask_question_form');
?>
</div>
The
/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
looks like this, i'm not sure how to override the function, so i edit the original file for the mean time
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2019 Amasty (https://www.amasty.com)
* @package Amasty_Faq
*/
namespace AmastyFaqBlockCatalogProduct;
use AmastyFaqModelConfigProvider;
use MagentoFrameworkViewElementTemplate;
class Tab extends AmastyFaqBlockAbstractBlock implements MagentoFrameworkDataObjectIdentityInterface
/**
* @var ConfigProvider
*/
private $configProvider;
/**
* Tab constructor.
*
* @param TemplateContext $context
* @param ConfigProvider $configProvider
* @param array $data
*/
public function __construct(
TemplateContext $context,
ConfigProvider $configProvider,
array $data = []
)
parent::__construct($context, $data);
$this->configProvider = $configProvider;
/**
* @return int
*/
public function getShortAnswerBehavior()
return (int)$this->configProvider->getProductPageShortAnswerBehavior();
/**
* @return bool
*/
public function showAskQuestionForm()
return $this->configProvider->isShowAskQuestionOnProductPage();
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
$count = $this->getChildBlock('amasty_faq_questions')->getCollection()->count();
$this->setTitle(__('Product Questions') . (($count) ? ' (' . $count .')' : ''));
return parent::_toHtml();
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
return [AmastyFaqModelResourceModelQuestionCollection::CACHE_TAG];
/app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/view/details.phtml
look like this
<?php
// @codingStandardsIgnoreFile
?>
<?php
$theme = $this->helper('InfortisBaseHelperData');
$innerContainerClasses = '';
$jsScriptInit = '';
$mode = $theme->getCfg('product_page/tabs');
$openedTab = $theme->getCfg('product_page/opened_tab');
$jsOpenedTab = '';
if ($openedTab !== null)
$jsOpenedTab = ', "active": ' . $openedTab;
else
$jsOpenedTab = ', "active": null';
switch ($mode)
case 1:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style') . ' show-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
case 2:
$innerContainerClasses = 'product data items ' . $theme->getCfg('product_page/tabs_style');
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true' . $jsOpenedTab . '';
break;
default:
$innerContainerClasses = 'product data items style1 stacked-tabs';
$jsScriptInit = '"tabs": "openedState": "active", "collapsible": true';
break;
?>
<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
<?php//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'amasty_faq_product_tab')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<div class="product info detailed collateral-container">
<?php $layout = $block->getLayout(); ?>
<div class="<?php echo $innerContainerClasses; ?>" <?php if ($jsScriptInit): ?>data-mage-init='<?php echo $jsScriptInit; ?>'<?php endif; ?>>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html))
continue;
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo $alias; ?>-title">
<strong><?php /* @escapeNotVerified */ echo $label; ?></strong>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
</div>
</div>
<?php endif; ?>
magento2 layout overrides extend
magento2 layout overrides extend
edited 10 hours ago
Kris Wen
asked Mar 7 at 19:41
Kris WenKris Wen
638
638
Can you provide the content ofAmasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'
– Matthias_CompactCode
Mar 8 at 10:55
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday
add a comment |
Can you provide the content ofAmasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'
– Matthias_CompactCode
Mar 8 at 10:55
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday
Can you provide the content of
Amasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'– Matthias_CompactCode
Mar 8 at 10:55
Can you provide the content of
Amasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'– Matthias_CompactCode
Mar 8 at 10:55
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday
add a comment |
2 Answers
2
active
oldest
votes
Overriding the original file isn't a great idea. If you once decide to update your module, all your changes would be overwritten anyway. In my opinion, this should be a setting in your adminpanel. There might be a few solutions to this.
Change the tab title
Solution 1
You can create a module and make your own Block class which extends /vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
. Since you already did this, you just need to copy the catalog_product_view.xml
from the Amasty_Faq module and change the original block class to yours. It should look like this:
catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="KwRenametabBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
Also, make sure that your module depends on the Amasty_Faq module.
Solution 2
You can always create a preference in your di.xml, but try to avoid this as many times as possible. This solution should be your last and worst case scenario.
KwRenametabetcfrontenddi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="AmastyFaqBlockCatalogProductTab" type="KwRenametabBlockCatalogProductTab"/>
</config>
Both of these solutions should be temporary. I highly recommend you to make a request to Amasty and ask a setting for this.
Display as the last tab
The ideal solution would be to move the block to the end of the referenceBlock, but I tried this myself and I couldn't make it work. I did make it work by adding the follow code in Magento_Catalog/templates/product/view/details.phtml
in your theme.
$detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml');
//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'name.of.your.block.to.display.as.last')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<?php if ($detailedInfoGroup):?>
<div class="product info detailed">
...
</div>
<?php endif; ?>
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
add a comment |
In catalog_product_view.xml Change This :-
<arguments>
<argument translate="true" name="title" xsi:type="string">FAQ</argument>
<argument name="priority" xsi:type="string">sort_order_number</argument>
</arguments>
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264919%2fhow-to-rename-the-product-detail-tab-title-and-display-as-the-last-tab%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Overriding the original file isn't a great idea. If you once decide to update your module, all your changes would be overwritten anyway. In my opinion, this should be a setting in your adminpanel. There might be a few solutions to this.
Change the tab title
Solution 1
You can create a module and make your own Block class which extends /vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
. Since you already did this, you just need to copy the catalog_product_view.xml
from the Amasty_Faq module and change the original block class to yours. It should look like this:
catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="KwRenametabBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
Also, make sure that your module depends on the Amasty_Faq module.
Solution 2
You can always create a preference in your di.xml, but try to avoid this as many times as possible. This solution should be your last and worst case scenario.
KwRenametabetcfrontenddi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="AmastyFaqBlockCatalogProductTab" type="KwRenametabBlockCatalogProductTab"/>
</config>
Both of these solutions should be temporary. I highly recommend you to make a request to Amasty and ask a setting for this.
Display as the last tab
The ideal solution would be to move the block to the end of the referenceBlock, but I tried this myself and I couldn't make it work. I did make it work by adding the follow code in Magento_Catalog/templates/product/view/details.phtml
in your theme.
$detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml');
//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'name.of.your.block.to.display.as.last')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<?php if ($detailedInfoGroup):?>
<div class="product info detailed">
...
</div>
<?php endif; ?>
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
add a comment |
Overriding the original file isn't a great idea. If you once decide to update your module, all your changes would be overwritten anyway. In my opinion, this should be a setting in your adminpanel. There might be a few solutions to this.
Change the tab title
Solution 1
You can create a module and make your own Block class which extends /vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
. Since you already did this, you just need to copy the catalog_product_view.xml
from the Amasty_Faq module and change the original block class to yours. It should look like this:
catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="KwRenametabBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
Also, make sure that your module depends on the Amasty_Faq module.
Solution 2
You can always create a preference in your di.xml, but try to avoid this as many times as possible. This solution should be your last and worst case scenario.
KwRenametabetcfrontenddi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="AmastyFaqBlockCatalogProductTab" type="KwRenametabBlockCatalogProductTab"/>
</config>
Both of these solutions should be temporary. I highly recommend you to make a request to Amasty and ask a setting for this.
Display as the last tab
The ideal solution would be to move the block to the end of the referenceBlock, but I tried this myself and I couldn't make it work. I did make it work by adding the follow code in Magento_Catalog/templates/product/view/details.phtml
in your theme.
$detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml');
//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'name.of.your.block.to.display.as.last')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<?php if ($detailedInfoGroup):?>
<div class="product info detailed">
...
</div>
<?php endif; ?>
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
add a comment |
Overriding the original file isn't a great idea. If you once decide to update your module, all your changes would be overwritten anyway. In my opinion, this should be a setting in your adminpanel. There might be a few solutions to this.
Change the tab title
Solution 1
You can create a module and make your own Block class which extends /vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
. Since you already did this, you just need to copy the catalog_product_view.xml
from the Amasty_Faq module and change the original block class to yours. It should look like this:
catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="KwRenametabBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
Also, make sure that your module depends on the Amasty_Faq module.
Solution 2
You can always create a preference in your di.xml, but try to avoid this as many times as possible. This solution should be your last and worst case scenario.
KwRenametabetcfrontenddi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="AmastyFaqBlockCatalogProductTab" type="KwRenametabBlockCatalogProductTab"/>
</config>
Both of these solutions should be temporary. I highly recommend you to make a request to Amasty and ask a setting for this.
Display as the last tab
The ideal solution would be to move the block to the end of the referenceBlock, but I tried this myself and I couldn't make it work. I did make it work by adding the follow code in Magento_Catalog/templates/product/view/details.phtml
in your theme.
$detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml');
//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'name.of.your.block.to.display.as.last')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<?php if ($detailedInfoGroup):?>
<div class="product info detailed">
...
</div>
<?php endif; ?>
Overriding the original file isn't a great idea. If you once decide to update your module, all your changes would be overwritten anyway. In my opinion, this should be a setting in your adminpanel. There might be a few solutions to this.
Change the tab title
Solution 1
You can create a module and make your own Block class which extends /vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php
. Since you already did this, you just need to copy the catalog_product_view.xml
from the Amasty_Faq module and change the original block class to yours. It should look like this:
catalog_product_view.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="KwRenametabBlockCatalogProductTab" name="amasty_faq_product_tab" ifconfig="amastyfaq/product_page/show_tab" as="amfaq_product" template="Amasty_Faq::product/questions_tab.phtml" group="detailed_info">
<action method="setTitle">
<argument name="title" xsi:type="string">Q>A</argument>
</action>
<block class="AmastyFaqBlockListsQuestionsList" name="amasty_faq_questions" template="Amasty_Faq::lists/questions.phtml" after="-">
<block class="AmastyFaqBlockRatingRating" ifconfig="amastyfaq/rating/enabled" name="amasty_faq_rating" template="Amasty_Faq::rating/rating.phtml">
<block class="MagentoFrameworkViewElementTemplate" name="amasty_faq_rating_item" template="Amasty_Faq::rating/rating_item.phtml"/>
</block>
<block class="AmastyFaqBlockListsPager" name="amasty_faq_pager"/>
</block>
<block class="AmastyFaqBlockFormsAskQuestion" ifconfig="amastyfaq/product_page/show_link" name="amasty_faq_ask_question_form" template="Amasty_Faq::forms/askquestion.phtml"/>
</block>
</referenceBlock>
<move element="amasty_faq_product_tab" destination="product.info.details" after="-" />
</body>
</page>
Also, make sure that your module depends on the Amasty_Faq module.
Solution 2
You can always create a preference in your di.xml, but try to avoid this as many times as possible. This solution should be your last and worst case scenario.
KwRenametabetcfrontenddi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="AmastyFaqBlockCatalogProductTab" type="KwRenametabBlockCatalogProductTab"/>
</config>
Both of these solutions should be temporary. I highly recommend you to make a request to Amasty and ask a setting for this.
Display as the last tab
The ideal solution would be to move the block to the end of the referenceBlock, but I tried this myself and I couldn't make it work. I did make it work by adding the follow code in Magento_Catalog/templates/product/view/details.phtml
in your theme.
$detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml');
//START CODE FOR LAST TAB
foreach ($detailedInfoGroup as $key => $name)
if($name == 'name.of.your.block.to.display.as.last')
unset($detailedInfoGroup[$key]);
array_push($detailedInfoGroup, $name);
// END CODE FOR LAST TAB
?>
<?php if ($detailedInfoGroup):?>
<div class="product info detailed">
...
</div>
<?php endif; ?>
answered yesterday
Matthias_CompactCodeMatthias_CompactCode
1213
1213
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
add a comment |
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thanks for the in-depth answer. I'm trying these out. For it to display as the last tab, should the name.of.your.block.to.display.as.last be "amasty_faq_product_tab" in this case? doesn't seem to work for me..i added my details.phtml in the question.
– Kris Wen
10 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
Thank you. Your code works fine. I edited the wrong details.phtml file, that's why it didn't work. It's at this location app/design/frontend/Infortis/base/Infortis_Base/templates/product/view/details.phtml for my theme, instead of the app/design/frontend/Infortis/base/Magento_Catalog/templates/product/view/details.phtml
– Kris Wen
4 hours ago
add a comment |
In catalog_product_view.xml Change This :-
<arguments>
<argument translate="true" name="title" xsi:type="string">FAQ</argument>
<argument name="priority" xsi:type="string">sort_order_number</argument>
</arguments>
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
add a comment |
In catalog_product_view.xml Change This :-
<arguments>
<argument translate="true" name="title" xsi:type="string">FAQ</argument>
<argument name="priority" xsi:type="string">sort_order_number</argument>
</arguments>
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
add a comment |
In catalog_product_view.xml Change This :-
<arguments>
<argument translate="true" name="title" xsi:type="string">FAQ</argument>
<argument name="priority" xsi:type="string">sort_order_number</argument>
</arguments>
In catalog_product_view.xml Change This :-
<arguments>
<argument translate="true" name="title" xsi:type="string">FAQ</argument>
<argument name="priority" xsi:type="string">sort_order_number</argument>
</arguments>
edited Mar 8 at 7:57
answered Mar 8 at 7:47
Ronak RathodRonak Rathod
3589
3589
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
add a comment |
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
update the catalog_product_view.xml with this and clear cache, but didn't change anything. please advise.
– Kris Wen
Mar 8 at 17:55
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264919%2fhow-to-rename-the-product-detail-tab-title-and-display-as-the-last-tab%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you provide the content of
Amasty_Faq::product/questions_tab.phtml?
and '/public_html/vendor/amasty/module-faq-product-questions/Block/Catalog/Product/Tab.php'– Matthias_CompactCode
Mar 8 at 10:55
updated the question. for rename the title, i tried extend the _toHtml() function by create a module, but didn't work, so i just edit the original Tab.php in the vendor file for now.
– Kris Wen
Mar 8 at 17:26
I added my answer. Feel free to contact me if you have any further questions.
– Matthias_CompactCode
yesterday