Ручное добавление meta тегов и title при создании релизов

Dr_Brown

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

На выхлопе должно быть следующее:


Please Login or Register to view hidden text.



Остальное по инструкции. Работает на 2.1.1 альфа, думаю на последней 5-й тоже пойдет.

Запрос в базу:

ALTER TABLE `bb_topics` ADD `topic_meta` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;

posting_meta.tpl закинуть в шаблон

config.php------------ find

define('BB_CFG_LOADED', true);

before add

$bb_cfg['allow_meta_in_new_topic'] = true;

posting.php------- find

$mode = (string) @$_REQUEST['mode'];

after add----------

$meta_tags = isset($_REQUEST['meta']) ? (array) $_REQUEST['meta'] : array();

find---------------

submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $topic_type, DB()->escape($username), DB()->escape($subject), DB()->escape($message), $update_post_time, $poster_rg_id, $attach_rg_sig);

in line find---------------

$attach_rg_sig
in line after add-----------

, $meta_tags

find-----------------------

$template->set_filenames(array(
'body' => 'posting.tpl',
));

after add---------------

$topic_meta = isset($post_info['topic_meta']) ? bb_json_decode($post_info['topic_meta']) : array();

find--------------------

'S_POST_ACTION' => POSTING_URL,

after add---------------

'META_TAG_TITLE' => isset($topic_meta['title']) ? $topic_meta['title'] : '',
'META_TAG_DESC' => isset($topic_meta['description']) ? $topic_meta['description'] : '',
'META_TAG_KEYWORD' => isset($topic_meta['keywords']) ? $topic_meta['keywords'] : '',
'META_TAG_AUTHOR' => isset($topic_meta['author']) ? $topic_meta['author'] : '',
'ALLOW_META' => ($post_data['first_post'] && $bb_cfg['allow_meta_in_new_topic']) ? true : false,

/includes/functions_post.php------- find

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig)

in line find---------------

$attach_rg_sig

in line after add---------------

, &$meta_tags_arr)

find--------------------

$current_time = TIMENOW;

after add-------------

$meta_tags = '';

if(!(isset($meta_tags_arr['author']) && $meta_tags_arr['author']))
{
$meta_tags_arr['author'] = ($mode == 'newtopic') ? $userdata['username'] : ($mode == 'reply') ? '' : get_username($post_data['poster_id']);
}
if(isset($meta_tags_arr['title']) && $meta_tags_arr['title']) $meta_tags_arr['title'] = str_replace('"', '', $meta_tags_arr['title']);
if(isset($meta_tags_arr['keywords']) && $meta_tags_arr['keywords']) $meta_tags_arr['keywords'] = mb_strtolower(str_replace('"', '', $meta_tags_arr['keywords']), 'UTF-8');
if(isset($meta_tags_arr['description']) && $meta_tags_arr['description']) $meta_tags_arr['description'] = str_replace('"', '', $meta_tags_arr['description']);
$meta_tags = bb_json_encode($meta_tags_arr);

find--------------------

" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)

in line find---------------

topic_dl_type

in line after add-----------

, topic_meta

find--------------------

('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type)

in line find---------------

$topic_dl_type

in line after add-----------

, '".DB()->escape($meta_tags)."'

find--------------------

topic_dl_type = $topic_dl_type

replace----------------

topic_dl_type = $topic_dl_type,

after add----------------

topic_meta = '".DB()->escape($meta_tags)."'

viewtopic.php------------------- find

$can_add_poll = ($can_manage_poll && !$topic_has_poll && !$poll_time_expired && !$start);

after add-------------

$topic_meta = bb_json_decode($t_data['topic_meta']);

find--------------------

'CAN_ADD_POLL' => $can_add_poll,

after add-----------------

'META_TAG_DESC' => (isset($topic_meta['description']) && $topic_meta['description']) ? $topic_meta['description'] : '',
'META_TAG_KEYWORD' => (isset($topic_meta['keywords']) && $topic_meta['keywords']) ? $topic_meta['keywords'] : '',
'META_TAG_AUTHOR' => (isset($topic_meta['author']) && $topic_meta['author']) ? $topic_meta['author'] : '',

find---------------

'PAGE_TITLE' => $topic_title,

replace----------------

'PAGE_TITLE' => (isset($topic_meta['title']) && $topic_meta['title']) ? $topic_meta['title'] : $topic_title,

page_header.tpl------------- find

<title><!-- IF PAGE_TITLE -->{PAGE_TITLE} :: {SITENAME}<!-- ELSE -->{SITENAME}<!-- ENDIF --></title>

after add----------------

<!-- IF META_TAG_DESC -->
<meta name="description" content="{META_TAG_DESC}" />
<!-- ENDIF -->
<!-- IF META_TAG_KEYWORD -->
<meta name="keywords" content="{META_TAG_KEYWORD}" />
<!-- ENDIF -->
<!-- IF META_TAG_AUTHOR -->
<meta name="author" content="{META_TAG_AUTHOR}" />
<!-- ENDIF -->
<!-- OpenGraph start -->
<meta property="og:site_name" content="{SITENAME}" />
<meta property="og:title" content="<!-- IF PAGE_TITLE -->{PAGE_TITLE} :: {SITENAME}<!-- ELSE -->{SITENAME}<!-- ENDIF -->" />
<!-- IF META_TAG_DESC -->
<meta property="og:description" content="{META_TAG_DESC}" />
<!-- ENDIF -->
<meta property="og:type" content="article" />
<!-- OpenGraph end -->

language/ru/main.php-----end of file, add----------

$lang['META_TOPIC_TAG'] = 'Мета-теги';
$lang['META_TITLE_TAG'] = 'Тег <b>title</b> для топика';
$lang['META_DESC_TAG'] = 'Тег <b>description</b> для топика';
$lang['META_AUTHOR_TAG'] = 'Тег <b>author</b> для топика';
$lang['META_KEYWORD_TAG'] = 'Тег <b>keywords</b> для топика';

language/en/main.php-----end of file, add----------

$lang['META_TOPIC_TAG'] = 'Meta tags';
$lang['META_TITLE_TAG'] = 'Tag <b>title</b> for topic';
$lang['META_DESC_TAG'] = 'Tag <b>description</b> for topic';
$lang['META_AUTHOR_TAG'] = 'Tag <b>author</b> for topic';
$lang['META_KEYWORD_TAG'] = 'Tag <b>keywords</b> for topic';

language/uk/main.php-----end of file, add----------

$lang['META_TOPIC_TAG'] = 'Мета-теги';
$lang['META_TITLE_TAG'] = 'Тег <b>title</b> для топіка';
$lang['META_DESC_TAG'] = 'Тег <b>description</b> для топіка';
$lang['META_AUTHOR_TAG'] = 'Тег <b>author</b> для топіка';
$lang['META_KEYWORD_TAG'] = 'Тег <b>keywords</b> для топіка';

posting.tpl------------- find

<!-- IF ATTACHBOX --><!-- INCLUDE posting_attach.tpl --><!-- ENDIF -->

before add---------------------

<!-- IF ALLOW_META --><!-- INCLUDE posting_meta.tpl --><!-- ENDIF -->

The End------------------------------------
 

Вложения

  • posting_meta.tpl
    714 байт · Просмотры: 23
Последнее редактирование:

Kryl

Пользователь
Ошибку пишет при открытии топика .
Fatal error: Call to undefined function bb_json_decode() in E:\OpenServer\OpenServer\domains\test.su\viewtopic.php on line 620
PHP:
$topic_meta = bb_json_decode($t_data['topic_meta']);
и на эту при создании топика
PHP:
$meta_tags = bb_json_encode($meta_tags_arr);
 

Dr_Brown

Пользователь
А кто нить ставил на 2.1.5?
помимо замены функции \Zend\Json\Json::encode,
Обновился до 2.1.5 у меня вообще их не выводит, хотя в базе есть поле и значения остались.
Логи пусто, и не сохраняет даже если заново добавить.
 

vitalix

Пользователь
А кто нить ставил на 2.1.5?
помимо замены функции \Zend\Json\Json::encode,
Обновился до 2.1.5 у меня вообще их не выводит, хотя в базе есть поле и значения остались.
Логи пусто, и не сохраняет даже если заново добавить.
:D всё точно так же
 

Dr_Brown

Пользователь
выебал...для 2.1.5

posting.php

строку: $topic_meta = isset($post_info['topic_meta']) ? bb_json_decode($post_info['topic_meta']) : array();

заменить на: $topic_meta = Zend\Json\Json::decode($post_info['topic_meta'], Zend\Json\Json::TYPE_ARRAY);

functions_post.php

строку: $meta_tags = bb_json_encode($meta_tags_arr);

заменить на: $meta_tags = Zend\Json\Json::encode($meta_tags_arr);

viewtopic.php

строку: $topic_meta = bb_json_decode($t_data['topic_meta']);

заменить на: $topic_meta = Zend\Json\Json::decode($t_data['topic_meta'], Zend\Json\Json::TYPE_ARRAY);
 
Сверху