Jump to content


Marcos Coelho

Member Since 28/07/2009
Offline Last Active 01/03/2013, 18:16
-----

Topics I've Started

Mudar Carregamento Em Javascript

01/03/2013, 12:01

Olá pessoal,



Estou com um problemaço e espero que vocês possam me ajudar.



Tenho pouquissima experiencia em javascript e preciso de mudar o carregamento em uma pagina.

Deixa eu explicar melhor.

Entrem no link: https://pacoesportes...esult/?q=a&cat=

Nos produtos tem uma imagem de configuração de cor depois de você clicar na cor aparece a configuração do tamanho.

A troca de imagens do produto só é feita depois que seleciono o tamanho mas eu preciso que o produto já no primeiro clique na cor.

Link do meu javascript: http://pacoesportes....igurableList.js



Se você entrar nesse link vai ver como quero q aconteça.

https://pacoesportes...a-principal.jsp

(clique na cor e o produto ja mudará)

Não sei se ajuda mas vou passar o link do javascript dessa pagina que funciona da forma que eu quero que a outra funcione tmb.

http://pacoesportes....configurable.js









Sei que eh muita informação pra um tópico só mas qualquer duvida postem que esclarecerei.







Espero que possam me ajudar com algo pois ja tentei bastante coisa e ainda nao consegui nada

Creio que esteja nessa parte do codigo meu problema




Product.Config.prototype.selectImage = function(element)
{
    attributeId = element.parentNode.id.replace(/[a-z-]*/, '');
    $('amconf-images-' + attributeId).childElements().each(function(child){
        child.removeClassName('amconf-image-selected');
    });
    element.addClassName('amconf-image-selected');
    
    var pos = attributeId.indexOf('-');
    if ('-1' != pos) {
          var optionId = attributeId.substring(0, pos);
          var parentId = attributeId.substring(pos+1, attributeId.length);
          var elId = element.id.replace(/[a-z-]*/, '');
          pos = elId.indexOf('-');
          elId = elId.substring(0, pos);
          var key = '';
          this.settings.each(function(select){
                // will check if we need to reload product information when the first attribute selected
                if (!select.value && 'undefined' != typeof(confData[parentId]) && confData[parentId].oneAttributeReload && "undefined" != select.options[1])
                {
                    key += select.options[1].value + ',';
                } else
                {
                    if( parseInt(select.value) > 0)
                            key += select.value + ',';
                }
          });
          key = key.substr(0, key.length - 1);
      
          if(confData[parentId]['optionProducts'][key]){
        var parUrl = confData[parentId]['optionProducts'][key]['parent_image'];
          var possl = parUrl.lastIndexOf('/');
             $$('.product-image img').each(function(img){
                  if(img.src.substr(possl, img.src.length) == parUrl.substr(possl, parUrl.length) || img.className == ('amconf-parent-'+parentId)){
                      img.src = confData[parentId]['optionProducts'][key]['small_image'];
                      img.addClassName('amconf-parent-'+parentId);
                  }
             });              
          }
    }  
}



Vou postar tmb da minha outra página que já funciona da forma que eu quero talvez ajude.

Creio que pode ser uma pequena diferença entre os dois.




Product.Config.prototype.configureElement = function(element)
{
    // extension Code
    optionId = element.value;
    if ($('amconf-image-' + optionId))
    {
        this.selectImage($('amconf-image-' + optionId));
    } else
    {
        attributeId = element.id.replace(/[a-z-]*/, '');
        if ($('amconf-images-' + attributeId))
        {
        $('amconf-images-' + attributeId).childElements().each(function(child){
            child.removeClassName('amconf-image-selected');
        });
        }
    }
    // extension Code End
    
    this.reloadOptionLabels(element);
    if(element.value){
        this.state[element.config.id] = element.value;
        if(element.nextSetting){
            element.nextSetting.disabled = false;
            this.fillSelect(element.nextSetting);
            this.resetChildren(element.nextSetting);
        }
    }
    else {
        // extension Code
        if(element.childSettings) {
            for(var i=0;i<element.childSettings.length;i++){
                attributeId = element.childSettings[i].id.replace(/[a-z-]*/, '');
                if ($('amconf-images-' + attributeId))
                {
                    $('amconf-images-' + attributeId).parentNode.removeChild($('amconf-images-' + attributeId));
                }
            }
        }
        // extension Code End
        
        this.resetChildren(element);
        
        // extension Code
        if (this.settings[0].hasClassName('no-display'))
        {
            this.processEmpty();
        }
        // extension Code End
    }
    this.reloadPrice();
    
    // extension Code
    var key = '';
    this.settings.each(function(select){
        // will check if we need to reload product information when the first attribute selected
        if (!select.value && 'undefined' != typeof(confData) && confData.oneAttributeReload && undefined != select.options[1] && !confData.isResetButton)
        {
            // if option is not selected, and setting is set to "Yes", will consider it as if the first attribute was selected (0 - is "Choose ...")
            key += select.options[1].value + ',';
        } else
        {
            key += select.value + ',';
        }
    });


Personalizar Menu Loja Magento

06/05/2012, 20:24

Olá galera, estou personalizando o menu lateral do meu site e preciso de ajuda com códigos em php
o link é o seguninte: http://pacoesportes.com/
o que eu estou mexendo é o menu lateral esquerdo que está com um botão em rosa por favor ignorem o resto
se vocês olharem ele fica somente com as categorias e as subcategorias tem que clicar para que elas apareçam.
(clicando na setinha da primeira categoria do meu se abre a subcategoria do mesmo.

O que eu quero é o que meu menu mostre as subcategorias que são os children do código que vou passar sem que eu precise clicar na setinha para que abra a mesma.
Após conseguir o que citei acima quero também que busque apenas as 5 primeiras subcategorias (children) e que fique escrito abaixo caso tenha mais de 5 subcategorias "mais subcategorias..." e ao clicar abra o restante das subcategorias.

Vou postar o original código completo que quero alterar.

<?php

class Codnitive_Sidenav_Block_Navigation extends Mage_Catalog_Block_Navigation

{

/**

* Extension config model object

*

*/

protected $_config;



/**

* Construct parent and define $_config

*

*/

protected function _construct()

{

parent::_construct();

$this->_config = Mage::getModel('sidenav/config');

}



/**

* Get store categories navigation menu

*

* @return string

*/

public function getCategoriesNavMenu()

{

$navigationMenu = $this->renderCategoriesMenuHtml(0);

return $navigationMenu ? $navigationMenu : false;

}



/**

* Get catagories of current store

*

* @return Varien_Data_Tree_Node_Collection

*/

public function getStoreCategories()

{

return Mage::helper('sidenav/category')->getStoreCategories();

}



/**

* Render category to html

*

* @param Mage_Catalog_Model_Category $category

* @param int Nesting level number

* @param boolean Whether ot not this item is last, affects list item class

* @param boolean Whether ot not this item is first, affects list item class

* @param boolean Whether ot not this item is outermost, affects list item class

* @param string Extra class of outermost list items

* @param string If specified wraps children list in div with this class

* @param boolean Whether ot not to add on* attributes to list item

* @return string

*/

protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,

$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)

{

if (!$category->getIsActive()) {

return '';

}

$html = array();

$js = null;

$expanded = null;

$ulThumb = '';

$image = '';

$thumb = '';

$htmlLi = '';



// get all children

if (Mage::helper('catalog/category_flat')->isEnabled()) {

$children = (array)$category->getChildrenNodes();

$childrenCount = count($children);

} else {

$children = $category->getChildren();

$childrenCount = $children->count();

}

$hasChildren = ($children && $childrenCount);



// select active children

$activeChildren = array();

foreach ($children as $child) {

if ($child->getIsActive()) {

$activeChildren[] = $child;

}

}

$activeChildrenCount = count($activeChildren);

$hasActiveChildren = ($activeChildrenCount > 0);



// prepare list item html classes

$classes = array();

$classes[] = 'level' . $level;

$classes[] = 'nav-' . $this->_getItemPosition($level);

if ($this->isCategoryActive($category)) {

$classes[] = 'active';

}

$linkClass = '';

if ($isOutermost && $outermostItemClass) {

$classes[] = $outermostItemClass;

$linkClass = ' class="'.$outermostItemClass.'"';

}

if ($isFirst) {

$classes[] = 'first';

}

if ($isLast) {

$classes[] = 'last';

}

if ($hasActiveChildren) {

$classes[] = 'parent';

}



// prepare list item attributes

$attributes = array();

if (count($classes) > 0) {

$attributes['class'] = implode(' ', $classes);

}

if ($hasActiveChildren && !$noEventAttributes) {

$attributes['onmouseover'] = 'toggleMenu(this,1)';

$attributes['onmouseout'] = 'toggleMenu(this,0)';

}



// assemble list item with attributes

$config = Mage::getModel('sidenav/config');

$thumbWidth = 14;

$thumbHeight = 14;

$liMarginLeft = 0;

$ulMarginLeft = 5;

$ulPaddingLeft = 10;



// define image thumbnail variables

if ($config->getThumbImageActive()) {

if ($config->getThumbSize()) {

$thumbWidth = $config->getThumbWidth();

$thumbHeight = $config->getThumbHeight();

}

$thumbnail = $config->load($category->getId())->getThumbnailImageUrl();

$ulThumb = ' ul-thumb';

if (!empty($thumbnail)) {

$image = '<img src="'.$thumbnail.'" style= "width:'.$thumbWidth.'px; height:'.$thumbHeight.'px; float: left;" />';

$thumb = ' thumb';

if ($config->getCollapsible() && $config->getThumbImageActive()) {

$liMarginLeft = $thumbWidth + 3;

$ulMarginLeft = 0;

}

else {

$liMarginLeft = 0;

$ulMarginLeft = $thumbWidth + 3;

}

$ulPaddingLeft = 0;

}

else {

$thumb = ' no-thumb';

$liMarginLeft = $thumbWidth + 3;

$ulMarginLeft = 0;

$ulPaddingLeft = 0;

}

}



$htmlLi .= '<li';

foreach ($attributes as $attrName => $attrValue) {

$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . $thumb . '"';

}

$htmlLi .= ' style="margin-left: ' . $liMarginLeft . 'px;">';

$html[] = $htmlLi;



// add collapsible arrow and wrraper

if ($config->getCollapsible()) {

$width = 8;

$height = 0;

$expanded = 0;

if ($hasActiveChildren) {

$width = 8;

$height = 10;

}

if ($this->isCategoryActive($category)) {

$expanded = 1;

}

$html[] = '<span class="arrow" onClick="expandMenu(this.parentNode)"

style="width: ' . $width . 'px; height: ' . $height . 'px;"></span>';

}



// add thumbnail image

$html[] = $image;



// add wrapper

if ($config->getCollapsible() || $config->getThumbImageActive()) {

$wrapperMargin = $config->getCollapsible() ? 14 : 0;

/*if ($config->getThumbImageActive()) {

$extraMargin = !empty($thumbnail) ? $thumbWidth + 3 : 0;

}*/

$extraMargin = !$config->getThumbImageActive() ? 0 : !empty($thumbnail) ? $thumbWidth + 3 : 0;

$collWrapper = $wrapperMargin + $extraMargin;

$html[] = '<div class="collapsible-wrapper" style="margin-left: ' . $collWrapper . 'px;">';

}



$html[] = '<a href="' . $this->getCategoryUrl($category) . '"'

. $linkClass.'><span class="category_name">'

. $this->escapeHtml($category->getName()) . '</span></a>';

// $html[] = '<span class="category_name">' . $this->escapeHtml($category->getName()) . '</span></a>';

// $html[] = '</a>';



// add product count

if ($config->getShowProductCount()) {

$count = Mage::getModel('catalog/layer')

->setCurrentCategory($category->getID())

->getProductCollection()

->getSize();

if (($config->removeZeroCount() && $count > 0) || !$config->removeZeroCount()) {

$html[] = '<span class="product-count">(' . $count . ')</span>';

}

}



// close wrapper

if ($config->getCollapsible() || $config->getThumbImageActive()) {

$html[] = '</div>';

}



// render children

$htmlChildren = '';

$j = 0;

foreach ($activeChildren as $child) {

$htmlChildren .= $this->_renderCategoryMenuItemHtml(

$child,

($level + 1),

($j == $activeChildrenCount - 1),

($j == 0),

false,

$outermostItemClass,

$childrenWrapClass,

$noEventAttributes

);

$j++;

}

if (!empty($htmlChildren)) {

if ($childrenWrapClass) {

$html[] = '<div class="' . $childrenWrapClass . '">';

}

$html[] = '<ul class="level' . $level . $ulThumb .

'" style="margin-left: ' . $ulMarginLeft .

'px; padding-left: ' . $ulPaddingLeft . 'px;" expanded="' . $expanded . '">';

$html[] = $htmlChildren;

$html[] = '</ul>';

if ($childrenWrapClass) {

$html[] = '</div>';

}

}



$html[] = '</li>';



$html = implode("\n", $html);

return $html;

}



/**

* Render categories menu in HTML

*

* @param int Level number for list item class to start from

* @param string Extra class of outermost list items

* @param string If specified wraps children list in div with this class

* @return string

*/

public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')

{

$activeCategories = array();

foreach ($this->getStoreCategories() as $child) {

if ($child->getIsActive()) {

$activeCategories[] = $child;

}

}

$activeCategoriesCount = count($activeCategories);

$hasActiveCategoriesCount = ($activeCategoriesCount > 0);



if (!$hasActiveCategoriesCount) {

return '';

}



$html = '';

$j = 0;

foreach ($activeCategories as $category) {

$html .= $this->_renderCategoryMenuItemHtml(

$category,

$level,

($j == $activeCategoriesCount - 1),

($j == 0),

true,

$outermostItemClass,

$childrenWrapClass,

true

);

$j++;

}



return $html;

}



/**

* Get extension enable status

*

* @deprecated after 1.7.20

* We don't need to check for module activation option

* in template, we check it in layout.

*

* @return boolean

*/

public function getCheckActive()

{

return $this->_config->checkActive();

}



/**

* Get selected column

*

* @deprecated after 1.7.20

* We don't need to check for selected column option

* in template, we check it in layout.

*

* @return string

*/

public function getColumn()

{

return $this->_config->getColumnValue();

}



/**

* Get category title

*

* @return string

*/

public function getTitle()

{

return $this->_config->setTitle();

}



}





Espero que possam me ajudar

A parte de mostrar o subcategoriaeu já consegui
agora preciso de ajuda para se contar mais doq 5 subcategorias mostre um link "mais subcategorias..."

IPB Skin By Virteq