Zugriff auf $account | $profile in user-profile.tpl.php
am 13.02.2009 - 02:13 Uhr in
Hallo erstmal!
Ich möchte das Layout der Profilseite verändern und dazu die Kategorien, bzw. Felder einzeln aufrufen.
Innerhalb von $account geht das auch recht gut, siehe
<?php print $account->signature; ?>
Ich komme aber bei den in $account enthaltenen Arrays nicht weiter. In der user-profile.tpl.php möchte ich mir z.B. das Profilefeld "Persönliche Nachricht" ausgeben lassen
<?php print check_plain($account->psm); ?>
Der Code liefert "www.gddu.net" zurück, jedoch ohne den 'Titel' des Feldes [#title] => Persönliche Nachricht
.
Habe mich schon dumm und dämlich gesucht und hoffe, ihr könnt mir helfen.
Mfg
grin
Habe mir mal über <?php print check_plain(print_r($account, 1)); ?>
alles ausgeben lassen:
stdClass Object
(
[uid] => 1
[name] => GRiNREAPER
[pass] => ///
[mail] => ///
[mode] => 0
[sort] => 0
[threshold] => 0
[theme] =>
[signature] => Hihi haha hoho
[created] => 1227736365
[access] => 1234483674
[login] => 1234311925
[status] => 1
[timezone] => 3600
[language] => en
[picture] => sites/default/files/pictures/user_pics/picture-1.jpg
[init] => ///
[data] => ///
[guestbook_visited] => 1234127109
[guestbook_status] => 0
[guestbook_send_email] => 0
[guestbook_intro] =>
[picture_delete] => 0
[picture_upload] =>
[contact] => 1
[form_build_id] => form-8a077ded34ab2fca116ef27af725bc57
[user_title] => Administrator
[block] => Array
(
[block] => Array
(
[1] => 1
)
)
[roles] => Array
(
[2] => authenticated user
)
[profile_details_street] => Privatstraße
[profile_details_number] => 4
[profile_details_residence] => Berlin
[profile_details_plz] => 1xxxx
[display_name] => GRiNREAPER
[psm] => www.gddu.net
[user_login_count] => 2
[user_ip_address] => 127.0.0.1
[user_post_count] => 3
[userreference] => Array
(
)
[realname] => GRiNREAPER
[realname_save] => admin
[content] => Array
(
[user_picture] => Array
(
[#weight] => -10
[#value] => <div class="picture">
<a href="/drupal/user/1" title="View user profile." class="active"><img src="http://localhost/drupal/sites/default/files/pictures/user_pics/picture-1.jpg" alt="GRiNREAPER's picture" title="GRiNREAPER's picture" /></a></div>
[#title] =>
[#description] =>
[#printed] => 1
)
[user_titles] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#attributes] => Array
(
)
[#description] =>
[#title] => User title
[title] => Array
(
[#tree] =>
[#parents] => Array
(
)
[#required] =>
[#attributes] => Array
(
)
[#value] => Administrator
[#description] =>
[#type] => user_profile_item
[#title] =>
[#printed] => 1
)
[#type] => user_profile_category
[#children] => <dt></dt>
<dd>Administrator</dd>
[#printed] => 1
)
[Persönliche Angaben] => Array
(
[display_name] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-display_name
)
[#title] => Anzeigename
[#value] => GRiNREAPER
[#weight] => -10
[#type] => user_profile_item
[#printed] => 1
)
[psm] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-psm
)
[#title] => Persönliche Nachricht
[#value] => www.gddu.net
[#weight] => -5
[#type] => user_profile_item
[#printed] => 1
)
[#tree] =>
[#required] =>
[#parents] => Array
(
)
[#description] =>
[#title] => Persönliche Angaben
[#type] => user_profile_category
[#attributes] => Array
(
)
[#children] => <dt class="profile-display_name">Anzeigename</dt>
<dd class="profile-display_name">GRiNREAPER</dd>
<dt class="profile-psm">Persönliche Nachricht</dt>
<dd class="profile-psm">www.gddu.net</dd>
[#printed] => 1
)
[Details] => Array
(
[#description] =>
[#attributes] => Array
(
)
[#required] =>
[#type] => user_profile_category
[#parents] => Array
(
)
[#title] => Details
[#tree] =>
[profile_details_street] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-profile_details_street
)
[#title] => Strasse
[#value] => Privatstraße
[#weight] => 1
[#type] => user_profile_item
[#printed] => 1
)
[profile_details_number] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-profile_details_number
)
[#title] => Hausnummer
[#value] => 4
[#weight] => 2
[#type] => user_profile_item
[#printed] => 1
)
[profile_details_plz] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-profile_details_plz
)
[#title] => Postleitzahl
[#value] => 1xxxx
[#weight] => 3
[#type] => user_profile_item
[#printed] => 1
)
[profile_details_residence] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => profile-profile_details_residence
)
[#title] => Wohnort
[#value] => Berlin
[#weight] => 4
[#type] => user_profile_item
[#printed] => 1
)
[#children] => <dt class="profile-profile_details_street">Strasse</dt>
<dd class="profile-profile_details_street">Privatstraße</dd>
<dt class="profile-profile_details_number">Hausnummer</dt>
<dd class="profile-profile_details_number">4</dd>
<dt class="profile-profile_details_plz">Postleitzahl</dt>
<dd class="profile-profile_details_plz">1xxxx</dd>
<dt class="profile-profile_details_residence">Wohnort</dt>
<dd class="profile-profile_details_residence">Berlin</dd>
[#printed] => 1
)
[summary] => Array
(
[#description] =>
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[guestbook] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => guestbook
)
[#title] => Guestbook
[#value] => <a href="/drupal/user/1/guestbook" title="Read GRiNREAPER's guestbook.">View recent guestbook entries</a>
[#type] => user_profile_item
[#printed] => 1
)
[member_for] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#attributes] => Array
(
)
[#description] =>
[#title] => Member for
[#value] => 11 weeks 1 day
[#type] => user_profile_item
[#printed] => 1
)
[#type] => user_profile_category
[#attributes] => Array
(
[class] => user-member
)
[#weight] => 5
[#title] => History
[blog] => Array
(
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#description] =>
[#attributes] => Array
(
[class] => blog
)
[#title] => Blog
[#value] => <a href="/drupal/blog/1" title="Read GRiNREAPER's latest blog entries.">View recent blog entries</a>
[#type] => user_profile_item
[#printed] => 1
)
[#children] => <dt class="guestbook">Guestbook</dt>
<dd class="guestbook"><a href="/drupal/user/1/guestbook" title="Read GRiNREAPER's guestbook.">View recent guestbook entries</a></dd>
<dt>Member for</dt>
<dd>11 weeks 1 day</dd>
<dt class="blog">Blog</dt>
<dd class="blog"><a href="/drupal/blog/1" title="Read GRiNREAPER's latest blog entries.">View recent blog entries</a></dd>
[#printed] => 1
)
)
)
- Anmelden oder Registrieren um Kommentare zu schreiben
Ausgabe
am 13.02.2009 - 10:02 Uhr
Moin!
In der user-profile.tpl.php möchte ich mir z.B. das Profilefeld "Persönliche Nachricht" ausgeben lassen
<?php print check_plain($account->psm); ?>
Der Code liefert "www.gddu.net" zurück, jedoch ohne den 'Titel' des Feldes
[#title] => Persönliche Nachricht
.Ok, ausgehend von Deiner Debug-Ausgabe (sehr hilfreich übrigens!) kannst Du den Titel so ausgeben:
<?php
$personalInfo = $account->content[t('Persönliche Angaben')];
print $personalInfo['psm']['#title'] .': '. $account->psm;
?>
hth,
Stefan
Geht leider nicht..
am 14.02.2009 - 00:13 Uhr
Ok, ausgehend von Deiner Debug-Ausgabe (sehr hilfreich übrigens!) kannst Du den Titel so ausgeben:
<?php
$personalInfo = $account->content[t('Persönliche Angaben')];
print $personalInfo['psm']['#title'] .': '. $account->psm;
?>
Geht leider nicht, ausgegeben wird nur:
:www.gddu.net
Ein Test auf
<?php print $personalInfo; ?>
erbrachte auch nichts, dann versuchte ich<?php print $account->content[t('Persönliche Angaben')]; ?>
direkt auszugeben - wieder nichts..Irgendeine Idee?
Mfg
grin
Problem erkannt - Bug?
am 14.02.2009 - 01:07 Uhr
Ich habe mal die Felder [psm] und [display_name] einer neuen Kategorie zugewiesen namens [Personal Info].
Daraufhin wird über
<?php
$personalInfo = $account->content[t('Personal Info')];
print $personalInfo['psm']['#title'];
?>
der Titel des Feldes korrekt ausgegeben. Daraufhin habe ich mit verschiedenen Wortkombinationen (für Kategorie) getestet. Das Problem sind die Umlaute ('a', 'ö', ..).
Ist das jetzt ein Bug?