0

这段代码在这里....(查看页脚订阅部分)

<?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"

我想将这三个部分按钮命名为 6month,12month,24month

将如何更改代码?

4

1 回答 1

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的名称

于 2013-05-31T07:26:07.610 回答