Page 1 of 1

Image intro it's fantastic, but i want to upgrade newsflash!

Posted: Fri Feb 17, 2012 4:39 pm
by dansky
Ok, joomla 2.5 it's out and finally gets the intro-image in a similar way wordpress does. Great I love it and makes the life much more easy (especially for external editors)
I also implemented the thimthumb to resize pictures on the fly as my intro-div has been loaded on frontpage. See down here.

But now my question is: how to get the intro image inside our newsflash modules ?? It's weird now using the before-readmore-firstpic of the article. Having the intro image inside newsflash could be the best natural evolution. Probably no one on joomla team got enought time to update the newsflash mod as it should be...
Is anyone able to help me pulling out from joomla the string to the intro pic path of each article showing on mod_newsflash ?

Anyone, let me know..!

Code: Select all

<?php  if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
	<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>

	<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">
<img
		<?php if ($images->image_intro_caption):
			echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
		endif; ?>
		src="<?php echo $this->baseurl ?>/templates/mytemplate/js/timthumb.php?src=<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($images->image_intro); ?>&h=150&w=150&zc=1" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
	</div>
<?php endif; ?>

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Sat Feb 18, 2012 9:23 am
by VARion
I have this problem.
How access to intro_image in mod_articles_news?
I'm try get $images in file: /templates/iv-template/html/mod_articles_news/_item.php with no results.

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Sat Feb 18, 2012 1:53 pm
by VARion
I'm solve this problem and add instructions to tracker: http://joomlacode.org/gf/project/joomla ... m_id=28086

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Sun Feb 19, 2012 10:15 am
by dansky
Added it on helper.php but I still get an apty space with this:

Code: Select all

 <img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Mon Feb 20, 2012 10:10 am
by VARion
Add follow line to /templates/your_template/html/mod_articles_news/_item.php

Code: Select all

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

Code: Select all

defined('_JEXEC') or die;

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Mon Feb 20, 2012 10:46 am
by dansky
Ok did it ! Works great now.

What about helper.php override ?
I already had a look around and didnt find a way to add that a.images call by a template override. Looks like it's impossible to override helper.php isnt it ?

So we're again here to mod the core files :-) ? not a prob after all.
The workaround it's creating a completely new module. With timthumb ersize features I would say that I'm creating something totally new !

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Mon Feb 20, 2012 11:23 am
by VARion
Override helper.php the most correct way. But, we need to wait until the fix is in the Joomla (I hope it will be in next update). By the way, too, url's are not working for the same reason.

The new module is needed if this current functionality is not enough. In my needs thumbs proportions differ from the proportions of the original image, which requires manual work and control. The idea is good, need a good implementation.

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Thu Mar 01, 2012 10:25 am
by wahahey
This is exactly what I want to do, but when I put dansky's code

Code: Select all

Code:
<?php  if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
   <?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>

   <div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">
<img
      <?php if ($images->image_intro_caption):
         echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
      endif; ?>
      src="<?php echo $this->baseurl ?>/templates/mytemplate/js/timthumb.php?src=<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($images->image_intro); ?>&h=150&w=150&zc=1" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
   </div>
<?php endif; ?>
in my template override _item.php it breaks the layout at

Code: Select all

<div class="img-intro-
and only displays the start of the module (all other modules, components, template are not displayed).

Is there something wrong with the code, or is there a specific place I should be putting it?

I'm using Beez20 on Joomla2.5

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Fri Mar 02, 2012 6:47 am
by VARion
wahahey, probably disrupted the structure of the module.
My _item.php file (based on Gantry default template):

Code: Select all

<?php
/**
 * @package   Template Overrides - RocketTheme
 * @version   3.2.15 January 25, 2012
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 *
 * Rockettheme Gantry Template uses the Joomla Framework (http://www.joomla.org), a GNU/GPLv2 content management system
 *
 */

// no direct access
defined('_JEXEC') or die;

$images = json_decode($item->images);		//for intro images

?>
<?php if ($params->get('item_title')) : ?>

	<<?php echo $params->get('item_heading'); ?> class="newsflash-title <?php echo $params->get('moduleclass_sfx'); ?>">
	<?php if ($params->get('link_titles') && $item->link != '') : ?>
		<a href="<?php echo $item->link;?>">
			<?php echo $item->title;?></a>
	<?php else : ?>
		<?php echo $item->title; ?>
	<?php endif; ?>
	</<?php echo $params->get('item_heading'); ?>>

<?php endif; ?>

<?php /** For Intro Image **/ if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
	<?php $imgfloat = (empty($images->float_intro)) ? $item->params->get('float_intro') : $images->float_intro; ?>
	<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">		
		<a href="<?php echo $item->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 /** End For Intro Image **/endif; ?>

<?php if (!$params->get('intro_only')) :
	echo $item->afterDisplayTitle;
endif; ?>

<?php echo $item->beforeDisplayContent; ?>

<?php echo $item->introtext; ?>

<?php if (isset($item->link) && $item->readmore && $params->get('readmore')) :
	echo '<a class="readon" href="'.$item->link.'"><span>'.$item->linkText.'</span></a>';
endif; ?>

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Fri Mar 02, 2012 8:37 am
by wahahey
VARion

I must have been putting it in the wrong position as you say - working perfectly now.

Thank you!

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Sun Apr 15, 2012 6:51 am
by 2inchesofwater
I'd love to find a way to apply this solution to mod-articles-category.

I want to display the image_intro as a background image behind the article summary, but like the mod-article-news issue, the images field doesn't get loaded.
Any thoughts?

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Thu Jun 28, 2012 2:42 am
by alekks
2inchesofwater wrote:I'd love to find a way to apply this solution to mod-articles-category.

I want to display the image_intro as a background image behind the article summary, but like the mod-article-news issue, the images field doesn't get loaded.
Any thoughts?
I'm trying to get it to work with mod_articles_category too, but no luck... Have you found a solution yet?

Thanks.


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); ?>" />

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Thu Feb 21, 2013 9:42 pm
by numinousmedia
VARion, thank you very much for posting your solution. It's exactly what I needed.

Re: Image intro it's fantastic, but i want to upgrade newsfl

Posted: Fri Jun 13, 2014 3:22 pm
by sdk19852
Awesome topic. Totally worked for my newsflash module:).

I am now trying to get it to display the category image of a sub-category.

I found out this code requests it:

Code: Select all

blog.php
<?php if (!empty($this->children[$this->category->id]) && $this->maxLevel != 0) : ?>
		<div class="cat-children">
			<?php if ($this->params->get('show_category_heading_title_text', 1) == 1) : ?>
				<h3> <?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?> </h3>
			<?php endif; ?>
			<?php echo $this->loadTemplate('children'); ?> </div>
	<?php endif; ?>
Then it requests from childeren:

Code: Select all

blog_children.php
	<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
	<?php //start mod?>
			<div class="item-image">
			<?php echo '<img src="'.json_decode($child->params)->image . '" />'; ?>
			</div>
	<?php // end mod?>
Images get displayed, but when there is no image it displays regardless (!). Can someone explain how I rewrite this so that it doesn't display if there is no image to be retrieved? I am really bad at php, I got this to work through trial and error :P.