DomiTori
Постоялец
- Регистрация
 - 15 Июл 2015
 
- Сообщения
 - 92
 
- Реакции
 - 88
 
- Автор темы
 - #1
 
Периодически натыкаюсь на вопрос о том, как вывести имя, аватарку, страну и значения из доп полей профиля в краткую или полную новость. Вот простое решение без модулей и лишних файлов на сервере.
Для полной новости открываем /engine/modules/show.full.php и ищем код
	
	
	
		
ВЫШЕ вставляем
	
	
	
		
Для краткой новости открываем /engine/modules/show.short.php и ищем код
	
	
	
		
ВЫШЕ вставляем
	
	
	
		
Как использовать? В fullstory.tpl или shortstory.tpl вашего шаблона в нужном месте вставить
Вот скрины:
Полная новость
		
		
	
	
		
	
Краткая новость
		
	
Если вдруг вам понадобилось выводить эту инфу в кастум шаблоне, то решение такое:
открываем /engine/modules/show.custom.php и ищем код
	
	
	
		
ВЫШЕ вставляем
	
	
	
		
	
		
			
		
		
	
				
			Для полной новости открываем /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}, {user-foto}, {user-land} и {user-xf-латинское_название_доп_поля_профиля}Имя: {user-fullname}
<br />
Ава: {user-foto}
<br />
Страна: {user-land}
<br />
Значение доп поля профиля: {user-xf-латинское_название_доп_поля_профиля}
<br />
<br />
Вот скрины:
Полная новость
	Краткая новость
	Если вдруг вам понадобилось выводить эту инфу в кастум шаблоне, то решение такое:
открываем /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 ) );
        }
	
				