| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if( ! defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* Layout: Boxed |
| 7 |
* Version: 1.0.0 |
| 8 |
* Author: wpForo Team |
| 9 |
* Description: Modern card-based layout with cover images and clean stats display. |
| 10 |
*/ |
| 11 |
|
| 12 |
$cover_styles = wpforo_get_forum_cover_styles( $cat ); |
| 13 |
?> |
| 14 |
|
| 15 |
<div class="wpfl-5 wpforo-section"> |
| 16 |
<!-- wpforo-category --> |
| 17 |
<div class="wpforo-category" <?php echo $cover_styles['cover'] ?>> |
| 18 |
<div class="wpforo-cat-panel" <?php echo $cover_styles['blur'] ?>> |
| 19 |
<div class="cat-title" title="<?php echo esc_attr( strip_tags( $cat['description'] ) ); ?>"> |
| 20 |
<span class="cat-name" <?php echo $cover_styles['title'] ?>><?php echo esc_html( $cat['title'] ); ?></span> |
| 21 |
</div> |
| 22 |
<?php if( WPF()->current_object['template'] === 'forum' ) wpforo_template_add_topic_button( $cat['forumid'] ); ?> |
| 23 |
</div> |
| 24 |
</div> |
| 25 |
<!-- wpforo-category --> |
| 26 |
|
| 27 |
<?php if( WPF()->current_object['template'] === 'forum' ) wpforo_template_topic_portable_form( $cat['forumid'] ); ?> |
| 28 |
|
| 29 |
<?php |
| 30 |
$forum_list = false; |
| 31 |
?> |
| 32 |
|
| 33 |
<!-- Forums Grid (Only Child Forums, Not Categories) --> |
| 34 |
<div class="wpforo-forum-grid"> |
| 35 |
<?php foreach( $forums as $key => $forum ) : |
| 36 |
if( ! WPF()->perm->forum_can( 'vf', $forum['forumid'] ) ) continue; |
| 37 |
|
| 38 |
$forum_list = true; |
| 39 |
|
| 40 |
// Get forum data with full details (including cover_url) |
| 41 |
$forum_full = wpforo_forum( $forum['forumid'] ); |
| 42 |
$data = wpforo_forum( $forum['forumid'], 'childs' ); |
| 43 |
$counts = wpforo_forum( $forum['forumid'], 'counts' ); |
| 44 |
$forum_url = wpforo_forum( $forum['forumid'], 'url' ); |
| 45 |
|
| 46 |
// Get cover image URL (wpForo provides this automatically) |
| 47 |
$cover_image_url = ! empty( $forum_full['cover_url'] ) ? $forum_full['cover_url'] : ''; |
| 48 |
|
| 49 |
// Get icon |
| 50 |
if( ! empty( $forum['icon'] ) ) { |
| 51 |
$forum['icon'] = trim( (string) $forum['icon'] ); |
| 52 |
if( strpos( (string) $forum['icon'], ' ' ) === false ) $forum['icon'] = 'fas ' . $forum['icon']; |
| 53 |
} |
| 54 |
$forum_icon = ( ! empty( $forum['icon'] ) ) ? $forum['icon'] : 'fas fa-comments'; |
| 55 |
|
| 56 |
// Get recent active users for avatar display (top 3) |
| 57 |
$recent_users = []; |
| 58 |
$recent_topics = WPF()->topic->get_topics( [ |
| 59 |
'forumids' => $data, |
| 60 |
'orderby' => 'modified', |
| 61 |
'order' => 'DESC', |
| 62 |
'row_count' => 3 |
| 63 |
] ); |
| 64 |
if( ! empty( $recent_topics ) ) { |
| 65 |
$user_ids = []; |
| 66 |
foreach( $recent_topics as $topic ) { |
| 67 |
if( ! in_array( $topic['userid'], $user_ids ) ) { |
| 68 |
if( $user = wpforo_member( $topic['userid'] ) ) { |
| 69 |
$recent_users[] = $user; |
| 70 |
$user_ids[] = $topic['userid']; |
| 71 |
if( count( $recent_users ) >= 3 ) break; |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
// Get subforums |
| 78 |
$sub_forums = WPF()->forum->get_forums( [ "parentid" => $forum['forumid'], "type" => 'forum' ] ); |
| 79 |
$has_sub_forums = is_array( $sub_forums ) && ! empty( $sub_forums ); |
| 80 |
?> |
| 81 |
<div id="wpf-forum-<?php echo intval( $forum['forumid'] ) ?>" class="wpforo-forum-card <?php wpforo_unread( $forum['forumid'], 'forum' ) ?>"> |
| 82 |
|
| 83 |
<!-- Card Cover with Stats Overlay (Clickable) --> |
| 84 |
<a href="<?php echo esc_url( (string) $forum_url ); ?>" class="forum-card-cover-link"> |
| 85 |
<div class="forum-card-cover" <?php if( $cover_image_url ): ?>style="background-image: url('<?php echo esc_url( $cover_image_url ); ?>');"<?php else: ?>style="background: linear-gradient(135deg, <?php echo esc_attr( $forum['color'] ); ?>55 0%, <?php echo esc_attr( $forum['color'] ); ?>99 100%);"<?php endif; ?>> |
| 86 |
|
| 87 |
<!-- Stats and Avatars Overlay --> |
| 88 |
<div class="forum-card-overlay"> |
| 89 |
<div class="forum-stats-overlay"> |
| 90 |
<div class="stat-item"> |
| 91 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill: #fff; height: 18px; margin-right: 7px;"> |
| 92 |
<g id="_01_align_center" data-name="01 align center"> |
| 93 |
<path d="M21,0H3A3,3,0,0,0,0,3V20H6.9l3.808,3.218a2,2,0,0,0,2.582,0L17.1,20H24V3A3,3,0,0,0,21,0Zm1,18H16.366L12,21.69,7.634,18H2V3A1,1,0,0,1,3,2H21a1,1,0,0,1,1,1Z"/> |
| 94 |
<rect x="6" y="5" width="6" height="2"/> |
| 95 |
<rect x="6" y="9" width="12" height="2"/> |
| 96 |
<rect x="6" y="13" width="12" height="2"/> |
| 97 |
</g> |
| 98 |
</svg> |
| 99 |
<span class="stat-value"><?php echo wpforo_print_number( $counts['topics'] ); ?></span> |
| 100 |
</div> |
| 101 |
<div class="stat-item"> |
| 102 |
<svg style="fill: #fff; height: 18px; margin-right: 7px; margin-top: 4px; transform: rotate(180deg);" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 103 |
<path d="M23,24a1,1,0,0,1-1-1,6.006,6.006,0,0,0-6-6H10.17v1.586A2,2,0,0,1,6.756,20L.877,14.121a3,3,0,0,1,0-4.242L6.756,4A2,2,0,0,1,10.17,5.414V7H15a9.01,9.01,0,0,1,9,9v7A1,1,0,0,1,23,24ZM8.17,5.414,2.291,11.293a1,1,0,0,0,0,1.414L8.17,18.586V16a1,1,0,0,1,1-1H16a7.984,7.984,0,0,1,6,2.714V16a7.008,7.008,0,0,0-7-7H9.17a1,1,0,0,1-1-1Z"/> |
| 104 |
</svg> |
| 105 |
<span class="stat-value"><?php echo wpforo_print_number( $counts['posts'] ); ?></span> |
| 106 |
</div> |
| 107 |
</div> |
| 108 |
|
| 109 |
<?php if( ! empty( $recent_users ) ): ?> |
| 110 |
<div class="forum-users-overlay"> |
| 111 |
<?php foreach( $recent_users as $user ): ?> |
| 112 |
<div class="user-avatar-mini"> |
| 113 |
<?php echo wpforo_user_avatar( $user, 32 ); ?> |
| 114 |
</div> |
| 115 |
<?php endforeach; ?> |
| 116 |
</div> |
| 117 |
<?php endif; ?> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
</a> |
| 121 |
|
| 122 |
<!-- Card Info (Icon + Title + Description) --> |
| 123 |
<div class="forum-card-info"> |
| 124 |
<!-- |
| 125 |
<div class="forum-card-icon-box"> |
| 126 |
<i class="<?php echo esc_attr( $forum_icon ); ?>" style="color: <?php echo esc_attr( $forum['color'] ); ?>;"></i> |
| 127 |
</div> |
| 128 |
--> |
| 129 |
<div class="forum-card-text"> |
| 130 |
<h3 class="forum-card-title"> |
| 131 |
<a href="<?php echo esc_url( (string) $forum_url ); ?>"><?php echo esc_html( $forum['title'] ); ?></a> |
| 132 |
<?php wpforo_viewing( $forum ); ?> |
| 133 |
</h3> |
| 134 |
<?php if( ! empty( $forum['description'] ) ): ?> |
| 135 |
<div class="forum-card-description"><?php echo wp_kses_post( wpforo_text( $forum['description'], 100, false ) ); ?></div> |
| 136 |
<?php endif; ?> |
| 137 |
|
| 138 |
<?php if( $has_sub_forums ): ?> |
| 139 |
<div class="forum-card-subforums"> |
| 140 |
<?php |
| 141 |
$subforum_links = []; |
| 142 |
foreach( $sub_forums as $sub_forum ): |
| 143 |
if( ! WPF()->perm->forum_can( 'vf', $sub_forum['forumid'] ) ) continue; |
| 144 |
$subforum_links[] = '<a href="' . esc_url( (string) wpforo_forum( $sub_forum['forumid'], 'url' ) ) . '" style="border-bottom: 1px solid ' . esc_attr( $sub_forum['color'] ) . ';">' . esc_html( $sub_forum['title'] ) . '</a>'; |
| 145 |
endforeach; |
| 146 |
echo implode( ' ยท ', $subforum_links ); |
| 147 |
?> |
| 148 |
</div> |
| 149 |
<?php endif; ?> |
| 150 |
</div> |
| 151 |
</div> |
| 152 |
|
| 153 |
</div><!-- wpforo-forum-card --> |
| 154 |
|
| 155 |
<?php do_action( 'wpforo_loop_hook', $key, $forum ) ?> |
| 156 |
|
| 157 |
<?php endforeach; ?> <!-- $forums as $forum --> |
| 158 |
</div><!-- wpforo-forum-grid --> |
| 159 |
|
| 160 |
<?php if( ! $forum_list ): ?> |
| 161 |
<?php do_action( 'wpforo_forum_loop_no_forums', $cat ); ?> |
| 162 |
<?php endif; ?> |
| 163 |
|
| 164 |
</div><!-- wpfl-5 --> |
| 165 |
|