Forums » Add User Who Created Item to detailed-view.php

RSS feed for this topic

Info

  1. So I have a class of 20 people adding items to an archive. I would like to be able to see who, by username, added which item.

    I tried adding this line to detailed-view.php in the "item-meta" div, where Creator, Type, Added, and Collection are already (I've broken it into multiple lines to make the relevant bit obvious):

    <li>
    <span class="fieldname">User:</span>
    <?php echo getUserWhoCreated()->username; ?>
    </li>

    The error I get says: Fatal error: Call to undefined function getUserWhoCreated()...

    Any thoughts? I am almost certainly borking some aspect of the PHP (I'm kind of guessing at syntax and how one uses methods); but I consulted this forum post as well as documentation for the User and Item classes. Is there an easier way to implement this?

  2. getUserWhoCreated() is a method of the Item class. Essentially, this means that you have to call it like this:

    $item->getUserWhoCreated()
  3. Gotcha. This code did the trick:

    <li><span class="fieldname">User:</span>
    <?php echo $item->GetUserWhoCreated()->username; ?>
    </li>

    Thanks!

    (I'd mark the thread "resolved" but in both FF and Chrome I just see the red dot icon with no pull down...)

Topic Closed

This topic has been closed to new replies.