Редактор темы

Реклама
Реклама

Хак вывода всей информации с профиля пользователя в краткую или полную новость [dle all]

DLEPlugins

Кодер
Регистрация
29 Ноя 2015
Сообщения
1.601
Рейтинг реакций
968
Баллы
113
1/3
Автор темы
Периодически натыкаюсь на вопрос о том, как вывести имя, аватарку, страну и значения из доп полей профиля в краткую или полную новость. Вот простое решение без модулей и лишних файлов на сервере.

Для полной новости открываем /engine/modules/show.full.php и ищем код
PHP:
$tpl->compile( 'content' );

        if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
ВЫШЕ вставляем
PHP:
$_user = $db->super_query( "SELECT user_id, email, fullname, land, foto, xfields FROM " . PREFIX . "_users WHERE name = '{$row['autor']}'" );
        $tpl->set( '{user-fullname}', $_user['fullname'] );
        $tpl->set( '{user-land}', $_user['land'] );
        $tpl->set( '{user-foto}', $_user['foto'] );
        $tpl->set( '{user-email}', $_user['email'] );
        $_user_xf = xfieldsdataload( $_user['xfields'] );
        foreach( $_user_xf as $_xf_key => $_xf_val ) {
            $tpl->set( '{user-xf-' . $_xf_key . '}', stripslashes( $_xf_val ) );
        }

Для краткой новости открываем /engine/modules/show.short.php и ищем код
PHP:
$tpl->compile( 'content' );

    }

    if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
ВЫШЕ вставляем
PHP:
$_user = $db->super_query( "SELECT user_id, email, fullname, land, foto, xfields FROM " . PREFIX . "_users WHERE name = '{$row['autor']}'" );
        $tpl->set( '{user-fullname}', $_user['fullname'] );
        $tpl->set( '{user-land}', $_user['land'] );
        $tpl->set( '{user-foto}', $_user['foto'] );
        $tpl->set( '{user-email}', $_user['email'] );
        $_user_xf = xfieldsdataload( $_user['xfields'] );
        foreach( $_user_xf as $_xf_key => $_xf_val ) {
            $tpl->set( '{user-xf-' . $_xf_key . '}', stripslashes( $_xf_val ) );
        }

Как использовать? В fullstory.tpl или shortstory.tpl вашего шаблона в нужном месте вставить
Имя: {user-fullname}
<br />
Ава: {user-foto}
<br />
Страна: {user-land}
<br />
Значение доп поля профиля: {user-xf-латинское_название_доп_поля_профиля}
<br />

<br />
Само собой вы можете оформлять как вам угодно, после установки хака вам доступны новые теги, которые и выводят нужную вам инфу : {user-fullname}, {user-foto}, {user-land} и {user-xf-латинское_название_доп_поля_профиля}

Вот скрины:

Полная новость
db02054ab1b9cc3ca74bb34101a040d9.jpg


Краткая новость

f5ece8ecd8aa59270a91ebcfffeac51e.jpg


Если вдруг вам понадобилось выводить эту инфу в кастум шаблоне, то решение такое:
открываем /engine/modules/show.custom.php и ищем код
PHP:
$tpl->compile( 'content' );

}

if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
ВЫШЕ вставляем
PHP:
$_user = $db->super_query( "SELECT user_id, email, fullname, land, foto, xfields FROM " . PREFIX . "_users WHERE name = '{$row['autor']}'" );
        $tpl->set( '{user-fullname}', $_user['fullname'] );
        $tpl->set( '{user-land}', $_user['land'] );
        $tpl->set( '{user-foto}', $_user['foto'] );
        $tpl->set( '{user-email}', $_user['email'] );
        $_user_xf = xfieldsdataload( $_user['xfields'] );
        foreach( $_user_xf as $_xf_key => $_xf_val ) {
            $tpl->set( '{user-xf-' . $_xf_key . '}', stripslashes( $_xf_val ) );
        }
 

Похожие темы Последние темы Популярные темы

Назад
Сверху