I want to take the below code from com_content/article/default.php (line 91-94):

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

And call it in the module mod_articles_category so I can have the custom link appear under each article.

I found a similar solution on this thread: How to add article image to module mod_article_categories?

But it's for images. I'm not sure how to load the links.


2 Answers 2


Create an override for the module in templates/your_template/html/mod_articles_category/default.php

Add to the line 20 and 84 after li tag:

    $params  = $item->params;
    $urls = json_encode($item->urls);
    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')))) :

        if ($urls && (!empty($urls->urla) || !empty($urls->urlb) || !empty($urls->urlc))) :
        <div class="content-links">
            <ul class="nav nav-tabs nav-stacked">
                    $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) :

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

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

                            switch ($target)
                                case 1:
                                    // Open in a new window
                                    echo '<a href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '" target="_blank" rel="nofollow noopener noreferrer">' .
                                        htmlspecialchars($label, ENT_COMPAT, 'UTF-8') . '</a>';

                                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, ENT_COMPAT, 'UTF-8') . "\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\" rel=\"noopener noreferrer\">" .
                                        htmlspecialchars($label, ENT_COMPAT, 'UTF-8') . '</a>';
                                case 3:
                                    // Open in a modal window
                                    JHtml::_('behavior.modal', 'a.modal');
                                    echo '<a class="modal" href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '"  rel="{handler: \'iframe\', size: {x:600, y:600}} noopener noreferrer">' .
                                        htmlspecialchars($label, ENT_COMPAT, 'UTF-8') . ' </a>';

                                    // Open in parent window
                                    echo '<a href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '" rel="nofollow">' .
                                        htmlspecialchars($label, ENT_COMPAT, 'UTF-8') . ' </a>';
                <?php endforeach; ?>
    <?php endif; ?>
<?php endif; ?>

I currently don't have a fresh image of the mod_articles_category and how it's coded - and I don't have the time to review it right now.

In any case, in order to have this additional data (custom links) of the articles in the module's output (template), this data must become available from the "model" part of the module - the one that fetches the data of the articles from the database.

This is usually handled within the modules' helper files. This is where you have to look to see if in it's data call the custom links are included and this is the place where a such call should be done.

If those extra data aren't included, then there is not an easy way to override this - but you can easily create a clone of that module (a customized version of the same module) where you can create your own helper.

Read here for How to develop a Joomla module?

Your Answer

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

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