Image not showing in Articles Category Override

Everything to do with Joomla! 2.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
djandyr
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Tue Mar 27, 2012 7:14 pm
Location: Chelmsford, Essex
Contact:

Image not showing in Articles Category Override

Post by djandyr » Wed Apr 04, 2012 2:09 pm

Hi there,

I have created a template, and it works (for the most part) I am trying to get the override to display the "Articles Category" module with a title, small description, and image to the left. I have the title and description working, but dont know how to display the image I have the code below but it doesnt seem to work.

Code: Select all

<?php
// no direct access
defined('_JEXEC') or die;
?>
<div class="BoxTop"><div class="BoxTopLeft"><!--KEEP NOTE--></div><h1><?php echo $module->title; ?></h1><div class="BoxTopRight"><!--KEEP NOTE--></div></div>
<div class="BoxContent">
<div class="Blog_Small">
<ul>
	<?php foreach ($list as $item) : ?>
	    <li>
        <a href="<?php echo $item->link; ?>">
        
		<?php if ($params->get('show_description_image') && $category->getParams()->get('image')) : ?>
			<img src="<?php echo $category->getParams()->get('image'); ?>"/>
		<?php endif; ?>
        
        <h3><?php echo $item->title; ?></h3>
		<?php if ($params->get('show_introtext')) :?>
			<?php echo $item->displayIntrotext; ?>
		<?php endif; ?>
        [ Read More ]
        </a>
	</li>
	<?php endforeach; ?>
</ul>
</div>
</div>
<div class="BoxBottom"><div class="BoxBottomLeft"><!--KEEP NOTE--></div><div class="BoxBottomRight"><!--KEEP NOTE--></div></div>
<div class="Clear Space"><!--KEEP NOTE--></div>
I have taken snippets of code from other modules, and the "Category Blog" component, but just cant get the ruddy image displayed. Its driving me insane!!!

The site is here > http://www.djandyreed.co.uk

Any assistance would be hugely appreciated.

Thanks in advance,

Andy

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Wed Apr 25, 2012 6:10 pm

I have the same problem - trying to get Articles Category to display a thumbnail image to the left.

Have you solved this yet?

djandyr
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Tue Mar 27, 2012 7:14 pm
Location: Chelmsford, Essex
Contact:

Re: Image not showing in Articles Category Override

Post by djandyr » Wed Apr 25, 2012 6:43 pm

Unfortunately no such luck :-(. I have not found anything of help yet either..

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Wed Apr 25, 2012 6:59 pm

What file did you add the above code to? I am going to test it and see if I can figure out how to make it work.

djandyr
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Tue Mar 27, 2012 7:14 pm
Location: Chelmsford, Essex
Contact:

Re: Image not showing in Articles Category Override

Post by djandyr » Mon Apr 30, 2012 5:46 pm

Sorry for the lengthy time before a reply, It was in a template override for the articles_category module, I copied over some of the template override that I used in the articles_category_blog but it did not seem to work out of the box, So i am wondering if there is some back end tinkering that would need to be done to extract the image and place it correctly. But i honestly have not got a clue...

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Mon Apr 30, 2012 6:40 pm

Thanks for getting back. No worries for the long reply. I am still working on this.

Have you checked out this article?
http://docs.joomla.org/How_to_override_ ... omla!_core

alekks
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Wed Jan 23, 2008 8:05 pm

Re: Image not showing in Articles Category Override

Post by alekks » Thu Jun 28, 2012 2:27 am

Hi,

I'm having the same problem...

Although, I'm trying to get the article's intro/full image, but just get a slash in the src=""...

The Newsflash module can handle these codes,

Code: Select all

<img width="200" height="41" src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>" />
but Articles Category can't for some reason...

Anyone have any solution to this?


UPDATE:
Just solved it.

just after the foreach loop, paste this line:
<?php $images = json_decode($item->images); ?>

and then this will work:
<img width="200" height="41" src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>" />

djandyr
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Tue Mar 27, 2012 7:14 pm
Location: Chelmsford, Essex
Contact:

Re: Image not showing in Articles Category Override

Post by djandyr » Thu Jun 28, 2012 8:35 am

Excelent!! I will try this as soon as i get the chance, I have rather left my website to itself recently and not had a chance to update moch on it. So i will try this later :-)

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Fri Jun 29, 2012 2:41 am

alekks wrote:

Although, I'm trying to get the article's intro/full image, but just get a slash in the src=""...

just after the foreach loop, paste this line:
<?php $images = json_decode($item->images); ?>

and then this will work:
<img width="200" height="41" src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>" />
I just tested this on my site, and I am getting the same slash you mention src="/". No image displays, and the alt"" info is blank.

I'm not sure what I am doing wrong, as I think I followed these instructions explicitly?

User avatar
MoonfireArt
Joomla! Explorer
Joomla! Explorer
Posts: 466
Joined: Wed Feb 29, 2012 3:27 pm

Re: Image not showing in Articles Category Override

Post by MoonfireArt » Fri Jun 29, 2012 3:32 am

I had to solve this for my site. Here is the content of my override file:

Code: Select all

<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_articles_category
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
?>
<ul class="category-module<?php echo $moduleclass_sfx; ?>">
<?php if ($grouped) : ?>
	<?php foreach ($list as $group_name => $group) : ?>
	<li>
		<h<?php echo $item_heading; ?>><?php echo $group_name; ?></h<?php echo $item_heading; ?>>
		<ul>
			<?php foreach ($group as $item) : ?>
				<li>
					
        <?php //json decodes the image object and gets the intro image source. ?>

            <img src="<?php echo json_decode($item->images)->image_intro; ?>" /> 
            
            <h<?php echo $item_heading+1; ?>>
					   	<?php if ($params->get('link_titles') == 1) : ?>
						<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
						<?php echo $item->title; ?>
				        <?php if ($item->displayHits) :?>
							<span class="mod-articles-category-hits">
				            (<?php echo $item->displayHits; ?>)  </span>
				        <?php endif; ?></a>
				        <?php else :?>
				        <?php echo $item->title; ?>
				        	<?php if ($item->displayHits) :?>
							<span class="mod-articles-category-hits">
				            (<?php echo $item->displayHits; ?>)  </span>
				        <?php endif; ?></a>
				            <?php endif; ?>
			        </h<?php echo $item_heading+1; ?>>


				<?php if ($params->get('show_author')) :?>
					<span class="mod-articles-category-writtenby">
					<?php echo $item->displayAuthorName; ?>
					</span>
				<?php endif;?>

				<?php if ($item->displayCategoryTitle) :?>
					<span class="mod-articles-category-category">
					(<?php echo $item->displayCategoryTitle; ?>)
					</span>
				<?php endif; ?>
				<?php if ($item->displayDate) : ?>
					<span class="mod-articles-category-date"><?php echo $item->displayDate; ?></span>
				<?php endif; ?>
				<?php if ($params->get('show_introtext')) :?>
			<p class="mod-articles-category-introtext">
			<?php echo $item->displayIntrotext; ?>
			</p>
		<?php endif; ?>

		<?php if ($params->get('show_readmore')) :?>
			<p class="mod-articles-category-readmore">
				<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
				<?php if ($item->params->get('access-view')== FALSE) :
						echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE');
					elseif ($readmore = $item->alternative_readmore) :
						echo $readmore;
						echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit'));
						if ($params->get('show_readmore_title', 0) != 0) :
							echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
						endif;
					elseif ($params->get('show_readmore_title', 0) == 0) :
						echo JText::sprintf('MOD_ARTICLES_CATEGORY_READ_MORE_TITLE');
					else :

						echo JText::_('MOD_ARTICLES_CATEGORY_READ_MORE');
						echo JHtml::_('string.truncate', ($item->title), $params->get('readmore_limit'));
					endif; ?>
	        </a>
			</p>
			<?php endif; ?>
		</li>
			<?php endforeach; ?>
		</ul>
	</li>
	<?php endforeach; ?>
<?php else : ?>
	<?php foreach ($list as $item) : ?>
	    <li>
	        
        <?php //json decodes the image object and gets the intro image source. ?>

            <img src="<?php echo json_decode($item->images)->image_intro; ?>" /> 
           
	   	<h<?php echo $item_heading; ?>>
	   	<?php if ($params->get('link_titles') == 1) : ?>
		<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
		<?php echo $item->title; ?>
        <?php if ($item->displayHits) :?>
			<span class="mod-articles-category-hits">
            (<?php echo $item->displayHits; ?>)  </span>
        <?php endif; ?></a>
        <?php else :?>
        <?php echo $item->title; ?>
        	<?php if ($item->displayHits) :?>
			<span class="mod-articles-category-hits">
            (<?php echo $item->displayHits; ?>)  </span>
        <?php endif; ?></a>
            <?php endif; ?>
        </h<?php echo $item_heading; ?>>

       	<?php if ($params->get('show_author')) :?>
       		<span class="mod-articles-category-writtenby">
			<?php echo $item->displayAuthorName; ?>
			</span>
		<?php endif;?>
		<?php if ($item->displayCategoryTitle) :?>
			<span class="mod-articles-category-category">
			<?php echo $item->displayCategoryTitle; ?>
			</span>
		<?php endif; ?>
        <?php if ($item->displayDate) : ?>
			<span class="mod-articles-category-date"><?php echo $item->displayDate; ?></span>
		<?php endif; ?>
		<?php if ($params->get('show_introtext')) :?>
			<p class="mod-articles-category-introtext">
			<?php echo $item->displayIntrotext; ?>
			</p>
		<?php endif; ?>

		<?php if ($params->get('show_readmore')) :?>
			<p class="mod-articles-category-readmore">
				<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
		        <?php if ($item->params->get('access-view')== FALSE) :
						echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE');
					elseif ($readmore = $item->alternative_readmore) :
						echo $readmore;
						echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit'));
					elseif ($params->get('show_readmore_title', 0) == 0) :
						echo JText::sprintf('MOD_ARTICLES_CATEGORY_READ_MORE_TITLE');
					else :
						echo JText::_('MOD_ARTICLES_CATEGORY_READ_MORE');
						echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit'));
					endif; ?>
	        </a>
			</p>
		<?php endif; ?>
	</li>
	<?php endforeach; ?>
<?php endif; ?>
</ul>
this was placed in templates/(my template)/html/mod_articles_category/default.php and it works perfectly. I can give a link to the override in action if anyone is interested.
The burned hand teaches best... - The Two Towers

http://webdesign.moonfireartstudios.com Joomla web design for small businesses

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Sun Jul 01, 2012 4:12 am

MoonfireArt wrote:this was placed in templates/(my template)/html/mod_articles_category/default.php and it works perfectly.
Thank you for this, however I am still having the same problem. I saved this as my default.php override in the exact path you show above.

After saving the file, I go to view the source code for the page the module is displayed on and the path to the image is still wrong. Instead of pointing as it should to src="/mysite/joomla/images/folder/intro_image.jpg" it points to the root directory of my installation src="/mysite/joomla/". Everything else works fine - the title, the intro text, the readmore link all work perfectly. Only the image does not display, as the path is wrong.

I am not sure how to fix this?

mcgeo
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 08, 2007 12:27 am

Re: Image not showing in Articles Category Override

Post by mcgeo » Mon Jul 02, 2012 9:11 pm

MoonfireArt wrote:I had to solve this for my site.
I have done some research that leads me to believe that my problem may be with my helper.php file.

What version of Joomla are you using?
Is it a fresh install, or did you upgrade from another version - if so which?
Would you mind posting the code for your helper.php file?

User avatar
MoonfireArt
Joomla! Explorer
Joomla! Explorer
Posts: 466
Joined: Wed Feb 29, 2012 3:27 pm

Re: Image not showing in Articles Category Override

Post by MoonfireArt » Mon Jul 02, 2012 11:40 pm

My helper.php file is the standard one from Joomla 2.5.6, although I initiated this override in Joomla 2.5.4. But, here is the code you requested. Beware, it is very lengthy.

Code: Select all

<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_articles_category
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$com_path = JPATH_SITE.'/components/com_content/';
require_once $com_path.'router.php';
require_once $com_path.'helpers/route.php';

JModelLegacy::addIncludePath($com_path . '/models', 'ContentModel');

abstract class modArticlesCategoryHelper
{
	public static function getList(&$params)
	{
		// Get an instance of the generic articles model
		$articles = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));

		// Set application parameters in model
		$app = JFactory::getApplication();
		$appParams = $app->getParams();
		$articles->setState('params', $appParams);

		// Set the filters based on the module params
		$articles->setState('list.start', 0);
		$articles->setState('list.limit', (int) $params->get('count', 0));
		$articles->setState('filter.published', 1);

		// Access filter
		$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
		$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
		$articles->setState('filter.access', $access);

		// Prep for Normal or Dynamic Modes
		$mode = $params->get('mode', 'normal');
		switch ($mode)
		{
			case 'dynamic':
				$option = JRequest::getCmd('option');
				$view = JRequest::getCmd('view');
				if ($option === 'com_content') {
					switch($view)
					{
						case 'category':
							$catids = array(JRequest::getInt('id'));
							break;
						case 'categories':
							$catids = array(JRequest::getInt('id'));
							break;
						case 'article':
							if ($params->get('show_on_article_page', 1)) {
								$article_id = JRequest::getInt('id');
								$catid = JRequest::getInt('catid');

								if (!$catid) {
									// Get an instance of the generic article model
									$article = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));

									$article->setState('params', $appParams);
									$article->setState('filter.published', 1);
									$article->setState('article.id', (int) $article_id);
									$item = $article->getItem();

									$catids = array($item->catid);
								}
								else {
									$catids = array($catid);
								}
							}
							else {
								// Return right away if show_on_article_page option is off
								return;
							}
							break;

						case 'featured':
						default:
							// Return right away if not on the category or article views
							return;
					}
				}
				else {
					// Return right away if not on a com_content page
					return;
				}

				break;

			case 'normal':
			default:
				$catids = $params->get('catid');
				$articles->setState('filter.category_id.include', (bool) $params->get('category_filtering_type', 1));
				break;
		}

		// Category filter
		if ($catids) {
			if ($params->get('show_child_category_articles', 0) && (int) $params->get('levels', 0) > 0) {
				// Get an instance of the generic categories model
				$categories = JModelLegacy::getInstance('Categories', 'ContentModel', array('ignore_request' => true));
				$categories->setState('params', $appParams);
				$levels = $params->get('levels', 1) ? $params->get('levels', 1) : 9999;
				$categories->setState('filter.get_children', $levels);
				$categories->setState('filter.published', 1);
				$categories->setState('filter.access', $access);
				$additional_catids = array();

				foreach($catids as $catid)
				{
					$categories->setState('filter.parentId', $catid);
					$recursive = true;
					$items = $categories->getItems($recursive);

					if ($items)
					{
						foreach($items as $category)
						{
							$condition = (($category->level - $categories->getParent()->level) <= $levels);
							if ($condition) {
								$additional_catids[] = $category->id;
							}

						}
					}
				}

				$catids = array_unique(array_merge($catids, $additional_catids));
			}

			$articles->setState('filter.category_id', $catids);
		}

		// Ordering
		$articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering'));
		$articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));

		// New Parameters
		$articles->setState('filter.featured', $params->get('show_front', 'show'));
		$articles->setState('filter.author_id', $params->get('created_by', ""));
		$articles->setState('filter.author_id.include', $params->get('author_filtering_type', 1));
		$articles->setState('filter.author_alias', $params->get('created_by_alias', ""));
		$articles->setState('filter.author_alias.include', $params->get('author_alias_filtering_type', 1));
		$excluded_articles = $params->get('excluded_articles', '');

		if ($excluded_articles) {
			$excluded_articles = explode("\r\n", $excluded_articles);
			$articles->setState('filter.article_id', $excluded_articles);
			$articles->setState('filter.article_id.include', false); // Exclude
		}

		$date_filtering = $params->get('date_filtering', 'off');
		if ($date_filtering !== 'off') {
			$articles->setState('filter.date_filtering', $date_filtering);
			$articles->setState('filter.date_field', $params->get('date_field', 'a.created'));
			$articles->setState('filter.start_date_range', $params->get('start_date_range', '1000-01-01 00:00:00'));
			$articles->setState('filter.end_date_range', $params->get('end_date_range', '9999-12-31 23:59:59'));
			$articles->setState('filter.relative_date', $params->get('relative_date', 30));
		}

		// Filter by language
		$articles->setState('filter.language', $app->getLanguageFilter());

		$items = $articles->getItems();

		// Display options
		$show_date = $params->get('show_date', 0);
		$show_date_field = $params->get('show_date_field', 'created');
		$show_date_format = $params->get('show_date_format', 'Y-m-d H:i:s');
		$show_category = $params->get('show_category', 0);
		$show_hits = $params->get('show_hits', 0);
		$show_author = $params->get('show_author', 0);
		$show_introtext = $params->get('show_introtext', 0);
		$introtext_limit = $params->get('introtext_limit', 100);

		// Find current Article ID if on an article page
		$option = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');

		if ($option === 'com_content' && $view === 'article') {
			$active_article_id = JRequest::getInt('id');
		}
		else {
			$active_article_id = 0;
		}

		// Prepare data for display using display options
		foreach ($items as &$item)
		{
			$item->slug = $item->id.':'.$item->alias;
			$item->catslug = $item->catid ? $item->catid .':'.$item->category_alias : $item->catid;

			if ($access || in_array($item->access, $authorised)) {
				// We know that user has the privilege to view the article
				$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
			}
			 else {
				// Angie Fixed Routing
				$app	= JFactory::getApplication();
				$menu	= $app->getMenu();
				$menuitems	= $menu->getItems('link', 'index.php?option=com_users&view=login');
			if(isset($menuitems[0])) {
					$Itemid = $menuitems[0]->id;
				} elseif (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
					$Itemid = JRequest::getInt('Itemid');
				}

				$item->link = JRoute::_('index.php?option=com_users&view=login&Itemid='.$Itemid);
				}

			// Used for styling the active article
			$item->active = $item->id == $active_article_id ? 'active' : '';

			$item->displayDate = '';
			if ($show_date) {
				$item->displayDate = JHTML::_('date', $item->$show_date_field, $show_date_format);
			}

			if ($item->catid) {
				$item->displayCategoryLink = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid));
				$item->displayCategoryTitle = $show_category ? '<a href="'.$item->displayCategoryLink.'">'.$item->category_title.'</a>' : '';
			}
			else {
				$item->displayCategoryTitle = $show_category ? $item->category_title : '';
			}

			$item->displayHits = $show_hits ? $item->hits : '';
			$item->displayAuthorName = $show_author ? $item->author : '';
			if ($show_introtext) {
				$item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_articles_category.content');
				$item->introtext = self::_cleanIntrotext($item->introtext);
			}
			$item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit) : '';
			// added Angie show_unauthorizid
			$item->displayReadmore = $item->alternative_readmore;

		}

		return $items;
	}

	public static function _cleanIntrotext($introtext)
	{
		$introtext = str_replace('<p>', ' ', $introtext);
		$introtext = str_replace('</p>', ' ', $introtext);
		$introtext = strip_tags($introtext, '<a><em><strong>');

		$introtext = trim($introtext);

		return $introtext;
	}

	/**
	* This is a better truncate implementation than what we
	* currently have available in the library. In particular,
	* on index.php/Banners/Banners/site-map.html JHtml's truncate
	* method would only return "Article...". This implementation
	* was taken directly from the Stack Overflow thread referenced
	* below. It was then modified to return a string rather than
	* print out the output and made to use the relevant JString
	* methods.
	*
	* @link http://stackoverflow.com/questions/1193500/php-truncate-html-ignoring-tags
	* @param mixed $html
	* @param mixed $maxLength
	*/
	public static function truncate($html, $maxLength = 0)
	{
		$printedLength = 0;
		$position = 0;
		$tags = array();

		$output = '';

		if (empty($html)) {
			return $output;
		}

		while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position))
		{
			list($tag, $tagPosition) = $match[0];

			// Print text leading up to the tag.
			$str = JString::substr($html, $position, $tagPosition - $position);
			if ($printedLength + JString::strlen($str) > $maxLength) {
				$output .= JString::substr($str, 0, $maxLength - $printedLength);
				$printedLength = $maxLength;
				break;
			}

			$output .= $str;
			$lastCharacterIsOpenBracket = (JString::substr($output, -1, 1) === '<');

			if ($lastCharacterIsOpenBracket) {
				$output = JString::substr($output, 0, JString::strlen($output) - 1);
			}

			$printedLength += JString::strlen($str);

			if ($tag[0] == '&') {
				// Handle the entity.
				$output .= $tag;
				$printedLength++;
			}
			else {
				// Handle the tag.
				$tagName = $match[1][0];

				if ($tag[1] == '/') {
					// This is a closing tag.
					$openingTag = array_pop($tags);

					$output .= $tag;
				}
				elseif ($tag[JString::strlen($tag) - 2] == '/') {
					// Self-closing tag.
					$output .= $tag;
				}
				else {
					// Opening tag.
					$output .= $tag;
					$tags[] = $tagName;
				}
			}

			// Continue after the tag.
			if ($lastCharacterIsOpenBracket) {
				$position = ($tagPosition - 1) + JString::strlen($tag);
			}
			else {
				$position = $tagPosition + JString::strlen($tag);
			}

		}

		// Print any remaining text.
		if ($printedLength < $maxLength && $position < JString::strlen($html)) {
			$output .= JString::substr($html, $position, $maxLength - $printedLength);
		}

		// Close any open tags.
		while (!empty($tags))
		{
			$output .= sprintf('</%s>', array_pop($tags));
		}

		$length = JString::strlen($output);
		$lastChar = JString::substr($output, ($length - 1), 1);
		$characterNumber = ord($lastChar);

		if ($characterNumber === 194) {
			$output = JString::substr($output, 0, JString::strlen($output) - 1);
		}

		$output = JString::rtrim($output);

		return $output.'&hellip;';
	}

	public static function groupBy($list, $fieldName, $article_grouping_direction, $fieldNameToKeep = null)
	{
		$grouped = array();

		if (!is_array($list)) {
			if ($list == '') {
				return $grouped;
			}

			$list = array($list);
		}

		foreach($list as $key => $item)
		{
			if (!isset($grouped[$item->$fieldName])) {
				$grouped[$item->$fieldName] = array();
			}

			if (is_null($fieldNameToKeep)) {
				$grouped[$item->$fieldName][$key] = $item;
			}
			else {
				$grouped[$item->$fieldName][$key] = $item->$fieldNameToKeep;
			}

			unset($list[$key]);
		}

		$article_grouping_direction($grouped);

		return $grouped;
	}

	public static function groupByDate($list, $type = 'year', $article_grouping_direction, $month_year_format = 'F Y')
	{
		$grouped = array();

		if (!is_array($list)) {
			if ($list == '') {
				return $grouped;
			}

			$list = array($list);
		}

		foreach($list as $key => $item)
		{
			switch($type)
			{
				case 'month_year':
					$month_year = JString::substr($item->created, 0, 7);

					if (!isset($grouped[$month_year])) {
						$grouped[$month_year] = array();
					}

					$grouped[$month_year][$key] = $item;
					break;

				case 'year':
				default:
					$year = JString::substr($item->created, 0, 4);

					if (!isset($grouped[$year])) {
						$grouped[$year] = array();
					}

					$grouped[$year][$key] = $item;
					break;
			}

			unset($list[$key]);
		}

		$article_grouping_direction($grouped);

		if ($type === 'month_year') {
			foreach($grouped as $group => $items)
			{
				$date = new JDate($group);
				$formatted_group = $date->format($month_year_format);
				$grouped[$formatted_group] = $items;
				unset($grouped[$group]);
			}
		}

		return $grouped;
	}
}
I hope it helps.
The burned hand teaches best... - The Two Towers

http://webdesign.moonfireartstudios.com Joomla web design for small businesses

dive4cb
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Mon Nov 26, 2007 6:41 pm

Re: Image not showing in Articles Category Override

Post by dive4cb » Wed Oct 10, 2012 3:49 pm

Was anyone able to resolve this issue? I'm having the same problem.

canopy
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Dec 20, 2012 1:08 am

Re: Image not showing in Articles Category Override

Post by canopy » Thu Dec 20, 2012 1:13 am

Thank you, MoonfireArt for posting your template override. It worked perfectly for me, solved the problem, and saved me many hours of frustration. :)

tranmani
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Dec 26, 2012 12:41 pm
Contact:

Re: Image not showing in Articles Category Override

Post by tranmani » Wed Dec 26, 2012 12:50 pm

thanks you
it's my issue too

Matt2012
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon May 31, 2010 7:18 pm

Re: Image not showing in Articles Category Override

Post by Matt2012 » Thu Aug 28, 2014 5:54 pm

This is an ancient thread but I was getting this issue in 3.3.3

Basically the problem is in the helper line 281

Code: Select all

$item->introtext = self::_cleanIntrotext($item->introtext);
This is stripping tags. If it strips a linked image it breaks.

I just commented the line out.

Matt2012
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon May 31, 2010 7:18 pm

Re: Image not showing in Articles Category Override

Post by Matt2012 » Thu Dec 17, 2015 3:25 pm

Just returned here as I was scratching my head when confronted with this issue - only to find that past Matt solved this problem before! Cheers past Matt.

Unfortunately as we are required to overwrite core files a Joomla update will overwrite any changes - as it just did with me. Looking back on my previous fix I thought an improvement was possible. Rather than preventing all cleaning I just added img to the list of tags to ignore.

edit this line (303):

Code: Select all

$introtext = strip_tags($introtext, '<a><em><strong><img>');
in /modules/mod_articles_category/helper.php


Locked

Return to “Templates for Joomla! 2.5”