Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Need help with PHP

  • 10-10-2010 05:26PM
    #1
    Registered Users, Registered Users 2 Posts: 55 ✭✭


    I've been trying to sort this our now for a few weeks and would appreciate any help I can get.

    Here's a link to my temporary Magento installation:
    http://gadgetgeek.xz3.org/magento/magento/

    Have a look at Featured Items at the bottom of the homepage. The first two items aren't clickable for some reason, yet they are hyperlinked and the HTML shows them as hyperlinked. Can anyone explain why this is the case?

    Here is the code that deals with this:
    <?php
        $_productCollection=$this->getLoadedProductCollection();
        $_helper = $this->helper('catalog/output');
    ?>
    <?php if(!$_productCollection->count()): ?>
    <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php else: ?>
    <div class="category-products">
       
    
        <?php // Grid Mode ?>
    
        <?php $_collectionSize = $_productCollection->count() ?>
        <?php $_columnCount = $this->getColumnCount(); ?>
        <?php $i=0; foreach ($_productCollection as $_product): ?>
            <?php if ($i++%$_columnCount==0): ?>
            <ul class="products-grid">
            <?php endif ?>
                        <?php if($_product->isSaleable()): ?>
                <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
                    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
              
                    <?php echo $this->getPriceHtml($_product, true) ?>
                    <div class="actions">
    
                            <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
       
    
         
                    </div>
                </li>
                        <?php endif; ?>
            <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
            </ul>
            <?php endif ?>
            <?php endforeach ?>
            <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
        <?php endif; ?>
    
    </div>
    


Comments

  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    not a php person but looking at the source code of the rendered page there seems to be something funky going on with the [PHP] <ul class="products-grid">
    [/PHP] on the page


  • Registered Users, Registered Users 2 Posts: 339 ✭✭duffman85


    The closing </ul> is missing before the second products grid <ul> in the generated HTML

    <ul class="products-grid">

    Magento seems to be generating the next <ul class="products-grid"> before it has closed the first one.
    Have a look at how the PHP is generating the <ul> elements.


  • Registered Users, Registered Users 2 Posts: 55 ✭✭Maxpv


    Hmm.. I wonder why its doing that, I'll have to have a proper look at it tomorrow.

    Actually, this shouldn't affect the hyperlink, should it? I think this is a separate issue.


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Blazr wrote: »
    Hmm.. I wonder why its doing that, I'll have to have a proper look at it tomorrow.

    Actually, this shouldn't affect the hyperlink, should it? I think this is a separate issue.

    Yes it will - you have a CSS element (probably the UL) that is masking your link. Try Firefox and (Menu) View -> Page Style -> No Style. You'll see the links are perfectly "clickable"


Advertisement