-
AuthorPosts
-
December 10, 2009 at 7:40 am #146741
Using Joomla 1.5 and the latest JA News, is there any way to use the category image for the categories rather than an image within the article? Not all our articles have images and it would be easier just to use the category image instead.
December 12, 2009 at 9:10 pm #326390It’s been a few days. Any ideas for this?
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
December 14, 2009 at 2:01 am #326431Hello DominicMaricic!
The ja new does not work as your expected. Please try to looking for a extension in the extensions joomla , may be you have it to use for your idea.:)
December 14, 2009 at 2:15 am #326433It seems like it would be an easy change. Just use the category image rather than an image within the article itself. The rest of the component works great. Does anyone know have an answer other than look elsewhere? I can’t believe that no one wants this, not every article has an image.
January 6, 2010 at 1:44 am #328342Still nothing on this? I’ve had a ticket open for almost a month.
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
January 6, 2010 at 5:00 am #328372Dear guy!
I’m sorry for this,
now, please open the file: modulesmod_janewshelper.php and try to find the “getList” function:
[PHP]
function getList($catorsec, $catid, $items, $ordering, $showcontentfrontpage = false) {
// code here
}
[/PHP]
You try to find the sql query in the function:
[PHP]
$query = ‘SELECT a.*,u.name as creater, cc.description as catdesc, cc.title as cattitle,s.description as secdesc, s.title as sectitle,’ . ‘ CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(“:”, a.id, a.alias) ELSE a.id END as slug,’ . ‘ CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(“:”, cc.id, cc.alias) ELSE cc.id END as catslug,’ . ‘ CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(“:”, s.id, s.alias) ELSE s.id END as secslug’ . ‘ FROM #__content AS a’ . ‘ INNER JOIN #__categories AS cc ON cc.id = a.catid’ . ‘ INNER JOIN #__sections AS s ON s.id = a.sectionid’ . ‘ left JOIN #__users AS u ON a.created_by = u.id’;
$query .= ‘ WHERE a.state = 1 ‘ . ($noauth ? ‘ AND a.access <= ‘ . ( int ) $aid . ‘ AND cc.access <= ‘ . ( int ) $aid . ‘ AND s.access <= ‘ . ( int ) $aid : ”) . ‘ AND (a.publish_up = ‘ . $db->Quote ( $nullDate ) . ‘ OR a.publish_up <= ‘ . $db->Quote ( $now ) . ‘ ) ‘ . ‘ AND (a.publish_down = ‘ . $db->Quote ( $nullDate ) . ‘ OR a.publish_down >= ‘ . $db->Quote ( $now ) . ‘ )’ . (($catorsec) ? “n AND cc.id=” . ( int ) $catid : ‘ AND s.id=’ . ( int ) $catid) . ‘ AND cc.section = s.id’ . ‘ AND cc.published = 1’ . ‘ AND s.published = 1’;
[/PHP]
+>> You replace:
[PHP]
$query = ‘SELECT a.*,u.name as creater,s.image as simage, cc.image as cimage, cc.description as catdesc, cc.title as cattitle,s.description as secdesc, s.title as sectitle,’ . ‘ CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(“:”, a.id, a.alias) ELSE a.id END as slug,’ . ‘ CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(“:”, cc.id, cc.alias) ELSE cc.id END as catslug,’ . ‘ CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(“:”, s.id, s.alias) ELSE s.id END as secslug’ . ‘ FROM #__content AS a’ . ‘ INNER JOIN #__categories AS cc ON cc.id = a.catid’ . ‘ INNER JOIN #__sections AS s ON s.id = a.sectionid’ . ‘ left JOIN #__users AS u ON a.created_by = u.id’;
$query .= ‘ WHERE a.state = 1 ‘ . ($noauth ? ‘ AND a.access <= ‘ . ( int ) $aid . ‘ AND cc.access <= ‘ . ( int ) $aid . ‘ AND s.access <= ‘ . ( int ) $aid : ”) . ‘ AND (a.publish_up = ‘ . $db->Quote ( $nullDate ) . ‘ OR a.publish_up <= ‘ . $db->Quote ( $now ) . ‘ ) ‘ . ‘ AND (a.publish_down = ‘ . $db->Quote ( $nullDate ) . ‘ OR a.publish_down >= ‘ . $db->Quote ( $now ) . ‘ )’ . (($catorsec) ? “n AND cc.id=” . ( int ) $catid : ‘ AND s.id=’ . ( int ) $catid) . ‘ AND cc.section = s.id’ . ‘ AND cc.published = 1’ . ‘ AND s.published = 1’;
[/PHP]2) you open the file modulesmod_janewstmplblog_item.php and find codes:
[PHP]$image = modJANewsHelper::replaceImage ($row, $img_align, $params, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);[/PHP]
=> replace:
[PHP]
$tr = ‘#<s*img [^>]*srcs*=s*([“‘])(.*?)1#im’;
$match=null;
preg_match ( $tr, $row->introtext. $row->fulltext, $match );
//Show the latest news
if( !$match ){
$tmpLink = $catorsec ? $row->cimage:$row->simage;
$image = !$tmpLink ? ” :'<img src=”‘.’images/stories/’.$tmpLink.'” />’;
$row->introtext = $image. $row->introtext;
}
$image = modJANewsHelper::replaceImage ($row, $img_align, $params, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);
[/PHP]good luck
January 6, 2010 at 5:35 am #328373Hi Tienhc,
Thank you for helping. I changed both files as above and the images went away but the category images did not appear ( I made sure to have a few set). Was there anything else that has to be changed?
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
January 6, 2010 at 7:02 am #328380Hello guy!
i forget explain more detail about my changes:
The image of categories or the image of section only was displayed if the article have not any image.
I tried to test my codes on the two sites again, the module is workded well on our site after modified codes.6623
Option 1:
These codes display the image base on the “Group by Category or Section” parameter
[PHP]
$tr = ‘#<s*img [^>]*srcs*=s*([“‘])(.*?)1#im’;
$match=null;
preg_match ( $tr, $row->introtext. $row->fulltext, $match );
//Show the latest news
if( !$match ){
$tmpLink = $catorsec ? $row->cimage:$row->simage;
$image = !$tmpLink ? ” :'<img src=”‘.’images/stories/’.$tmpLink.'” />’;
$row->introtext = $image. $row->introtext;
}
$image = modJANewsHelper::replaceImage ($row, $img_align, $params, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);
[/PHP]
Option 2: without the “Group by Category or Section” parameter
[PHP]
$tr = ‘#<s*img [^>]*srcs*=s*([“‘])(.*?)1#im’;
$match=null;
preg_match ( $tr, $row->introtext. $row->fulltext, $match );
//Show the latest news
if( !$match ){
$image = !$row->cimage ? ” :'<img src=”‘.’images/stories/’.$row->cimage.'” />’;
$row->introtext = $image. $row->introtext;
}
$image = modJANewsHelper::replaceImage ($row, $img_align, $params, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);
[/PHP]chanton Friendchanton
- Join date:
- July 2006
- Posts:
- 137
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 6
- Thanked:
- 2 times in 1 posts
January 6, 2010 at 8:33 am #328396I also tried your code in JA News2, but category just never show when article has no image. what’s wrong?
Is it because your code is for JA News instead of Ja New2 (based on your screenshot)
also I could not find the code your mentioned
[PHP]$image = modJANewsHelper::replaceImage ($row, $img_align, $params, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses); [/PHP]
but found this one. I guess it’s the same.
[PHP]$image = $helper->replaceImage ($row, $img_align, $autoresize, $maxchars, $s_showimage, $img_w, $img_h, $hiddenClasses);[/PHP]Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
January 6, 2010 at 9:13 am #328411ahhh, yes. I only make for the ja new, not the ja news 2. so please give me some times, i ‘ll try to do this and give you the solution 🙂
chanton Friendchanton
- Join date:
- July 2006
- Posts:
- 137
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 6
- Thanked:
- 2 times in 1 posts
January 6, 2010 at 9:43 am #328424You are the best!
Saguaros ModeratorSaguaros
- Join date:
- September 2014
- Posts:
- 31405
- Downloads:
- 237
- Uploads:
- 471
- Thanks:
- 845
- Thanked:
- 5346 times in 4964 posts
January 7, 2010 at 7:49 am #328522Hello guys
The solution for ja news 2: checkout here: http://www.joomlart.com/forums/showthread.php?p=148887#post148887
-
AuthorPosts
This topic contains 12 replies, has 3 voices, and was last updated by Saguaros 14 years, 11 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum