Вывод информации с профиля пользователя в краткую или полную новость

Вывод информации с профиля пользователя в краткую или полную новость

Простое решение позволяющее вывести имя пользователя, его аватарку, страну и значения из доп.полей профиля в краткую или полную новость.


Установка:
1. Для полной новости открыть engine/modules/show.full.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']) );

Добавить выше:
$_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 ) );
        }

2. Для краткой новости открыть engine/modules/show.short.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']) );

Добавить выше:
$_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 ) );
        }

3. Если понадобится выводить информацию в кастом шаблоне, то следует открыть engine/modules/show.custom.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']) );

Добавить выше:
$_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 ) );
        }

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

Готово!
 
Версия DLE: 11.х
Автор: DomiTori
Источник
Информация
Посетители, находящиеся в группе Гость, не могут оставлять комментарии к данной публикации.