Category list layout, with image?

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
djdany
Joomla! Intern
Joomla! Intern
Posts: 82
Joined: Mon Oct 12, 2009 5:39 pm

Re: Category list layout, with image?

Post by djdany » Thu Jul 31, 2014 3:18 pm

pangolin wrote:In the five odd years since joomjbo posted the code above, the file names and variables have changed slightly.

The file you need to copy is now /components/com_content/views/category/tmpl/default_articles.php

You need to copy it to /templates/[the template you use]/html/com_content/category/default_articles.php

(Nb you will need to do this for each template you use. Editing the file in place is not recommended as it will get overwritten when you upgrade joomla)

The edits you need to make are as follows:

The line of code you need to find is

Code: Select all

<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); ?>">
The $item variable is now $article, so the code you need to add after the previous line is:

Code: Select all

<?php
$text = $article->introtext;
if(preg_match('/<\s*img[^>]+>/Ui', $text, $matches)){
   $image=$matches[0];
   $text = str_replace($image,'',$text);
}
if ($matches) {
$image = str_replace('img src="','img width="150px" src="/',$image);
$image = str_replace("caption","", $image);
echo '' . $image . '';
}
else {echo '<img width="150px" src="/images/defaultarticleimage.jpg" class="defaultArticleImage" />';}
?>
Thank you for your post. It is working, but how can I put the intro image instead? like insted of looking in the articles image, it looks for the intro image in the article.

Code: Select all

$images  = json_decode($this->item->images);

echo $images->image_intro;
this is the code I found but I do not know how to implement it with your code.
Any idea?

Nesto1930
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Dec 19, 2014 9:09 pm

Re: Category list layout, with image?

Post by Nesto1930 » Fri Dec 19, 2014 9:15 pm

Hi!

Thank you for the helps, but i have a problem, the codes are working but i want to resize images and add ID for the CSS ^^

My page
http://driveradio.be/index.php/news.html


I'd like something that looks like this
http://www.jeuxvideo.com/toutes-les-videos/

And i'm sorry for my English :/

Best regards,
Nesto

spacecabbie
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 08, 2012 9:17 pm

Re: Category list layout, with image?

Post by spacecabbie » Thu Mar 12, 2015 10:59 am

Does any one have an updated code for this for joomla 3 ?

maestrotg
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sun Oct 19, 2014 2:54 pm

Re: Category list layout, with image?

Post by maestrotg » Wed Sep 02, 2015 12:02 am

Can anyone can help me to show a thumbnail in my category pages. Im using list layout. Thanks


Locked

Return to “General Questions/New to Joomla! 1.5”