I want to make the joomla articles intro image to behave like the read more, and the title link. So the user clicks the image, and the article loads.
I'm not an PHP expert but maybe this is the readmore links code:
<a href="<?php echo $this->item->readmore_link; ?>" class="button<?php echo $this->item->params->get('pageclass_sfx'); ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::_("Read Article");
endif; ?></a>
This is what i want to do with every intro image on my joomla site. Thanks !
If you have Gantry installed on Joomla 3.1, the overrides are in a different location. You will want to navigate to plugins/system/gantry/overrides/3.0/2.5/com_content/category/blog_item.php and wrap the intro image with the read more link code.
for Joomla 2.5:
in your override for _item.php (Location: yourtemplate\html\mod_articles_news\item.php) place the following line:
Place it there where you would like it to show up For example after:
Your intro image has become a link now. the isset part, makes sure that if a viewer uses Internet Explorer, it doesn't show up a small red cross box.
Just for the information: in blog_item.php you can find an example code how it's shown up in an article. Here you can also find the code for imagefloat etc.
So let me start by explaining what the code that you've posted above does. The entire block of code generates one link: there are a bunch of if statements that are determined based off some settings. For example, if you have set that people need to register in order to read more, the link will say "Register to read more..."
The part that we're interested in here, however, since we want to turn images into links, is the URL that we want the images to link to. This is right in the first line:
so we know that the URL is provided dynamically thanks to
$item->item->readmore_link
and all this code is doing is echoing it into the HTML.All that's left is to edit your Joomla template of the page on which you have your images (probably the same file you took this code from). It looks like this should be part of a greater PHP loop, which loops through all the posts. Somewhere above where you found this code, should be code for the intro image that goes along with that post.
I'm not sure what it'll look like, it could be a
<img src="<? stuff here; ?> />
or it could be dynamically generated. Keep reading. If you're still not sure where to find it at the end, edit your post with the full code of the template where you got the above snipping from. Regardless of what it looks like, it is referred to as<WHATEVER IMAGE CODE YOU FOUND ABOVE>
in the following step:You have to wrap that image with "a" tags so that it looks like the following:
That should do it. Let me know if you have any trouble, I'll be more than happy to make my post more specific if you can provide more detailed information, but I've tried to explain it well enough that you should be able to figure it out with a couple tries.
As you stated you are not a PHP expert, it sounds like your best bet will be to use a Joomla extension that has similar functionality to what you want.
I believe mod_minifrontpage will work for what you need. It allows you to display a list of articles, and it generates thumbnails for those articles based on the first image to be referenced.
There are article intro images in J, since 1.7.5 and now in latest 2.5.3 what you need is change the defaults for component_content,
you can do it 2 ways, editing views in yourinstall/components/com_content/views/
or use template overrides , you first need to know if your template IS using overrides otherwise if you edit component views in the component itself you will not see changes.
to verify this , go to site_name/templates/template_name/html folder and check if there is folder name com_content ,
if that is the case than your template is using overrides and any edits should be done trough there not through component
now to the actual code
this is in components\com_content\views\featured\tmpl\default_item.php ( THIS I DEFAULT FRONTPAGE ARTICLE VIEW)
all you would need to do is wrap a element around IMG tag with readmore link like this
DO NOT forget that if there is template override for com_content you wold need to edit the featured/default_item.php inside it
Just resolved it!
your way of thinking helped me. Thank you!
here's my code: