View Single Post
  #7  
Old 04-07-2014, 03:23 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Custom Product Tabs

Hi Mark!

I am sorry for my late reply! Just got slammed by work.

First of all, this is great that you created the mod and created view lists for both sections: Extended Spec and Where used.

You need two more steps in order to complete your work.
1) Create the method that will return only attributes you need. This is how you can do it.

Add the following method to your View/Product/Details/Customer/Page/APage.php script:

PHP Code:
protected function getExtendedSpecAttributes()
    {
        
$attributesToDisplay = array ('COLOR');

        
$return = array();

        
$widgets $this->getAttributesWidgets();

        foreach (
$widgets as $widget) {

            foreach (
$widget->getAttrList() as $attribute) {

                if (
in_array(strtoupper($attribute['name']), $attributesToDisplay)) {

                    
$return[] = $attribute;

                }

            }

        }

        return 
$return;
    } 

This method is quite straight-forward. It pulls all attribute widgets and walk through each attribute checking whether this attribute is color. If it is, then it will be put into the output array $return.

Of course, you can define your own if() condition in this case.

The result of this step is that we have a method for template that will output only needed attributes, not all of them.

2) After the method is ready, you should edit your extended_spec.tpl template and define it like this (for example):

Code:
{** * @ListChild(list="product.details.page.tab.extended_spec") *} <ul class="extra-fields"> {foreach:getExtendedSpecAttributes(),a} <li><div><strong>{a.name}</strong></div> <span class="{a.class}">{a.value:nl2br}</span></li> {end:} </ul>

This template takes our method, walks through needed attributes and displays them. Of course, the template implementation may vary depending on your needs.

Please, let me know if it makes sense to you.

Tony.
Reply With Quote