In joomla 3.1 I edited in this file \components\com_content\views\featured\tmpl\default_item.php

<?php if (isset($images->image_intro) && !empty($images->image_intro)) : ?>
    <?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
    <div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
    <?php if ($images->image_intro_caption):
        echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
    endif; ?>
    src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/> </div>
<?php endif; ?>

to:

<?php if (isset($images->image_intro) && !empty($images->image_intro)) : ?>
    <?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
    <div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"><a href="<?php echo $this->item->readmore_link; ?>"> <img
    <?php if ($images->image_intro_caption):
        echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
    endif; ?>
    src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/></a> </div>
<?php endif; ?>`

but its not working correct, because is linking to the main page... how I can fix this, I tried everything from this, but it does not work Joomla intro image as read more link

有帮助吗?

解决方案

First of all, you should never edit a core file. Instead of editing \components\com_content\views\featured\tmpl\default_item.php, you should make a copy of the file and place it here - /templates/YOUR TEMPLATE/html/com_content/featured/default_item.php.

This will prevent Joomla from overwriting any changes when there is an update/upgrade. This is probably also why you are not seeing the change on your site. There is very likely a template override for \components\com_content\views\featured\tmpl\default_item.php already in your template folder. If there is, Joomla will use that file instead of the core file you are editing. Make your changes in your template override and it should work.

其他提示

I found the resolution:

<img
     <?php if ($images->image_intro_caption):
        echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
     endif; ?>
     src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/> 

Modified to:

<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"><img
     <?php if ($images->image_intro_caption):
        echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
     endif; ?>
     src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/> </a>

And now its working correct :), and thanks to Brent Friar for the template override :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top