• Главная
  • » PHP
  • » Smarty на примере модификации форума PunBB

#31 2012.02.20 14:00

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

В архиве все.


Вложения

Отредактировано tipsun (2012.02.20 14:55)

Неактивен

#32 2012.02.20 15:19

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

эм нет. в папке include/template есть уже несколько шаблонов, нужно развивать их там дальше.
сам Smarty тоже стоит положить в includes. themes положить в include/template

Неактивен

#33 2012.02.20 15:46

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Это получится так типа:

- include/template/themes/THEME_NAME/templates/TPL_NAME.tpl
- include/template/themes/THEME_NAME/compiled/~
- include/template/themes/THEME_NAME/cache/~
- include/template/themes/THEME_NAME/configs/~
- include/template/themes/THEME_NAME/style.css

Отредактировано tipsun (2012.02.20 15:48)

Неактивен

#34 2012.02.20 15:48

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

еще даже можно, наверн в themes 2 подпапки добавить wap и web и в них ложить темы для того и другого отдельно

Неактивен

#35 2012.02.20 15:50

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Ок.
Я в dcms видел, что они просто префикс добавляли: "wap_", "pda_", "web_".
Поэтому думал, может так и сделать.
Добавлено спустя   6 минут  26 секунд:
Еще надо будет в верстке указывать (через переменную можно):

Код:

1
span style="color: #0000BB"><?php$smarty->template_dir = PUN_ROOT . 'include/template/themes/wap/' . $pun_user['style_wap'] . '/tpls/';$smarty->compile_dir = PUN_ROOT . 'include/template/themes/wap/' . $pun_user['style_wap'] . '/compiled/';$smarty->config_dir = PUN_ROOT . 'include/template/themes/wap/' . $pun_user['style_wap'] . '/configs/';$smarty->cache_dir = PUN_ROOT . 'include/template/themes/wap/' . $pun_user['style_wap'] . '/cache/';/*$smarty->template_dir = PUN_ROOT . 'include/template/themes/' . $pun_user['style_wap'] . '/tpls/';$smarty->compile_dir = PUN_ROOT . 'include/template/themes/' . $pun_user['style_wap'] . '/compiled/';$smarty->config_dir = PUN_ROOT . 'include/template/themes/' . $pun_user['style_wap'] . '/configs/';$smarty->cache_dir = PUN_ROOT . 'include/template/themes/' . $pun_user['style_wap'] . '/cache/';*///<!-- +TEMPLATE --> <head> <title>{$page_title|escape}</title> <link rel="stylesheet" type="text/css" href="/include/template/themes/wap/{$pun_user.style_wap}/style.css" /> //<!-- <link rel="stylesheet" type="text/css" href="/include/template/themes/{$pun_user.style_wap}/style.css" /> --> </head>//<!-- -TEMPLATE -->

Отредактировано tipsun (2012.02.20 16:03)

Неактивен

#36 2012.02.20 16:18

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

А если включить мозги, то так можно:

Код:

1
span style="color: #0000BB"><?php//без слеша впереди, потом можно добавить в "подключении" css.define('THEME_DIR', 'include/template/themes/wap/' . $pun_user['style_wap'] . '/');$smarty->template_dir = PUN_ROOT . THEME_DIR . '/tpls/';$smarty->compile_dir = PUN_ROOT . THEME_DIR . '/compiled/';$smarty->config_dir = PUN_ROOT . THEME_DIR . '/configs/';$smarty->cache_dir = PUN_ROOT . THEME_DIR . '/cache/';/* HTML<link rel="stylesheet" type="text/css" href="/{$smarty.const.THEME_DIR}/style.css" />*/

Отредактировано tipsun (2012.02.20 16:23)

Неактивен

#37 2012.02.20 16:45

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Не знаю как тут с запросом быть.
Просто сделал, что типа карма уже будет готовая выводиться в массиве.

Код:

1
span style="color: #0000BB"><?php//Пост должен содержать типа такого.$cur_post['karma']['val'] = 'integer karma'; if ($pun_config['o_show_post_karma'] == 1 || $pun_user['g_id'] < PUN_GUEST) { $q = $db->fetch_row($db->query(' SELECT COUNT(1), (SELECT COUNT(1) FROM `' . $db->prefix . 'karma` WHERE `vote` = "-1" AND `to` = ' . $cur_post['poster_id'] . ') FROM `' . $db->prefix . 'karma` WHERE `vote` = "1" AND `to` = ' . $cur_post['poster_id'] )); $karma['plus'] = intval($q[0]); $karma['minus'] = intval($q[1]); $karma['karma'] = $karma['plus'] - $karma['minus']; unset($q); if ($pun_user['is_guest']) { $karma = ' (' . $karma['karma'] . ')'; } else if ($db->num_rows($db->query('SELECT 1 FROM `' . $db->prefix . 'karma` WHERE `id`=' . $pun_user['id'] . ' AND `to`=' . $cur_post['poster_id'] . ' LIMIT 1'))) { $karma = ' (' . $karma['karma'] . ')'; } else { $karma = ' (' . $karma['karma'] . ') <a href="karma.php?to=' . $cur_post['poster_id'] . '&amp;vote=1&amp;pid=' . $cur_post['id'] . '">+</a>/<a href="karma.php?to=' . $cur_post['poster_id'] . '&amp;vote=-1&amp;pid=' . $cur_post['id'] . '">-</a>'; } } //Template //<!-- +Karma --> {if $cur_post.karma.val and $pun_config.o_show_post_karma == 1 || $pun_user.g_id < $smarty.const.PUN_GUEST} &#160;({$cur_post.karma.val}) {if ! $pun_user.is_guest} &#160;<a href="karma.php?to={$cur_post.poster_id}&amp;vote=1&amp;pid={$cur_post.id}">+</a>/<a href="karma.php?to={$cur_post.poster_id}&amp;vote=-1&amp;pid={$cur_post.id}">-</a> {/if} {/if} //<!-- -Karma -->

Отредактировано tipsun (2012.02.20 16:52)

Неактивен

#38 2012.02.20 16:57

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Нет, надо было оставить "used".

$cur_post['karma']['val'] - значение кармы
$cur_post['karma']['used'] - уже ставил этому пользователю, если ставил, то задать true.

Вот короче:

Код:

1
2
3
4
5
6
7
8
9
//Template
//<!-- +Karma -->
{if $pun_config.o_show_post_karma == 1 || $pun_user.g_id < $smarty.const.PUN_GUEST}
 ({$cur_post.karma.val})
{if ! $pun_user.is_guest and ! $cur_post.karma.used}
 <a href="karma.php?to={$cur_post.poster_id}&amp;vote=1&amp;pid={$cur_post.id}">+</a>/<a href="karma.php?to={$cur_post.poster_id}&amp;vote=-1&amp;pid={$cur_post.id}">-</a>
{/if}
{/if}
//<!-- -Karma -->

Отредактировано tipsun (2012.02.20 17:17)

Неактивен

#39 2012.02.20 17:08

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Сейчас еще вытащу все assign с цикла шаблона big_smile Я сначала даже и не подумал.
Добавлено спустя   6 минут  30 секунд:
Осталось: карма, аватарка и еще

Код:

1
span style="color: #0000BB"><?php// Can we or can we not post replies?if (!$cur_topic['closed']) { if ((!$cur_topic['post_replies'] && ($pun_user['g_post_replies'] == 1 || $pun_user['g_post_replies'] == 2)) || $cur_topic['post_replies'] == 1 || $is_admmod) { $post_link = '<a href="post.php?tid='.$id.'">'.$lang_topic['Post reply'].'</a>'; } else { $post_link = '&#160;'; }} else { $post_link = $lang_topic['Topic closed']; if ($is_admmod) { $post_link .= ' / <a href="post.php?tid='.$id.'">'.$lang_topic['Post reply'].'</a>'; }}if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == 1) { if ($cur_topic['is_subscribed']) { // I apologize for the variable naming here. It's a mix of subscription and action I guess :-) $subscraction = '<div class="con">'.$lang_topic['Is subscribed'].' - <a href="misc.php?unsubscribe='.$id.'">'.$lang_topic['Unsubscribe'].'</a></div>'; } else { $subscraction = '<div class="con"><a href="misc.php?subscribe='.$id.'">'.$lang_topic['Subscribe'].'</a></div>'; }} else { $subscraction = null;} // Switch the background color for every message. $bg_switch = !$bg_switch; $vtbg = ($bg_switch) ? ' roweven' : ' rowodd'; // Perform the main parsing of the message (BBCode, smilies, censor words etc) $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies'], $cur_post['id']); // Do signature parsing/caching if ($cur_post['signature'] && $pun_user['show_sig']) { if (isset($signature_cache[$cur_post['poster_id']])) { $signature = $signature_cache[$cur_post['poster_id']]; } else { $signature = parse_signature($cur_post['signature']); $signature_cache[$cur_post['poster_id']] = $signature; } } $save_attachments = $attachments; $attachments = array_filter($attachments, 'filter_attachments_of_post'); if ($attachments) { include PUN_ROOT.'include/attach/wap_view_attachments.php'; } $attachments = $save_attachments; if ($is_admmod) { if (isset($cur_post['spam_id'])) { include_once PUN_ROOT . 'lang/' . $pun_user['language'] . '/misc.php'; echo '<br/>'.$lang_misc['Antispam pattern'].' - '.pun_htmlspecialchars($cur_post['pattern']).'<br /><a href="./antispam_misc.php?action=allow&amp;id='.$cur_post['spam_id'].'">'.$lang_misc['Antispam tread'].'</a> | <a href="./antispam_misc.php?action=deny&amp;id='.$cur_post['spam_id'].'">'.$lang_misc['Antispam del'].'</a><br />'; } }if ($cur_post['signature'] && $pun_user['show_sig']) { if (isset($signature_cache[$cur_post['poster_id']])) { $signature = $signature_cache[$cur_post['poster_id']]; } else { $signature = parse_signature($cur_post['signature']); $signature_cache[$cur_post['poster_id']] = $signature; } }

Отредактировано tipsun (2012.02.20 17:25)

Неактивен

#40 2012.02.20 17:38

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Пойду отдыхать, а то глаза уже болят...
Добавлено спустя   8 минут  41 секунду:

tipsun написал:

А если включить мозги, то так можно:

Код:

1
span style="color: #0000BB"><?php//без слеша впереди, потом можно добавить в "подключении" css.define('THEME_DIR', 'include/template/themes/wap/' . $pun_user['style_wap'] . '/');$smarty->template_dir = PUN_ROOT . THEME_DIR . '/tpls/';$smarty->compile_dir = PUN_ROOT . THEME_DIR . '/compiled/';$smarty->config_dir = PUN_ROOT . THEME_DIR . '/configs/';$smarty->cache_dir = PUN_ROOT . THEME_DIR . '/cache/';/* HTML<link rel="stylesheet" type="text/css" href="/{$smarty.const.THEME_DIR}/style.css" />*/

А если этими мозгами еще подумать, то:

Код:

1
span style="color: #0000BB"><?phpdefine('THEME_DIR', PUN_ROOT . 'include/template/themes/wap/' . $pun_user['style_wap'] . '/');$smarty->template_dir = THEME_DIR . '/tpls/';$smarty->compile_dir = THEME_DIR . '/compiled/';$smarty->config_dir = THEME_DIR . '/configs/';$smarty->cache_dir = THEME_DIR . '/cache/';////<link rel="stylesheet" type="text/css" href="{$smarty.const.THEME_DIR}/style.css" />//

Отредактировано tipsun (2012.02.20 17:48)

Неактивен

  • Главная
  • » PHP
  • » Smarty на примере модификации форума PunBB

Дополнительно

forum.wapinet.ru

PunBB Mod v0.6.2
0.019 s