Доброго времени суток.
Делал темизацию профиля. Получился вот такой код:
<b><?php print t('Аватар: ')?></b><br> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_image'][0]);?> <br>
<b><?php print t('Настоящее имя: ')?> </b><?php print render($user_profile['profile_main']['view']['profile2'][1]['field_name'][0]);?> <br>
<b><?php print t('Пол: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_sex'][0]['#markup']);?> <br>
<b><?php print t('Дата рождения: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_birthdays'][0]['#markup']);?><br>
<fieldset class = "collapse-text-fieldset collapsible form-wrapper collapsed">
<legend><span class="fieldset-legend">Дополнительно</span></legend>
<div class="fieldset-wrapper"><b>Информация о себе:</b></br>
<?php print render($user_profile['profile_main']['view']['profile2'][1]['field_about_me'][0]['#markup']);?>
<div class="fieldset-description"></div>
</div>
</fieldset>
<b><?php print t('Настоящее имя: ')?> </b><?php print render($user_profile['profile_main']['view']['profile2'][1]['field_name'][0]);?> <br>
<b><?php print t('Пол: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_sex'][0]['#markup']);?> <br>
<b><?php print t('Дата рождения: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_birthdays'][0]['#markup']);?><br>
<fieldset class = "collapse-text-fieldset collapsible form-wrapper collapsed">
<legend><span class="fieldset-legend">Дополнительно</span></legend>
<div class="fieldset-wrapper"><b>Информация о себе:</b></br>
<?php print render($user_profile['profile_main']['view']['profile2'][1]['field_about_me'][0]['#markup']);?>
<div class="fieldset-description"></div>
</div>
</fieldset>
Данные выводит только у админа, у остальных пустые строчки. В чем ошибка?
Комментарии
Не хватает прав на просмотр содержимого профиля?
Цифра 1 - случайно не ID-пользователя?
Попробуй через debug($user_profile) вывести и посмотреть, есть ли вообще что-нибудь в переменной.
Как может не хватать прав на просмотр собственного профиля?
Цифра 1 это часть пути к значению поля.
В переменной все есть. Если написать просто <?php print render ($user_profile);?> , то отображается у всех.
Если всё есть... то попробуй
1) вывести свой текст
2) выводить по 1 полю и смотреть, когда вывод пропадёт.
Если посмотреть пользователем профиль админа, то там все выводится, а во всех остальных профилях пусто. Как я понял этот код выводит только данные профиля админа (путь брал через модуль devel), а вот как сделать его универсальным не могу понять.
Вы были правы, цифра 1 это id пользователя. Как сделать чтобы было для всех?
Получить данный id (напр. из переменной $user_profile) и его подставлять. Либо в поле он там каком-то сохранён.
Ну например так: http://php.net/manual/ru/function.array-search.php
Сделал вот так:
global $user;
$userID = $user->uid;
?>
<b><?php print t('Аватар: ')?></b><br> <?php print render($user_profile['profile_main']['view']['profile2'][$userID]['field_image'][0]);?> <br>
<b><?php print t('Настоящее имя: ')?> </b><?php print render($user_profile['profile_main']['view']['profile2'][$userID]['field_name'][0]);?> <br>
<b><?php print t('Пол: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][1]['field_sex'][$userID]['#markup']);?> <br>
<b><?php print t('Дата рождения: ')?></b> <?php print render($user_profile['profile_main']['view']['profile2'][$userID]['field_birthdays'][0]['#markup']);?><br>
<fieldset class = "collapse-text-fieldset collapsible form-wrapper collapsed">
<legend><span class="fieldset-legend">Дополнительно</span></legend>
<div class="fieldset-wrapper"><b>Информация о себе:</b></br>
<?php print render($user_profile['profile_main']['view']['profile2'][$userID]['field_about_me'][0]['#markup']);?>
<div class="fieldset-description"></div>
</div>
</fieldset>
id он определяет, но теперь выводит только в своем профиле, а при просмотре чужого не выводит.
up
up
Проблема все еще не решена. Помогите пожалуйста.
возьми например из адреса...
<?php
$id = (int)arg(1);
?>
Эта функция выводит правильный айди пользователя, но почему то выводится профиль только того пользователя под которым авторизован, а остальных нет. То есть под профилем под которым залогинен всё ок, а при просмотре других профилей ничего не выводит.
1) Проверь права на просмотр профилей других пользователей. Как вариант поставь все галочки для анонимов и зареганых на тестовой системе - и посмотри, будет ли доступ?
2) Напиши debug($user_profile). Что оно выводит на других страницах?