Modification of user profile in sidebar for New Custodian
  • By default user profile in "new custodian" theme looks like a dump table  user_attribute.


    I think user doesn't need to see data from some fields. etc email_public, first_name_public, last_name_public.
    Instead of this, better use data from this fields for show or hide some user profile data

    I modified layout.tpl and make several buttons for users accounts on facebook twitter and google
    I think if profile has trigger for show or hide first/last name and email we output data depending on it.

    if fist_name_public selected in profile we show users first tname
    if last_name_public equal 1 we show users last tname
    if user filled facebook,twitter or google fields we show appropriate buttons (buttons is clickable and open apropriate profile in new tab)
    if Allow sending emails selected in profile we sho email button.

    How to do it:
    1. Put buttons images into _img/icon in themes folder of your publication. (in attach)
    1. Open file layout.tpl located in root folder of your publication.
    2. Replace code between lines 21 and 37 that is placed on the lower
    3. Save changes and see result like a on screenshot.

    ps You can use if for any template but you need make custom buttons


    code for replace

        {{ if $profile['first_name_public'] eq 1 }}
            {{ $user->first_name }}
        {{ /if }}
        {{ if $profile['last_name_public'] eq 1 }}
            {{ $user->last_name }}
        {{ /if }}
    <dl class="profile">
        {{ foreach $profile as $label => $value }}
        {{ if !empty($value) }}
            <div class="profile">
            {{ if $label == "bio" }}
                    <dt>Bio:</dt><dd>{{ $value|default:"n/a" }}</dd>
            {{ /if }}
            {{ if $label == "birth_date" }}
                <dt>Birth Date:</dt><dd>{{ $profile['birth_date'] }}</dd>
            {{ /if }}
            {{ if $label == "geolocation" }}
                <dt>Location:</dt><dd>{{ $profile['geolocation'] }}</dd>
            {{ /if }}
            {{ if $label == "organisation" }}
                <dt>Organisation:</dt><dd>{{ $profile['organisation'] }}</dd>
            {{ /if }}
            {{ if $label == "gender" }}
                <dt>Gender:</dt><dd>{{  $profile['gender'] }}</dd>
            {{ /if }}
        {{ /if }}
        {{ /foreach }}

        {{ if  !empty($profile['facebook']) }}
            <a rel="nofollow" target="_blank" href="{{ $profile['facebook'] }}">
            <img src="{{ url static_file='_img/icons/fb_btn.png' }}"></a>&nbsp;
        {{ /if }}
        {{ if  !empty($profile['twitter']) }}
        <a rel="nofollow" target="_blank" href="{{ $profile['twitter'] }}">
        <img src="{{ url static_file='_img/icons/tw_btn.png' }}"></a>&nbsp;
        {{ /if }}

        {{ if  !empty($profile['google']) }}
        <a rel="nofollow" target="_blank" href="{{ $profile['google'] }}/">
        <img src="{{ url static_file='_img/icons/gg_btn.png' }}"></a>&nbsp;
        {{ /if }}

        {{ if  !empty($profile['website']) }}
        <a rel="nofollow" target="_blank" href="http://{{ $profile['website']|escape:url }}">
        <img src="{{ url static_file='_img/icons/ws_btn.png' }}"></a>&nbsp;
             {{ if $profile['email_public'] eq 1}}
                <a rel="nofollow" href="mailto:{{ $user->email }}">
                    <img src="http://{{ $gimme->url->host }}/themes/publication_{{ $gimme->publication->identifier }}/theme_1/_img/icons/em_btn.png"></a><br>
            {{ /if }}
        {{ /if }}
    Post edited by Ruslan Shilov at 2013-04-30 02:41:52
  • 6 Comments sorted by
  • Thanks Ruslan, we're going to include this change into next version of New Custodian
    Ljuba Rankovic
    Senior Front End Developer, Sourcefabric
  • Vote Up1Vote Down Micz FlorMicz Flor
    Posts: 184Administrator
    yes, that is really nice!
  • A <dl> tag must only contain <dt> and <dd> tags. You should move the <div> outside the <dl> (and also close it with a </div> after </dl>) The same goes for the buttons. Move the closing </dl> to before the links.
  • Thanks for your cms. Anyway it's fast food. Table user_attribute need to be modification for multilanguage support. I wrote about it there.
  • I'm a big fan of definition lists for describing lists of things. They're just so… descriptive!
  • The path to the e-mail image should be the same as the other ones. It is linking to theme number 1 now and that can cause problems if the theme has any other number.

    The e-mail button will only be shown if the user has a website. Close the website if-statement before the code for the e-mail.