By Mist on Saturday, 15 March 2014
Posted in General Issues
Replies 13
Likes 0
Views 600
Votes 0
Hi guys. Do you know for what reason some variables that i am using inside EasyDiscuss template file "frontpage.post.php" file does not work inside mod_recentdiscussions, default.php template file ?

Basically what i need is to replicate the entire "frontpage.post.php" file inside the mod_recentdiscussions to have "recent discussions" items look the same as discussions inside the component view. (frontpage.post.php)

I have a feeling that somethings ore some easydiscuss libraries/helpers or so on ... are not included by default into the module.

For example, even the basic stuff does not work, code like (i will post some variables below)


<?php echo $post->category; ?>
<?php echo $post->reply->getLink();?>
<?php echo $post->reply->getName(); ?>
<?php echo $post->reply->getAvatar();?>
$attachments = $post->getAttachments();


... and so on. Also i have some conditional statements that does not work .
Are there any other files that should be included in the module that will allow me to use the post layout, similar code as in "frontpage.post.php" ?

PS: Sorry for keep getting back to you with some "developer-friendly" needs, but this can be also helpfull for somebody else looking to achieve the same thing. EasyDiscuss is great but with a little touch and customization is simply PERFECT !
Hello Mist,

I am really sorry for the delay of this reply as it is a weekend for us here. The variables that you see in the theme files are different than the modules. This is because they are 2 separate stuffs. Components are components and modules are modules. To see what variables are exposed to the module's template file, take a look at the main module file which is /modules/mod_recentdiscussions/mod_recentdiscussions.php
·
Saturday, 15 March 2014 14:00
·
0 Likes
·
0 Votes
·
0 Comments
·
In mod_recentdiscussions.php i can see only these 2 variables


$itemid = DiscussRouter::getItemId('post');
$posts = modRecentDiscussionsHelper::getData($params);


I also checked /modules/mod_recentdiscussions/helper.php but can;t seems to figure things out.

What i need is this (pretty much similar with frontpage.post.php) .

1. Post Category

<?php echo $post->category; ?>


2. Post Reply related stuff

a) replyer profile link:   <?php echo $post->reply->getLink();?>
b) replyer name: <?php echo $post->reply->getName(); ?>
c) replyer avatar: <?php echo $post->reply->getAvatar();?>
d) last reply "time ago" : <?php echo $post->duration; ?>


3. Conditional statement if post reply exists

    <?php if( isset( $post->reply ) ){ ?>
<?php if( $post->reply->id ){ ?>

do something ...

<?php } ?>
<?php } else { ?>
do something else
<?php } ?>



4. Loading first post attachment

<?php
$attachments = $post->getAttachments();
$attachment = isset( $attachments[ 0 ] ) ? $attachments[ 0 ] : false;
if( $attachment )
{
?>
<img src="<?php echo JURI::root() . 'index.php?option=com_easydiscuss&controller=attachment&task=displayFile&tmpl=component&size=thumb&id=' . $attachment->id;?>"/>
<?php
}
?>



All of the above work flawless in frontpage.post.php file. I think there is some stuff not loaded inside $post variable for mod_recentdiscussions.
·
Saturday, 15 March 2014 21:20
·
0 Likes
·
0 Votes
·
0 Comments
·
The result list in the mod_recentdiscussions are just plain objects unlike the one on the component. You will need to customize the module if you want to render the posts table. The code in the module's helper.php should look like this


$posts = array();
require_once DISCUSS_HELPERS . '/parser.php';

foreach( $result as $row )
{
$post = DiscussHelper::getTable('Post');
$post->load($row->id);

$profile = DiscussHelper::getTable( 'Profile' );
$profile->load( $row->user_id );

$post->profile = $profile;
$post->content = EasyDiscussParser::bbcode( $row->content );

$post->title = DiscussHelper::wordFilter( $row->title );
$post->content = strip_tags( html_entity_decode( DiscussHelper::wordFilter( $row->content) ) );

// Process bbcode
$post->content = EasyDiscussParser::bbcode( $row->content );

$posts[] = $post;
}

// Append profile objects to the result
return $posts;


Also, kindly do please take note that our support policy does not cover customizations as outlined in http://stackideas.com/support as some users seem to continuously take advantages of our assistance. I am just helping you out of good faith

Thanks for understanding
·
Sunday, 16 March 2014 00:02
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry for the trouble. Didn't meant to sound like i'm taking advantage of your kindness. I really appreciate you guys and love your products and support.
I will keep my custom request down to a minimum level or none from now on.
I fully agree with you that support is not meant for this but i thought that putting these code changes request in public we will build an awesome source of knowledge on the forum aswell.
Other people that will seek the same functionality will found the needed code changes.

Also, some requests can involve code changes that are meant to actually improve the product and correct some small glitches.

For example in this case, we have the "Recent Discussions" module. This module is meant to show the recent discussions, including all the "post" information (variables and so on) and make it similar like the way "posts" are shown in the actual EasyDiscuss pages (index page and category page)

In the default recent discussions module, posts are "stripped out" of information ..... but anyway i will figure out things or hire somebody to do it.

PS Your code for helper.php does not solve it. I tried to replace that chunk of code with one you provided but still not working.
Anyway ...i will try to find a good developer that knows your products code. I will contact you in private maybe you can suggest me one.
You guys should start to take into consideration paid customization requests.
·
Sunday, 16 March 2014 00:47
·
0 Likes
·
0 Votes
·
0 Comments
·
Ah, I guess I missed the magic part. Try this,


$posts = array();
require_once DISCUSS_HELPERS . '/parser.php';

foreach( $result as $row )
{
$post = DiscussHelper::getTable('Post');
$post->load($row->id);

$profile = DiscussHelper::getTable( 'Profile' );
$profile->load( $row->user_id );

$post->profile = $profile;
$post->content = EasyDiscussParser::bbcode( $row->content );

$post->title = DiscussHelper::wordFilter( $row->title );
$post->content = strip_tags( html_entity_decode( DiscussHelper::wordFilter( $row->content) ) );

// Process bbcode
$post->content = EasyDiscussParser::bbcode( $row->content );

$posts[] = $post;
}

DiscussHelper::formatPost($posts, false, true);
// Append profile objects to the result
return $posts;
·
Sunday, 16 March 2014 01:03
·
0 Likes
·
0 Votes
·
0 Comments
·
Still a no go

See the attached modified helper.php with your latest code change. Even with this modified helper the below code does not output anything.

<?php echo $post->category; ?>
·
Sunday, 16 March 2014 01:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Perhaps try turning on error reporting to the fullest and see if you hit any errors?
·
Tuesday, 18 March 2014 13:38
·
0 Likes
·
0 Votes
·
0 Comments
·
When i set-up error reporting in joomla to "developer" mode, i get a bunch of notices
"Notice: Undefined property: DiscussPost:"
" Notice: Undefined offset:"
"Notice: Undefined variable:"

so no errors just a lot of notices, i just give an example of them above, there are a lot.

So, there is basically no magic trick that will allow me to just copy-paste the same layout (including the same variables) from "frontpages.post.php" template file, in the module's default.php template file ?

I want this module to replicate the EXACTLY same "frontpage.post.php" template file output.

Thanks so much for this Mark !
·
Wednesday, 19 March 2014 06:21
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mist,

Unfortunately no, modules are modules and components are components
·
Wednesday, 19 March 2014 12:02
·
0 Likes
·
0 Votes
·
0 Comments
·
So, any other developer around community that will like to contribute to this ? We really need a way to hack this module to obtain the same item output as in "frontpages.post.php" template file.

The module is great but if we can't find a way to output all the post information in it, we can't use it.
·
Saturday, 05 April 2014 08:48
·
0 Likes
·
0 Votes
·
0 Comments
·
I wish I could help but I am currently occupied with lots of work
·
Saturday, 05 April 2014 15:55
·
0 Likes
·
0 Votes
·
0 Comments
·
Sure, no problem, thanks anyway Mark. Hopefully i will find a solution in the end. We are pretty close to our project launch and we must figure out this module aswell.

If you have some spare time or maybe other guys from your support team can provide a fix (if possible and when you guys have time).
Maybe this fix can make into an official module update. I am pretty sure that some other users may want to display more post information in this module.

Thanks !
·
Wednesday, 09 April 2014 23:35
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Mist! Your site would be a really great testament to our products and I really wish we can showcase the site if it's online and it let's the world know that you can achieve similar sites like this on Joomla! (I always hear people say that Joomla always looks the same)
·
Wednesday, 09 April 2014 23:51
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post