[SOLVED] Bulletin only shows 1 result

13 years 3 months ago - 13 years 1 month ago #150277 by sfraise
[SOLVED] Bulletin only shows 1 result was created by sfraise
Hi, I've done quite a bit of customization to the Groupjive component and for some reason I'm having what seems like a silly issue.

The latest bulletin section only returns 1 result, here is how it's queried in the groupjive_func.php:
[code:1]
$query .= "\n FROM " . $_CB_database->NameQuote( '#__gj_bul' ) . " AS a"
. "\n INNER JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS b"
. ' ON a.' . $_CB_database->NameQuote( 'author_id' ) . ' = b.' . $_CB_database->NameQuote( 'id' )
. "\n WHERE a." . $_CB_database->NameQuote( 'group_id' ) . " = " . (int) $gid
. "\n ORDER BY a." . $_CB_database->NameQuote( 'date_bul' ) . " DESC LIMIT 5";
[/code:1]

I have it set to 5 in the admin section as well. This was originally set to desc limit 1 so I changed it to 5 which in my mind should have changed it but it didn't. I also tried desc limit 0, 5 and 1, 5 and nothing seems to work. If I change it to desc limit 0 it doesn't return any results and if I change it to 2, 5 it returns the second result but still only 1 result. Obviously the desc limit is working, but any ideas why it's only returning one result? I must be missing something somewhere.

Please Log in to join the conversation.

13 years 3 months ago #150337 by krileon
Replied by krileon on topic Re:Bulletin only shows 1 result
This is because the function is latestbul. It's designed and intended from the core to get the single latest bulletin and not the 5 latest bulletins for example. You'd need to also adjust the display and not just the query. Further down you'll find the display part.

[code:1]
if ( $total > 0 ) {
$row = $result[0];
$content .= '<h4><a href="' . cbSef( 'index.php?option=com_groupjive&action=gj.core.bulletin.showfullmessage&idm=' . $row->id . '&groupid=' . (int) $gid . '&Itemid=' . $Itemid ) .'">' . $row->subject . '</a></h4><p>' . $row->post . '</p>' . htmlspecialchars( $row->author_name );
} else {
$content .= GJ_NO_MESSAGE;
}
[/code:1]

It's designed to handle a single row. I recommend changing it to the below. Further additions maybe required, but this is just a example.

[code:1]
if ( $total > 0 ) {
foreach ( $result as $row ) {
$content .= '<h4><a href="' . cbSef( 'index.php?option=com_groupjive&action=gj.core.bulletin.showfullmessage&idm=' . $row->id . '&groupid=' . (int) $gid . '&Itemid=' . $Itemid ) .'">' . $row->subject . '</a></h4><p>' . $row->post . '</p>' . htmlspecialchars( $row->author_name );
}
} else {
$content .= GJ_NO_MESSAGE;
}
[/code:1]

You'd of course need to ensure LIMIT was greater then 1, but IF it was 1 it should still display that 1 post perfectly fine.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 2 months ago #154471 by hunt
Replied by hunt on topic Re:Bulletin only shows 1 result
That workde great! Thanks:evil:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.211 seconds

Facebook Twitter LinkedIn