Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Remove attributes with multiple values from Specification Tab?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 11-17-2014, 04:47 PM
 
SignTorch SignTorch is offline
 

Advanced Member
  
Join Date: Jun 2010
Posts: 30
 

Default Re: Remove attributes with multiple values from Specification Tab?

Here's a way I found to hide product specific attributes that are not in a group

In my case I had several global attributes to display

and when I added 2 yes/no product-specific attributes for variants, those attributes display on top with yes/no as the value, which doesn't look right and is unnecessary

as luck would have it, my global attributes were all in a group, and the template that displays attributes has two IF statements to place a <div> around grouped attributes, which can be made into one IF block that only displays grouped attributes,

so that the yes/no attributes do not get displayed because they are not in a group

copy skins\default\en\product\details\parts\attribute.t pl

to skins\custom_skin\default\en\product\details\parts \attribute.tpl

and comment out the first {end} and the second {if:getAttributeGroup()} statements

Code:
{if:getAttributeGroup()} <li><div class="head-h3">{getTitle()}</div> <ul> {*end:*} <li FOREACH="getAttrList(),a"> <div><strong>{a.name}</strong></div> <span class="{a.class}">{a.value:nl2br}</span> </li> {*if:getAttributeGroup()*} </ul> </li> {end:}

instead of only hiding attributes that are not grouped, you could probably expand the if statement to hide specific groups of attributes based on the group title in {getTitle()}
__________________
SignTorch Vector Graphics
dropping xc4.6.x, tested xc5 (FAIL)
Reply With Quote
  #12  
Old 11-18-2014, 04:41 PM
 
minfinger minfinger is offline
 

X-Adept
  
Join Date: Apr 2009
Posts: 678
 

Default Re: Remove attributes with multiple values from Specification Tab?

That did not work for me.
__________________
X-Cart 4.3
Joomla
Among other things
Reply With Quote
  #13  
Old 11-18-2014, 08:09 PM
 
SignTorch SignTorch is offline
 

Advanced Member
  
Join Date: Jun 2010
Posts: 30
 

Default Re: Remove attributes with multiple values from Specification Tab?

Quote:
Originally Posted by minfinger
That did not work for me.
before applying the custom template change, make sure there is no group title above the attributes to be hidden

http://www.signtorch.com/bin/xcart/attribute-group.jpg

then place a text marker (1234) in the custom template like so

Code:
1234 {if:getAttributeGroup()} <li><div class="head-h3">{getTitle()}</div> <ul> {*end:*} <li FOREACH="getAttrList(),a"> <div><strong>{a.name}</strong></div> <span class="{a.class}">{a.value:nl2br}</span> </li> {*if:getAttributeGroup()*} </ul> </li> {end:}

and then you should see the template text markers, but not the ungrouped attributes

http://www.signtorch.com/bin/xcart/attribute-group2.jpg

if you do not see the text markers, then the custom template may not be at the correct path and filename

and make sure the custom skins module is enabled
__________________
SignTorch Vector Graphics
dropping xc4.6.x, tested xc5 (FAIL)
Reply With Quote
  #14  
Old 11-19-2014, 06:40 PM
 
minfinger minfinger is offline
 

X-Adept
  
Join Date: Apr 2009
Posts: 678
 

Default Re: Remove attributes with multiple values from Specification Tab?

My apologies. Mine are grouped.
__________________
X-Cart 4.3
Joomla
Among other things
Reply With Quote
  #15  
Old 11-20-2014, 12:56 AM
 
SignTorch SignTorch is offline
 

Advanced Member
  
Join Date: Jun 2010
Posts: 30
 

Default Re: Remove attributes with multiple values from Specification Tab?

Quote:
Originally Posted by minfinger
My apologies. Mine are grouped.

ok, here's a down and dirty way to hide individual attributes based on hard-coded name values

if you need to hide a whole group, title and all, that would be different

in attribute.tpl shown above, add an inline style on the <li tag

Code:
{if:getAttributeGroup()} <li><div class="head-h3">{getTitle()}</div> <ul> {end:} <li FOREACH="getAttrList(),a" style="display:{a.hidden}"> <div><strong>{a.name}</strong></div> <span class="{a.class}">{a.value:nl2br}</span> </li> {if:getAttributeGroup()} </ul> </li> {end:}

then put the following code block in a new file

classes\XLite\Module\XC\CustomSkin\View\Product\De tails\Customer\Attributes.php

the code shown hides two of the attributes shown in my screenshots above

adjust the blue text values and number of if statements to match the name and number of attributes you want to hide

the two red statements are what I added to the original Attributes class

Code:
<?php namespace XLite\Module\XC\CustomSkin\View\Product\Details\Customer; function isHidden($a) { if($a=="Number of Designs")return("none"); if($a=="Number of Categories")return("none"); return "block"; } abstract class Attributes extends \XLite\View\Product\Details\Customer\Attributes implements \XLite\Base\IDecorator { public function getAttrList() { if (!isset($this->attributes)) { $this->attributes = array(); foreach ($this->getAttributesList() as $a) { $value = $a->getAttributeValue($this->getProduct(), true); $hidden = isHidden($a->getName()); if (is_array($value)) { $value = implode($a::DELIMITER, $value); } if ( $value && ( $a::TYPE_CHECKBOX != $a->getType() || static::t('No') != $value ) ) { $this->attributes[] = array( 'name' => $a->getName(), 'value' => htmlspecialchars($value), 'class' => $this->getFieldClass($a, $value), 'hidden' => $hidden ); } } } return $this->attributes; } }
__________________
SignTorch Vector Graphics
dropping xc4.6.x, tested xc5 (FAIL)
Reply With Quote

The following user thanks SignTorch for this useful post:
tony_sologubov (11-24-2014)
  #16  
Old 12-04-2014, 04:32 PM
 
minfinger minfinger is offline
 

X-Adept
  
Join Date: Apr 2009
Posts: 678
 

Default Re: Remove attributes with multiple values from Specification Tab?

I need to know how to get rid Specifications tab all together. My client just said kill it.
__________________
X-Cart 4.3
Joomla
Among other things
Reply With Quote
  #17  
Old 12-04-2014, 11:25 PM
 
SignTorch SignTorch is offline
 

Advanced Member
  
Join Date: Jun 2010
Posts: 30
 

Default Re: Remove attributes with multiple values from Specification Tab?

you could remove all product attributes

-------

or to hide all tabs and tab content, put this in custom.css (then description uses full container width)

.product-details-tabs .tabs {display:none;}

--------

or an easy way to selectively remove the specifications tab, run this SQL

UPDATE xc_products SET attrSepTab = 0;

then copy

skins/default/en/product/details/parts/common.product-main-attributes.tpl

to custom_skin and comment out the {*<ul> ... </ul>*} tags

that hides the attributes and any group titles on any products where attrSepTab is 0

that way you could show the specifications tab on some products by setting attrSepTabs to not 0 on certain products

---------

to just globally hide the specs tab you could decorate getTabs() in

classes/XLite/View/Product/Details/Customer/Page/APage.php

with something like this (untested)

Code:
if($id!="specification") $list[$k] = array( 'index' => $i, 'id' => 'product-details-tab-' . $id, 'name' => is_array($data) && !empty($data['name']) ? $data['name'] : $k, 'weight' => isset($data['weight']) ? $data['weight'] : $i, );
__________________
SignTorch Vector Graphics
dropping xc4.6.x, tested xc5 (FAIL)
Reply With Quote

The following user thanks SignTorch for this useful post:
tony_sologubov (12-05-2014)
  #18  
Old 03-17-2016, 02:05 AM
 
xgarb xgarb is online now
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: Remove attributes with multiple values from Specification Tab?

Another approach...

You can remove the tab and replace it with a tab of your own content from the Product object like this:

Code:
abstract class DefineTabShowSpecification extends \XLite\View\Product\Details\Customer\Page\APage implements \XLite\Base\IDecorator { protected function defineTabs() { $list = parent::defineTabs(); unset($list['Specification']); //remove default X-cart specification $tmp = $this->getSpec(); if (!empty($tmp)) { //if the spec field has data... $list['Specification'] = array( 'list' => 'product.details.page.tab.detailed_spec', //... show it in the specification tab ); } return $list; } protected function getSpec(){ return $this->getProduct()->specification; } }

(also need in skins/default/en/module/DEV-ID/MODULE-NAME/ folder

Code:
{** * Product details spec tab * * * @ListChild(list="product.details.page.tab.detailed_spec") *} {product.specification:h}
)


In this case the client wants to add text and images into the Specification tab. I'd previously added this to the Product Info section in admin so product_translations in the database contains a specification column. The code above display the data from this column.
__________________
Core version: 5.5.xx
Reply With Quote

The following user thanks xgarb for this useful post:
qualiteam (03-17-2016)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:01 AM.

   

 
X-Cart forums © 2001-2020