By Zeosing on Thursday, 27 February 2014
Posted in Technical Issues
Replies 5
Likes 0
Views 1.1K
Votes 0
We are with a new developing, and wi need to set the background image in a div with the easyblog image (module) , the code for this is :

<?php
/**
* @package EasyBlog
* @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*
* EasyBlog is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

defined('_JEXEC') or die('Restricted access');

// override itemid.
// reset the itemid incase previously the itemid was assigned from other posts.
$itemId = modLatestBlogsHelper::_getMenuItemId($post, $params);
$url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post->id . $itemId );

$posterURL = EasyBlogRouter::_( 'index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $post->author->id . $itemId );
$posterName = $post->author->getName();

$disabled = true;
if( $params->get( 'enableratings' ) )
{
$disabled = false;
}
?>
<div class="mod-item">

<?php if( $params->get( 'photo_show') ){ ?>
<?php if( !empty( $post->source ) ){ ?>
<?php require( JModuleHelper::getLayoutPath('mod_latestblogs', $post->source . '_item' ) ); ?>
<?php } else { ?>

<?php if( $post->getImage() ){ ?>
<div class="mod-post-image align-<?php echo $params->get( 'alignment' , 'default' );?>">
<a href="/<?php echo $url; ?>"><div class="back-image" style="background-image: url('/<?php echo $post->getImage(')->getSource('module');?>) ; background-size: cover"></div></a>
</div>
<?php } else { ?>
<!-- Legacy for older style -->
<?php if( $post->media ){ ?>
<div class="mod-post-image align-<?php echo $params->get( 'alignment' , 'default' );?>">
<a href="/<?php echo $url; ?>"><?php echo $post->media;?></a>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>

<div class="mod-post-title">
<a href="/<?php echo $url; ?>"><?php echo $post->title;?></a>
</div>

<?php if( $params->get( 'showcategory') ){ ?>
<div class="mod-post-type">
<a href="/<?php echo EasyBlogRouter::_( 'index.php?option=com_easyblog&view=categories&layout=listings&id=' . $post->category_id . $itemId );?>"><?php echo $post->getCategoryName();?></a>
</div>
<?php } ?>

<?php if( $params->get( 'showintro' , '-1' ) != '-1' ){ ?>
<div class="mod-post-content clearfix">

<?php if( $post->protect ){ ?>
<?php echo $post->content; ?>
<?php } else { ?>
<?php echo $post->summary;?>
<?php } ?>

<?php if( $params->get( 'showreadmore' , true ) ){ ?>
<div class="mod-post-more">
<a href="/<?php echo $url; ?>"><?php echo JText::_('MOD_LATESTBLOGS_READMORE'); ?></a>
</div>
<?php } ?>

</div>
<?php } ?>

<?php if( $params->get( 'showratings', true ) && $post->showRating ): ?>
<div class="mod-post-rating blog-rating small"><?php echo EasyBlogHelper::getHelper( 'ratings' )->getHTML( $post->id , 'entry' , JText::_( 'MOD_LATESTBLOGS_RATEBLOG' ) , uniqid() . '-mod-latestpost-' . $post->id , $disabled);?></div>
<?php endif; ?>

<!-- Author metadata -->
<?php require( JModuleHelper::getLayoutPath('mod_latestblogs', 'default_meta' ) ); ?>
</div>


But for some reason, work fine in the first and secon post, but in the last two doesn´t wokt, we have set post to show to 4 .

Thnaks.
Hello Adrian,

I did a bit of modification to your code now its displaying your pictures,

<div class="mod-item">
<a class="box-link" href="<?php echo $url; ?>"> </a>
<?php if( $params->get( 'photo_show') ){ ?>
<?php if( !empty( $post->source ) ){ ?>
<?php require( JModuleHelper::getLayoutPath('mod_latestblogs', $post->source . '_item' ) ); ?>
<?php } else { ?>

<?php if( $post->getImage() ){ ?>
<div class="mod-post-image align-<?php echo $params->get( 'alignment' , 'default' );?>">

<?php $backgroungImage = str_replace(" ", "%20", $post->getImage()->getSource('module')); ?>
<div class="back-image" style="background-image:url(<?php echo $backgroungImage;?>); background-size:cover">
<div class="box-overlay"></div>
<div class="post-content">

<?php if( $params->get( 'showcategory') ){ ?>
<div class="show-category">
<i class="grid-icon <?php echo $post->getCategoryName();?>"></i><span class="category"><?php echo $post->getCategoryName();?></span>
</div>
<?php } ?>
<!-- Author metadata -->
<?php require( JModuleHelper::getLayoutPath('mod_latestblogs', 'default_meta' ) ); ?>
<div class="mod-post-title">
<span class="title"><?php echo $post->title;?></span>
</div>


Thanks:)
·
Thursday, 27 February 2014 07:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi, impressive, thanks to you, it´s a pleasure be part of stackideas clients.

Thanks again.

It would be possible to retrieve the category ID to make a custon class? like

<i class="grid-icon <?php echo $post->getCategoryName();?>">


Of course in the place of category name the categry id.
·
Thursday, 27 February 2014 13:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

You can use $post->category_id. Please give it a try.
·
Thursday, 27 February 2014 16:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Perfect as always, thanks Nick,
·
Thursday, 27 February 2014 16:46
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

You're welcome.
·
Thursday, 27 February 2014 17:11
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post