2012-07-17 6 views

cevap

12

Blok görünümü komut dosyasında, /wishlist/'a bir bağlantı ekleyen aşağıdakileri ekledim.

<a href="<?php echo $this->getUrl('wishlist') ?>">Wishlist</a> 
0

'Mage_Page_Block_Template_Links' sınıfına göz atmak isteyebilirsiniz. aşağıdaki yöntemi görebilirsiniz Bu sınıfta :

public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(), 
    $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='') 
{ 
    if (is_null($label) || false===$label) { 
     return $this; 
    } 
    $link = new Varien_Object(array(
     'label'   => $label, 
     'url'   => ($prepare ? $this->getUrl($url, (is_array($urlParams) ? $urlParams : array())) : $url), 
     'title'   => $title, 
     'li_params'  => $this->_prepareParams($liParams), 
     'a_params'  => $this->_prepareParams($aParams), 
     'before_text' => $beforeText, 
     'after_text' => $afterText, 
    )); 

    $this->_links[$this->_getNewPosition($position)] = $link; 
    if (intval($position) > 0) { 
     ksort($this->_links); 
    } 

    return $this; 
} 

bu korumalı değişken $ _link bir bağlantı eklemek için işlevidir; Daha sonra bu bağlantı şablonunuz tarafından bir foreach döngüsü ile yazılacaktır.

Sen ile bu değişkenin değer alabilir: Dosya örneğin

public function getLinks() 
    { 
     return $this->_links; 
    } 

; Sonra sayfa/şablon/links.phtml

<?php $_links = $this->getLinks(); ?> 
<?php if(count($_links)>0): ?> 
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>> 
    <?php foreach($_links as $_link): ?> 
     <?php if ($_link instanceof Mage_Core_Block_Abstract):?> 
      <?php echo $_link->toHtml() ?> 
     <?php else: ?> 
      <li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?></li> 
     <?php endif;?> 
    <?php endforeach; ?> 
</ul> 
<?php endif; ?> 

, yeni bir fonksiyon oluşturabilir Özel bloğunuz için veya bu bloğu genişletebilir ve removeLinkByUrl ve addLink işlevlerini kullanabilirsiniz.

+0

İstek listesi bağlantısını zaten kaldırdım. Başka bir bloğa eklemek istiyorum –