You are here: Home / Documentation / How To's / How to change order of the byline

How to change order of the byline

by ledwell published Aug 13, 2013 09:00 AM, last modified Aug 16, 2016 10:50 AM
Ever want to change the order of the information in the by line? Make the first name first and not display the middle initial?

This is somewhat inelegant, but it works. Nathan helped me with it and Dan contributed some edits as well to make sure that if a user does't have a middle initial that it does't barff, it also removes an extra comma that was appearing. Thank Dan & Nathan!! :)
You will need to have ZMI access to your website

  • Login
  • Browse to "portal_view_customizations
  • Edit "plone.belowcontenttitle.documentbyline"
  • replace this
<tal:creator tal:define="creator_short_form view/creator;"
               tal:condition="creator_short_form">
  <tal:name tal:define="creator_long_form string:?author=${creator_short_form};
                        creator_is_openid python:'/' in creator_short_form;
                        creator_id python:(creator_short_form, creator_long_form)[creator_is_openid];">
    <span class="documentAuthor">
      <tal:i18n i18n:translate="label_by_author">
      by
      <a href="#"
         tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/author/${creator_id}"
         tal:content="view/authorname"
         tal:omit-tag="python:view.author() is None"
         i18n:name="author">Roland Barthes</a>
      </tal:i18n>
         —
    </span>
  </tal:name>
  </tal:creator>
 
  • with this
 <tal:creator tal:define="creator_short_form view/creator;"
               tal:condition="creator_short_form">
  <tal:name tal:define="creator_long_form string:?author=${creator_short_form};
                        creator_is_openid python:'/' in creator_short_form;
                        creator_id python:(creator_short_form, creator_long_form)[creator_is_openid];">
 by 
   <span class="documentAuthor fname">
      <tal:i18n i18n:translate="label_by_author">
      <a href="#"
         tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/author/${creator_id}"
         tal:content="python: view.authorname().split(' ')[1]"
         tal:omit-tag="python:view.author() is None"
         i18n:name="author">Roland Barthes</a>

      </tal:i18n>
  
    </span>

    <span class="documentAuthor lname">
      <tal:i18n i18n:translate="label_by_author">
      <a href="#"
         tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/author/${creator_id}"
         tal:content="python: view.authorname().split(' ')[0].replace(',','')"
         tal:omit-tag="python:view.author() is None"
         i18n:name="author">Roland Barthes</a>

      </tal:i18n>
         -€”
    </span>
  </tal:name>
  </tal:creator>

Note

If you want to add the middle initial initial in then you'll want to add this bit as well.
<span class="documentAuthor fname">
      <tal:i18n i18n:translate="label_by_author">
      <a href="#"
         tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/author/${creator_id}"
         tal:content="python: view.authorname().split(' ')[-1]"
         tal:omit-tag="python:view.author() is None"
         i18n:name="author">Roland Barthes</a>

      </tal:i18n>
  
    </span>
If you want to write something more elegant you could use some code like this that Nathan gave me that I don't quit understand. So you'll need to do some experimenting of your own if you want to use it..
tal:content="python: ' '.join(view.authorname().split(' ')[1:1])"
 
Navigation