2012-09-20 254 views
0

這段代碼放出來是here ....(看頁腳認購部分)如何更改按鈕的名稱

<?php if(!empty($this->items))foreach($this->items as $level): ?> 
<?php 
    $formatedPrice = sprintf('%1.02f',$level->price); 
    $dotpos = strpos($formatedPrice, '.'); 
    $price_integer = substr($formatedPrice,0,$dotpos); 
    $price_fractional = substr($formatedPrice,$dotpos+1); 
?> 
    <div class="level akeebasubs-level-<?php echo $level->akeebasubs_level_id ?>"> 
     <p class="level-title"> 
      <span class="level-price"> 
       <?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'before'): ?> 
       <span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span> 
       <?php endif; ?> 
       <span class="level-price-integer"><?php echo $price_integer ?></span><?php if((int)$price_fractional > 0): ?><span class="level-price-separator">.</span><span class="level-price-decimal"><?php echo $price_fractional ?></span><?php endif; ?> 
       <?php if(AkeebasubsHelperCparams::getParam('currencypos','before') == 'after'): ?> 
       <span class="level-price-currency"><?php echo AkeebasubsHelperCparams::getParam('currencysymbol','€')?></span> 
       <?php endif; ?> 
      </span> 
      <span class="level-title-text"> 
       <a href="<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>"> 
        <?php echo $this->escape($level->title)?> 
       </a> 
      </span> 
     </p> 
     <div class="level-inner"> 
      <div class="level-description"> 
       <div class="level-description-inner"> 
        <?php if(!empty($level->image)):?> 
        <img class="level-image" src="<?php echo JURI::base()?><?php echo trim(AkeebasubsHelperCparams::getParam('imagedir','images/'),'/') ?>/<?php echo $level->image?>" /> 
        <?php endif;?> 
        <?php echo JHTML::_('content.prepare', AkeebasubsHelperMessage::processLanguage($level->description));?> 
       </div> 
      </div> 
      <div class="level-clear"></div> 
      <div > 
       <button onclick="window.location='<?php echo JRoute::_('index.php?option=com_akeebasubs&view=level&slug='.$level->slug.'&format=html&layout=default')?>'"> 
        <?php echo JText::_('COM_AKEEBASUBS_LEVELS_SUBSCRIBE')?> 
       </button> 
      </div> 
     </div> 
    </div> 
<?php endforeach; ?> 

這是語言文件包含該名稱

COM_AKEEBASUBS_LEVELS_SUBSCRIBE="Subscribe Now" 

我想要命名這三個部分按鈕爲6個月,12個月,24個月

如何更改代碼?

+0

你爲什麼不把它改成'$ level-> title'?不一樣嗎? – timidboy

+0

從您網站的外觀來看,您似乎已經解決了這個問題。你是否? –

回答

1

如果無法獲得使用PHP的價值,嘗試在頁面加載 這裏更改按鈕的名稱的值是JQUERY

$(document).ready(function){ 
    $('div.akeebasubs-awesome-description').each(function(
    substription = $(this).children('H4').html() 
    button = $(this).parent().next().children('button') 
    $(button).attr(name,substription.split(' ')[0]+'month') 
    }) 
}) 

JAVASCRIPT

divs = document.getElementsByClassName('akeebasubs-awesome-description'); 
for (var i in divs){ 
    divs[i].parentElement.nextElementSibling.children[0].name = divs[i].children[0].innerHTML.split(' ')[0] + 'month' 
} 

這將採用H4的文本並使相應的button的名稱爲