Я угадал?
Выводит последние фото альбома на главную
Версия : Social Engine v3x
Установка
Открываем home.php и в самом низу вставляем
PHP:
// RECENT ALBUM
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "album_datecreated DESC"; }
if(isset($_POST['v'])) { $v = $_POST['v']; } elseif(isset($_GET['v'])) { $v = $_GET['v']; } else { $v = 0; }
// ENSURE SORT/VIEW ARE VALID
if($s != "album_datecreated DESC" && $s != "album_dateupdated DESC") { $s = "album_dateupdated DESC"; }
if($v != "0" && $v != "1") { $v = 0; }
// SET WHERE CLAUSE
$where = "CASE
WHEN se_albums.album_user_id={$user->user_info[user_id]}
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_REGISTERED) AND {$user->user_exists}<>0)
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_ANONYMOUS) AND {$user->user_exists}=0)
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_FRIEND) AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_albums.album_user_id AND friend_user_id2={$user->user_info[user_id]} AND friend_status='1' LIMIT 1))
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_SUBNET) AND {$user->user_exists}<>0 AND (SELECT TRUE FROM se_users WHERE user_id=se_albums.album_user_id AND user_subnet_id={$user->user_info[user_subnet_id]} LIMIT 1))
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_FRIEND2) AND (SELECT TRUE FROM se_friends AS friends_primary LEFT JOIN se_users ON friends_primary.friend_user_id1=se_users.user_id LEFT JOIN se_friends AS friends_secondary ON friends_primary.friend_user_id2=friends_secondary.friend_user_id1 WHERE friends_primary.friend_user_id1=se_albums.album_user_id AND friends_secondary.friend_user_id2={$user->user_info[user_id]} AND se_users.user_subnet_id={$user->user_info[user_subnet_id]} LIMIT 1))
THEN TRUE
ELSE FALSE
END";
// ONLY MY FRIENDS' ALBUMS
if($v == "1" && $user->user_exists) {
// SET WHERE CLAUSE
$where .= " AND (SELECT TRUE FROM se_friends WHERE friend_user_id1={$user->user_info[user_id]} AND friend_user_id2=se_albums.album_user_id AND friend_status=1)";
}
// CREATE ALBUM OBJECT
$album = new se_album();
// GET TOTAL ALBUMS
$total_albums = $album->album_total($where);
// MAKE ENTRY PAGES
$albums_per_page = 4;
$page_vars = make_page($total_albums, $albums_per_page, $p);
// GET ALBUM ARRAY
$album_array = $album->album_list($page_vars[0], $albums_per_page, $s, $where);
// ASSIGN SMARTY VARIABLES AND DISPLAY ALBUMS PAGE
$smarty->assign('albums', $album_array);
$smarty->assign('total_albums', $total_albums);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($album_array));
$smarty->assign('s', $s);
$smarty->assign('v', $v);
И в home.tpl в любом месте вставляем
PHP:
{* RECENT ALBUM *}
<div class='portal_spacer'></div>
<div class='header'><img src="./images/icons/album_album16.gif"> Recent Albums</div>
<div class='portal_content'>
{* SET ALBUM COVER *}
{if $albums[album_loop].album_cover_id == 0}
{assign var='album_cover_src' value='./images/icons/album_album16.gif'}
{else}
{* IF IMAGE, GET THUMBNAIL *}
{if $albums[album_loop].album_cover_ext == "jpeg" || $albums[album_loop].album_cover_ext == "jpg" || $albums[album_loop].album_cover_ext == "gif" || $albums[album_loop].album_cover_ext == "png" || $albums[album_loop].album_cover_ext == "bmp"}
{assign var='album_cover_dir' value=$url->url_userdir($albums[album_loop].album_author->user_info.user_id)}
{assign var='album_cover_src' value="`$album_cover_dir``$albums[album_loop].album_cover_id`_thumb.jpg"}
{* SET THUMB PATH FOR AUDIO *}
{elseif $albums[album_loop].album_cover_ext == "mp3" || $albums[album_loop].album_cover_ext == "mp4" || $albums[album_loop].album_cover_ext == "wav"}
{assign var='album_cover_src' value='./images/icons/audio_big.gif'}
{* SET THUMB PATH FOR VIDEO *}
{elseif $albums[album_loop].album_cover_ext == "mpeg" || $albums[album_loop].album_cover_ext == "mpg" || $albums[album_loop].album_cover_ext == "mpa" || $albums[album_loop].album_cover_ext == "avi" || $albums[album_loop].album_cover_ext == "swf" || $albums[album_loop].album_cover_ext == "mov" || $albums[album_loop].album_cover_ext == "ram" || $albums[album_loop].album_cover_ext == "rm"}
{assign var='album_cover_src' value='./images/icons/video_big.gif'}
{* SET THUMB PATH FOR UNKNOWN *}
{else}
{assign var='album_cover_src' value='./images/icons/album_album16.gif'}
{/if}
{/if}
{section name=album_loop loop=$albums}
<table cellpadding='0' cellspacing='0'>
<tr>
<td style='vertical-align: top;'>
<a href='{$url->url_create('album', $albums[album_loop].album_author->user_info.user_username, $albums[album_loop].album_id)}'><img src='{$album_cover_src}' border='0'></a>
</td>
<td style='vertical-align: top; padding-left: 8px;'>
<div style='font-weight: bold; font-size: 8pt'><a href='{$url->url_create('album', $albums[album_loop].album_author->user_info.user_username, $albums[album_loop].album_id)}'>{$albums[album_loop].album_title|truncate:30:"...":true}</a></div>
<div class='album_browse_date'>
{lang_sprintf id=1000172 1=$albums[album_loop].album_files} - {lang_sprintf id=1000124 1=$updated 2=$url->url_create("profile", $albums[album_loop].album_author->user_info.user_username) 3=$albums[album_loop].album_author->user_displayname}
</div>
<div>{$albums[album_loop].album_desc|truncate:75:"...":true}</div>
</td>
</tr>
</table>
{cycle values=",<div style='clear: both; height: 8px;'></div>"}
{/section}
</div>
Выводит последние 4 записи блогов
Версия : Social Engine v3x
Установка
Открывает home.php в самом конце добавляем
PHP:
// RECENT BLOGS
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "blogentry_date DESC"; }
if(isset($_POST['v'])) { $v = $_POST['v']; } elseif(isset($_GET['v'])) { $v = $_GET['v']; } else { $v = 0; }
if(isset($_POST['c'])) { $c = $_POST['c']; } elseif(isset($_GET['c'])) { $c = $_GET['c']; } else { $c = -1; }
if(isset($_POST['blog_search'])) { $blog_search = $_POST['blog_search']; } elseif(isset($_GET['c'])) { $blog_search = $_GET['blog_search']; } else { $c = NULL; }
// ENSURE SORT/VIEW ARE VALID
if($s != "blogentry_date DESC" && $s != "blogentry_views DESC" && $s != "total_comments DESC") { $s = "blogentry_date DESC"; }
if($v != "0" && $v != "1") { $v = 0; }
// SET WHERE CLAUSE
$where = "CASE
WHEN se_blogentries.blogentry_user_id='{$user->user_info[user_id]}'
THEN TRUE
WHEN ((se_blogentries.blogentry_privacy & @SE_PRIVACY_REGISTERED) AND '{$user->user_exists}'<>0)
THEN TRUE
WHEN ((se_blogentries.blogentry_privacy & @SE_PRIVACY_ANONYMOUS) AND '{$user->user_exists}'=0)
THEN TRUE
WHEN ((se_blogentries.blogentry_privacy & @SE_PRIVACY_FRIEND) AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_blogentries.blogentry_user_id AND friend_user_id2='{$user->user_info[user_id]}' AND friend_status='1' LIMIT 1))
THEN TRUE
WHEN ((se_blogentries.blogentry_privacy & @SE_PRIVACY_SUBNET) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_users WHERE user_id=se_blogentries.blogentry_user_id AND user_subnet_id='{$user->user_info[user_subnet_id]}' LIMIT 1))
THEN TRUE
WHEN ((se_blogentries.blogentry_privacy & @SE_PRIVACY_FRIEND2) AND (SELECT TRUE FROM se_friends AS friends_primary LEFT JOIN se_users ON friends_primary.friend_user_id1=se_users.user_id LEFT JOIN se_friends AS friends_secondary ON friends_primary.friend_user_id2=friends_secondary.friend_user_id1 WHERE friends_primary.friend_user_id1=se_blogentries.blogentry_user_id AND friends_secondary.friend_user_id2='{$user->user_info[user_id]}' AND se_users.user_subnet_id='{$user->user_info[user_subnet_id]}' LIMIT 1))
THEN TRUE
ELSE FALSE
END";
// ONLY MY FRIENDS' BLOGS
if( $v=="1" && $user->user_exists )
{
// SET WHERE CLAUSE
$where .= " AND (SELECT TRUE FROM se_friends WHERE friend_user_id1={$user->user_info[user_id]} AND friend_user_id2=se_blogentries.blogentry_user_id AND friend_status=1)";
}
// CATEGORIES
if( isset($c) && $c!=-1 )
{
if( $c==0 ) $c = '0';
$where .= " AND blogentry_blogentrycat_id='$c'";
}
// CREATE blog OBJECT
$blog = new se_blog();
// GET TOTAL blogs
$total_blogentries = $blog->blog_entries_total($where);
// MAKE ENTRY PAGES
$blogentries_per_page = 4;
$page_vars = make_page($total_blogentries, $blogentries_per_page, $p);
// GET blog ARRAY
$blogentry_array = $blog->blog_entries_list($page_vars[0], $blogentries_per_page, $s, $where);
// ASSIGN SMARTY VARIABLES AND DISPLAY blogs PAGE
$smarty->assign('total_blogentries', $total_blogentries);
$smarty->assign_by_ref('blogentries', $blogentry_array);
$smarty->assign_by_ref('blogentrycats', $blogentrycats_array);
$smarty->assign('blog_search', $blog_search);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($blogentry_array));
$smarty->assign('s', $s);
$smarty->assign('v', $v);
$smarty->assign('c', $c);
Открываем home.tpl и в любом удобном для вас месте вставляем
PHP:
{* RECENT BLOGS *}
<div class='portal_spacer'></div>
<div class='header'><img src="./images/icons/blog_blog16.gif"> Recent Blogs</div>
<div class='portal_content'>
{section name=blogentry_loop loop=$blogentries}
<div style='font-weight: bold; font-size: 8pt;'>
<img src="./images/icons/blog_blog16.gif" class='button' style='float: left;'>
<a href='{$url->url_create("blog_entry", $blogentries[blogentry_loop].blogentry_author->user_info.user_username, $blogentries[blogentry_loop].blogentry_id)}'>
{$blogentries[blogentry_loop].blogentry_title|truncate:30:"...":true}
</a>
</div>
<div class='blogs_browse_date'>
{assign var='blogentry_date' value=$datetime->time_since($blogentries[blogentry_loop].blogentry_date)}{capture assign="created"}{lang_sprintf id=$blogentry_date[0] 1=$blogentry_date[1]}{/capture}
{lang_sprintf id=1500039 1=$created 2=$url->url_create("profile", $blogentries[blogentry_loop].blogentry_author->user_info.user_username) 3=$blogentries[blogentry_loop].blogentry_author->user_displayname}
</div>
{cycle name="blogret" values=",<div style='clear: both; height: 8px;'></div>"}
{/section}
</div>
Хак добавляет блок с наступаюшими событиями на главную страницу.
Установка
Открыть Home.php в самом низу добавить:
PHP:
// ENSURE SORT/VIEW ARE VALID
if($s != "event_datecreated DESC" && $s != "num_members DESC" && $s != "event_date_start DESC" && $s != "event_date_end DESC" && $s != "event_date_start ASC" && $s != "event_date_end ASC") { $s = "event_date_start ASC"; }
if($v != "1" && $v != "2" && $v != "3") { $v = 3; }
// SET WHERE CLAUSE
$where = "CASE
WHEN se_events.event_user_id='{$user->user_info[user_id]}'
THEN TRUE
WHEN ((se_events.event_privacy & 32) AND '{$user->user_exists}'<>0)
THEN TRUE
WHEN ((se_events.event_privacy & 64) AND '{$user->user_exists}'=0)
THEN TRUE
WHEN ((se_events.event_privacy & 2) AND (SELECT TRUE FROM se_eventmembers WHERE eventmember_user_id='{$user->user_info[user_id]}' AND eventmember_event_id=se_events.event_id AND eventmember_status=1 LIMIT 1))
THEN TRUE
WHEN ((se_events.event_privacy & 4) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_events.event_user_id AND friend_user_id2='{$user->user_info[user_id]}' AND friend_status=1 LIMIT 1))
THEN TRUE
WHEN ((se_events.event_privacy & 8) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_eventmembers LEFT JOIN se_friends ON se_eventmembers.eventmember_user_id=se_friends.friend_user_id1 WHERE se_eventmembers.eventmember_event_id=se_events.event_id AND se_friends.friend_user_id2='{$user->user_info[user_id]}' AND se_eventmembers.eventmember_status=1 AND se_friends.friend_status=1 LIMIT 1))
THEN TRUE
WHEN ((se_events.event_privacy & 16) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_eventmembers LEFT JOIN se_friends AS friends_primary ON se_eventmembers.eventmember_user_id=friends_primary.friend_user_id1 LEFT JOIN se_friends AS friends_secondary ON friends_primary.friend_user_id2=friends_secondary.friend_user_id1 WHERE se_eventmembers.eventmember_event_id=se_events.event_id AND se_eventmembers.eventmember_status=1 AND friends_secondary.friend_user_id2='{$user->user_info[user_id]}' AND friends_primary.friend_status=1 AND friends_secondary.friend_status=1 LIMIT 1))
THEN TRUE
ELSE FALSE
END";
// ONLY MY FRIENDS' EVENTS
if( $v=="2" && $user->user_exists )
{
// SET WHERE CLAUSE
$where .= " AND (SELECT TRUE FROM se_friends LEFT JOIN se_eventmembers ON se_friends.friend_user_id2=se_eventmembers.eventmember_user_id WHERE friend_user_id1='{$user->user_info[user_id]}' AND friend_status=1 AND eventmember_event_id=se_events.event_id AND eventmember_status=1 LIMIT 1)";
}
elseif( $v=="3" )
{
$where .= " && se_events.event_date_start>'".time()."' ";
// Force sort?
$s = "event_date_start ASC";
}
// SPECIFIC EVENT CATEGORY
if($eventcat_id != 0) {
$eventcat_query = $database->database_query("SELECT eventcat_id, eventcat_title, eventcat_dependency FROM se_eventcats WHERE eventcat_id=$eventcat_id");
if($database->database_num_rows($eventcat_query)) {
$eventcat = $database->database_fetch_assoc($eventcat_query);
if($eventcat[eventcat_dependency] == 0) {
$cat_ids[] = $eventcat[eventcat_id];
$depcats = $database->database_query("SELECT eventcat_id FROM se_eventcats WHERE eventcat_id={$eventcat[eventcat_id]} OR eventcat_dependency={$eventcat[eventcat_id]}");
while($depcat_info = $database->database_fetch_assoc($depcats)) { $cat_ids[] = $depcat_info[eventcat_id]; }
$where .= " AND se_events.event_eventcat_id IN('".implode("', '", $cat_ids)."')";
} else {
$where .= " AND se_events.event_eventcat_id={$eventcat[eventcat_id]}";
$eventsubcat = $eventcat;
$eventcat = $database->database_fetch_assoc($database->database_query("SELECT eventcat_id, eventcat_title FROM se_eventcats WHERE eventcat_id={$eventcat[eventcat_dependency]}"));
}
}
}
// CREATE EVENT OBJECT
$event = new se_event();
// MAKE ENTRY PAGES
$events_per_page = 10;
$page_vars = make_page($total_events, $events_per_page, $p);
// GET EVENT ARRAY
$event_array = $event->event_list($page_vars[0], $events_per_page, $s, $where, TRUE);
// ASSIGN SMARTY VARIABLES AND DISPLAY EVENTS PAGE
$smarty->assign('eventcat_id', $eventcat_id);
$smarty->assign('eventcat', $eventcat);
$smarty->assign('eventsubcat', $eventsubcat);
$smarty->assign('cats', $cat_array);
$smarty->assign('events', $event_array);
$smarty->assign('total_events', $total_events);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($event_array));
$smarty->assign('s', $s);
$smarty->assign('v', $v);
Открыть home.tpl в любом удобном месте добавить :
PHP:
{* EVENTS ON MAIN PAGE *}
<div class='header'>Upcoming Events</div>
{* NO EVENTS AT ALL *}
{if $events|@count == 0}
<br>
<table cellpadding='0' cellspacing='0' align='center'>
<tr>
<td class='result'>
<img src='./images/icons/bulb16.gif' border='0' class='icon' />
{lang_print id=3000214}
</td>
</tr>
</table>
{/if}
{* DISPLAY PAGINATION MENU IF APPLICABLE *}
{if $maxpage > 1}
<div class='event_pages_top'>
{if $p != 1}<a href='browse_events.php?s={$s}&v={$v}&eventcat_id={$eventcat_id}&p={math equation="p-1" p=$p}'>« {lang_print id=182}</a>{else}« {lang_print id=182}{/if}
|
{if $p_start == $p_end}
<b>{lang_sprintf id=184 1=$p_start 2=$total_events}</b>
{else}
<b>{lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_events}</b>
{/if}
|
{if $p != $maxpage}<a href='browse_events.php?s={$s}&v={$v}&eventcat_id={$eventcat_id}&p={math equation="p+1" p=$p}'>{lang_print id=183} »</a>{else}{lang_print id=183} »{/if}
</div>
{/if}
{section name=event_loop loop=$events}
<div style='padding: 10px; border: 1px solid #CCCCCC; margin-bottom: 10px;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>
<a href='event.php?event_id={$events[event_loop].event->event_info.event_id}'>
<img class='photo' src='{$events[event_loop].event->event_photo("./images/nophoto.gif", TRUE)}' border='0' width='60' height='60' />
</a>
</td>
<td style='vertical-align: top; padding-left: 10px;'>
<div style='font-weight: bold; font-size: 10pt;'>
<a href='event.php?event_id={$events[event_loop].event->event_info.event_id}'>
{$events[event_loop].event->event_info.event_title}
</a>
</div>
<div style='color: #777777; font-size: 7pt; margin-bottom: 2px;'>
{* NO END DATE *}
{if !$events[event_loop].event->event_info.event_date_end}
{lang_sprintf id=3000203 1=$datetime->cdate($setting.setting_dateformat, $event_date_start) 2=$datetime->cdate($setting.setting_timeformat, $event_date_start)}
{* SAME-DAY EVENT *}
{elseif $datetime->cdate("F j, Y", $event_date_start)==$datetime->cdate("F j, Y", $event_date_end)}
{lang_sprintf id=3000202 1=$datetime->cdate($setting.setting_dateformat, $event_date_start) 2=$datetime->cdate($setting.setting_timeformat, $event_date_start) 3=$datetime->cdate($setting.setting_timeformat, $event_date_end)}
{* MULTI-DAY EVENT *}
{else}
{lang_sprintf id=3000204 1=$datetime->cdate("`$setting.setting_dateformat` `$setting.setting_timeformat`", $event_date_start) 2=$datetime->cdate("`$setting.setting_dateformat` `$setting.setting_timeformat`", $event_date_end)}
{/if}
</div>
<div style='color: #777777; font-size: 7pt; margin-bottom: 5px;'>
{assign var=event_date_start value=$datetime->timezone($events[event_loop].event->event_info.event_date_start, $global_timezone)}
{assign var=event_date_end value=$datetime->timezone($events[event_loop].event->event_info.event_date_end, $global_timezone)}
{assign var='event_dateupdated' value=$datetime->time_since($events[event_loop].event->event_info.event_dateupdated)}{capture assign="updated"}{lang_sprintf id=$event_dateupdated[0] 1=$event_dateupdated[1]}{/capture}
{lang_sprintf id=3000215 1=$events[event_loop].num_members} -
{lang_sprintf id=3000216 1=$events[event_loop].event_creator->user_displayname 2=$url->url_create("profile", $events[event_loop].event_creator->user_info.user_username)} -
{lang_sprintf id=3000217 1=$updated}
</div>
<div>
{$events[event_loop].event->event_info.event_desc|truncate:300:"...":true}
</div>
</td>
</tr>
</table>
</div>
{/section}