0

I am trying to space out the line of footer links that are not in the Admin>CMS>Static Block (Site Map, Advanced Search, Search Terms....) on this site: http://silversalesusa.com/magento and I cannot get it to work. Can't even find where these labels are stored so that I can add a few spaces and a | to separate them. Either would work. Any ideas? (See my update below...)

EDIT OK. Something I did worked somewhat. I have the | character between all except the last two and there is one at the end which doesn't need to be there. Why is the | missing after Orders and Returns? Here's the code:

    <?php $_links = $this->getLinks(); ?>
    <?php if(count($_links)>0): ?>
    <?php ksort($_links); ?>
    <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 '  |' ?><?php echo $_link->getAfterText() ?></li>
            <?php endif;?>
        <?php endforeach; ?>
    </ul>
    <?php endif; ?>

2 Answers 2

1

Here is a modified version (untested) of your version of the links.phtml file. It fixes a few syntax errors and adds in the logic for not adding a '|' after the last link. After changing the file you may need to clear your Magento caches to see the update.

<?php $_links = $this->getLinks(); ?>
<?php if(count($_links)>0): ?>
<?php ksort($_links); ?>
<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 if($_link->getIsLast()): ?> last<?php else: echo '  |'; endif; ?>
            <?php echo $_link->getAfterText() ?>
        </li>
    <?php endif;?>
<?php endforeach; ?>
</ul>
<?php endif; ?>

Edited Answer

This will probably just be easier to solve with CSS. So return your links.phtml to its original code (if its version 1.9 this is the code, if not then you can look in base/default for original code)

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

Then in your CSS file add these styles:

.footer .links li:after {
content: '|';
padding-left: 5px;
padding-right: 5px;
}
.footer .links li.last:after {
content: '';
}
3
  • Thank you Jason. I tried this and ended up with two separators at the beginning, still not one between the last two, and the word last at the end...
    – SonshineTN
    Feb 18, 2015 at 23:55
  • Tried to edit my comment but it was over five minutes so sorry for the second post. I found where I had added the | to one of the labels in another file so that got rid of the two separators together. I took out the word last from your code and that took care of that issue. Still can't figure out why there is no separator between Orders and Returns and Contact Us...
    – SonshineTN
    Feb 19, 2015 at 0:22
  • I've updated the answer to an easier solution. Its more of a CSS solution than Magento but will get you the results you're looking for. Feb 19, 2015 at 0:24
1

Is better do this by CSS

.links li { padding: 0 5px; }

2
  • Tried that and couldn't get it to work...
    – SonshineTN
    Feb 18, 2015 at 23:56
  • I did and work, you most use chrome tools like this link Feb 19, 2015 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.