2

I would like to include the article Links (as set in the Images and Links tab) below the intro text shown in the blog layout, above or below the 'Read more' link.

I've tried including this from the article default.php but it doesn't work, maybe something's missing or it's completely wrong:

<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position)))
        || (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>

Can anyone tell me how to do this?

I know how to tinker around with the content layouts and have created an override for the blog_item.php file but I am not a php expert.

Any help would be greatly appreciated.

Many thanks Leila

1 Answer 1

3

Add the following code to your blog_item.php override file where you want the links to show up:

<?php 
$urls    = json_decode($this->item->urls); // Create shortcut
if ($urls && (!empty($urls->urla) || !empty($urls->urlb) || !empty($urls->urlc))) :
?>
<div class="content-links">
    <ul class="nav nav-tabs nav-stacked">
        <?php
            $urlarray = array(
            array($urls->urla, $urls->urlatext, $urls->targeta, 'a'),
            array($urls->urlb, $urls->urlbtext, $urls->targetb, 'b'),
            array($urls->urlc, $urls->urlctext, $urls->targetc, 'c')
            );
            foreach ($urlarray as $url) :
                $link = $url[0];
                $label = $url[1];
                $target = $url[2];
                $id = $url[3];

                if ( ! $link) :
                    continue;
                endif;

                // If no label is present, take the link
                $label = ($label) ? $label : $link;

                // If no target is present, use the default
                $target = $target ? $target : $params->get('target'.$id);
                ?>
            <li class="content-links-<?php echo $id; ?>">
                <?php
                    // Compute the correct link

                    switch ($target)
                    {
                        case 1:
                            // open in a new window
                            echo '<a href="'. htmlspecialchars($link) .'" target="_blank"  rel="nofollow">'.
                                htmlspecialchars($label) .'</a>';
                            break;

                        case 2:
                            // open in a popup window
                            $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=600';
                            echo "<a href=\"" . htmlspecialchars($link) . "\" onclick=\"window.open(this.href, 'targetWindow', '".$attribs."'); return false;\">".
                                htmlspecialchars($label).'</a>';
                            break;
                        case 3:
                            // open in a modal window
                            JHtml::_('behavior.modal', 'a.modal'); ?>
                            <a class="modal" href="<?php echo htmlspecialchars($link); ?>"  rel="{handler: 'iframe', size: {x:600, y:600}}">
                                <?php echo htmlspecialchars($label) . ' </a>';
                            break;

                        default:
                            // open in parent window
                            echo '<a href="'.  htmlspecialchars($link) . '" rel="nofollow">'.
                                htmlspecialchars($label) . ' </a>';
                            break;
                    }
                ?>
                </li>
        <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>

(I copied this code from components\com_content\views\article\tmpl\default_links.php.)

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.