Inline Banners Ad – Баннери между мненията
Автор: drlevine
Файловете в урока не са преведени, но мисля че менюто е доста „easy“ че дори и човек който тепърва си инсталлира phpBB2 форум ще го разбере 🙂
Мисля, че ще Ви зарадвам много с този урок тъй като в последо време много се разпитваше за такъв мод .. и с дълго търсене и мъчене го намерих за ваше и мое удолетворение 🙂
Започваме със SQL-а
CREATE TABLE `phpbb_inline_ads` (
`ad_id` TINYINT( 5 ) NOT NULL auto_increment,
`ad_code` TEXT NOT NULL ,
`ad_name` CHAR( 25 ) NOT NULL,
PRIMARY KEY (`ad_id`)
);
INSERT INTO `phpbb_inline_ads` (`ad_id` , `ad_code`, `ad_name` )
VALUES
('1', 'Your banner code goes here', 'Default');
INSERT INTO `phpbb_config` ( `config_name` , `config_value` )
VALUES
('ad_after_post', '1'),
('ad_post_threshold', ''),
('ad_every_post', ''),
('ad_who', '1'),
('ad_no_forums', ''),
('ad_no_groups', ''),
('ad_old_style', '1');После копираме тези файлове както и където трябва:
copy inline_ad_config_body.tpl to templates/subSilver/admin/inline_ad_config_body.tpl
copy inline_ad_code_body.tpl to templates/subSilver/admin/inline_ad_code_body.tpl
copy inline_ad_code_edit.tpl to templates/subSilver/admin/inline_ad_code_edit.tpl
copy admin_inline_ad.php to admin/admin_inline_ad.php
copy admin_inline_ad_code.php to admin/admin_inline_ad_code.php
Отваряме viewtopic.php
Търсим:
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];След него добавяме:
$inline_ad_code = '';
$display_ad = ($i == $board_config['ad_after_post'] - 1) || (($board_config['ad_every_post'] != 0) && ($i + 1) % $board_config['ad_every_post'] == 0);
//This if statement should keep server processing down a bit
if ($display_ad)
{
$display_ad = ($board_config['ad_who'] == ALL) || ($board_config['ad_who'] == ANONYMOUS && $userdata['user_id'] == ANONYMOUS) || ($board_config['ad_who'] == USER && $userdata['user_id'] != ANONYMOUS);
$ad_no_forums = explode(",", $board_config['ad_no_forums']);
for ($a=0; $a < count($ad_no_forums); $a++){
if ($forum_id == $ad_no_forums[$a]){
$display_ad = false;
break;
}
}
if ($board_config['ad_no_groups'] != '')
{
$ad_no_groups = explode(",", $board_config['ad_no_groups']);
$sql = "SELECT 1
FROM " . USER_GROUP_TABLE . "
WHERE user_id=" . $userdata['user_id'] . " AND (group_id=0";
for ($a=0; $a < count($ad_no_groups); $a++){
$sql .= " OR group_id=" . $ad_no_groups[$a];
}
$sql .= ")";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)){
$display_ad = false;
}
}
if (($board_config['ad_post_threshold'] != '') &&($userdata['user_posts'] >= $board_config['ad_post_threshold']))
{
$display_ad = false;
}
}
//check once more, for server performance
if ($display_ad)
{
$sql = "SELECT a.ad_code
FROM " . ADS_TABLE . " a";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
}
$adRow = array();
$adRow = $db->sql_fetchrowset($result);
srand((double)microtime()*1000000);
$adindex = rand(1, $db->sql_numrows($result)) - 1;
$db->sql_freeresult($result);
$inline_ad_code = $adRow[$adindex]['ad_code'];
}Търсим:
'DELETE' => $delpost,След него добавяме:
'L_SPONSOR' => $lang['Sponsor'],
'INLINE_AD' => $inline_ad_code,Търсим:
'U_POST_ID' => $postrow[$i]['post_id'])
);След него добавяме:
if ($display_ad){
if (!$board_config['ad_old_style'] && $display_ad)
{
$template->assign_block_vars('postrow.switch_ad',array());
}
else
{
$template->assign_block_vars('postrow.switch_ad_style2',array());
}
}Отваряме: includes/constants.php
Търсим:
define('AUTH_ATTACH', 11);След него добавяме:
define('ALL', 1);Търсим:
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');След него добавяме:
define('ADS_TABLE', $table_prefix.'inline_ads');Отваряме: templates/ВАШИЯТ СТИЛ/overall_header.tpl
Търсим:
.helpline { background-color: {T_TR_COLOR2}; border-style: none; }След него добавяме:
td.inlineadtitle {
background-color: {T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid; border-width: 1px;
}
td.inlinead {
background-color: {T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid; border-width: 1px; text-align: center;
}Отваряме: templates/ВАШИЯТ СТИЛ/viewtopic_body.tpl
Търсим:
<!-- END postrow -->Преди него добавяме:
<!-- BEGIN switch_ad -->
<tr>
<td width="150" align="left" valign="top" class="inlineadtitle"><span class="name"><b>{postrow.L_SPONSOR}</b></span><br /</td>
<td class="inlinead" width="100%" height="28" valign="top">
{postrow.INLINE_AD}
</td>
</tr>
<tr>
<td class="spaceRow" colspan="2" height="1"><img src="templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<!-- END switch_ad -->
<!-- BEGIN switch_ad_style2 -->
<tr>
<td colspan=2 class="inlinead">
{postrow.INLINE_AD}
</td>
</tr>
<!-- END switch_ad_style2 -->Отваряме: language/lang_ЕЗИК/lang_main.php
Търсим:
?>Преди него добавяме:
$lang['Sponsor'] = 'Sponsor';Отваряме: language/lang_ЕЗИК/lang_admin.php
Търсим:
?>Преди него добавяме:
$lang['ad_managment'] = 'Ad Management';
$lang['inline_ad_config'] = 'Inline Ad Config';
$lang['inline_ads'] = 'Inline Ads';
$lang['ad_code_about'] = 'This page lists current ads. You may edit, delete or add new ads here.';
$lang['Click_return_firstpost'] = 'Click %sHere%s to return to Inline Ad Configuration';
$lang['Click_return_inline_code'] = 'Click %sHere%s to return to Inline Ad Code Configuration';
$lang['ad_after_post'] = 'Display Ad After x Post';
$lang['ad_every_post'] = 'Display Ad Every x Post';
$lang['ad_display'] = 'Display Ads To';
$lang['ad_all'] = 'All';
$lang['ad_reg'] = 'Registered Users';
$lang['ad_guest'] = 'Guests';
$lang['ad_exclude'] = 'Exclude These Groups (List by comma-seperated group ID)';
$lang['ad_forums'] = 'Exclude These Forums (List by comma-seperated forum ID)';
$lang['ad_code'] = 'Ad Code';
$lang['ad_style'] = 'Display Style';
$lang['ad_new_style'] = 'Ad looks like a special user post';
$lang['ad_old_style'] = 'Ad falls inline with the topic';
$lang['ad_post_threshold'] = 'Do not display if user has more than x posts (Leave blank to disable)';
$lang['ad_add'] = 'Add New Ad';
$lang['ad_name'] = 'Short name to identify ad';Затваряме и записваме 🙂


