1

I am using the module Articles - Newsflash to show a category of mine, which works just as intended.

Now I can see all intro images of the selected articles and also some corresponding text.

Clicking on the titles of the articles sends me to the full article, but I would like to change that.

Instead, I would like to use the Link A field of each article to define where the user is sent upon clicking the article title.

I found some threads such as: https://stackoverflow.com/questions/24350538/linking-intro-image-in-joomla-3-3-1

https://forum.joomla.org/viewtopic.php?t=926779

Those threads seem to go in the right direction, but I am not experienced enough to manage it on my own.

0

1 Answer 1

2

I found the file I needed to create an override of and edited the neccesary files accordingly. Thats what I did:

In file /html/mod_articles_news_adv/_item.php

<figure class="item_img img-intro img-intro__<?php echo htmlspecialchars($imgfloat); ?>"> 
<?php if (isset($urls) && (!empty($urls->urla) )) :
        $articleLinkAUrl = $urls->urla;
        endif;?>
    <?php if ($params->get('link_titles') && $item->readmore) : ?>
    <a href="<?php echo $articleLinkAUrl;?>">
    <?php endif; ?>
        <img src="<?php echo htmlspecialchars($item_images->image_intro); ?>" alt="<?php echo htmlspecialchars($item_images->image_intro_alt); ?>">
        <?php if ($item_images->image_intro_caption): ?>
        <figcaption><?php echo htmlspecialchars($item_images->image_intro_caption); ?></figcaption>
        <?php endif;
    if ($params->get('link_titles') && $item->readmore) : ?>
    </a>
    <?php endif; ?>
</figure>

This part gets the Link A Url in php:

<?php if (isset($urls) && (!empty($urls->urla) )) :
    $articleLinkAUrl = $urls->urla;
    endif;?>

Unsing articleLinkAUrl as new URL for the intro image:

<a href="<?php echo $articleLinkAUrl;?>">

Same can be done to change the title URl to use articleLinkAURL

mickmackusa improved my solution which is available here: https://3v4l.org/JFDRM

1
  • That's more than enough, let's remove our comments as none of them are useful anymore. Apr 26, 2019 at 9:12

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.