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

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
dansky
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Thu Jan 10, 2008 4:42 pm
Location: Italy
Contact:

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

Post by dansky » Fri Feb 17, 2012 4:39 pm

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; ?>

VARion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jan 18, 2012 10:28 am
Location: Russia

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

Post by VARion » Sat Feb 18, 2012 9:23 am

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.

VARion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jan 18, 2012 10:28 am
Location: Russia

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

Post by VARion » Sat Feb 18, 2012 1:53 pm

I'm solve this problem and add instructions to tracker: http://joomlacode.org/gf/project/joomla ... m_id=28086

dansky
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Thu Jan 10, 2008 4:42 pm
Location: Italy
Contact:

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

Post by dansky » Sun Feb 19, 2012 10:15 am

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

VARion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jan 18, 2012 10:28 am
Location: Russia

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

Post by VARion » Mon Feb 20, 2012 10:10 am

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;

dansky
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Thu Jan 10, 2008 4:42 pm
Location: Italy
Contact:

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

Post by dansky » Mon Feb 20, 2012 10:46 am

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 !

VARion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jan 18, 2012 10:28 am
Location: Russia

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

Post by VARion » Mon Feb 20, 2012 11:23 am

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.

wahahey
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Wed Jul 15, 2009 9:06 pm

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

Post by wahahey » Thu Mar 01, 2012 10:25 am

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

VARion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jan 18, 2012 10:28 am
Location: Russia

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

Post by VARion » Fri Mar 02, 2012 6:47 am

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; ?>

wahahey
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Wed Jul 15, 2009 9:06 pm

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

Post by wahahey » Fri Mar 02, 2012 8:37 am

VARion

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

Thank you!

2inchesofwater
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Apr 15, 2012 6:47 am

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

Post by 2inchesofwater » Sun Apr 15, 2012 6:51 am

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?

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

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

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

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

User avatar
numinousmedia
Joomla! Ace
Joomla! Ace
Posts: 1567
Joined: Fri Dec 16, 2011 6:13 pm
Location: Barberton, OH
Contact:

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

Post by numinousmedia » Thu Feb 21, 2013 9:42 pm

VARion, thank you very much for posting your solution. It's exactly what I needed.
Ryan
Frontend Developer and Joomla Professional
Ethode Website Development: http://www.ethode.com
Personal Site: http://www.numinousmedia.com

sdk19852
Joomla! Intern
Joomla! Intern
Posts: 76
Joined: Fri Feb 12, 2010 8:36 pm

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

Post by sdk19852 » Fri Jun 13, 2014 3:22 pm

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.


Locked

Return to “Templates for Joomla! 2.5”