Last Entry by "Name"

7 years 9 months ago - 7 years 9 months ago #1 by Captainmoomoo
Hello again, I am trying to get the index in Rialto to display the first and last name of the user, rather than his/her username. Is there a piece of code I can edit to display the full name instead?

I took a look at default.php (in com_rialto>views>index>tmpl) and made a few changes to at least get the user id to display. The code I edited shown below. I'm not sure what I'm doing wrong... Thank you for any support you can give.
<td align="center" class="rialtoIndexViewTableRowLastEntry">
  <?php
    if ( $category->last_entry_date == "") {
      echo "-";
        } else { // entry found
          $_username = $cHelper->getUsernameById( $category->last_entry_user_id);
          // Next line displays users ID
          //$_username = ( $category->last_entry_user_id);
            echo "<table width='100%' cellspacing='0' cellpadding='0' border='0' class='noborder'>";
            echo "<tr>";
            echo "<td align='center' valign='center' class='noborder'>";
            echo $category->last_entry_date;
            echo "<br />";
            echo JText::_( 'COM_RIALTO_BY' ) . "&nbsp;";
            echo "<b>";
            //echo $_username;
            // Removes characters in usernames
            echo $_username = preg_replace('/[.,]/', ' ', $_username);
            echo "</b>";
            echo "</td>";
            echo "</tr>";
            echo "</table>";
        }
  ?>
</td>

Please Log in or Create an account to join the conversation.

7 years 9 months ago #2 by geoffc
Replied by geoffc on topic Last Entry by "Name"
Names are a little strange (to my mind) in Joomla. Basically when one registers to Joomla one supplies a 'name' and a 'username'. The username is used for when one logs in to the site. The 'name' can really be anything and isn't really used as a 'true name' as such. Many people tend to use either the same text as the 'username' or just a one word title. It is often not a real 'name' at all.

Rialto tries to split the Joomla name' into the 'firstname' and 'lastname' which is then used in its displays, but there is no guarantees that they are 'real names' even then. Hence the use of the username in the displays etc.

There are two possibilities. a) Get the 'name' from the Joomla users table or b) Get the firstname and lastname fields from the Rialto users table. Either is best server by a small helper routine to access the appropriate table and return a value which is then displayed.

Which is most suitable for your site?
There may be a small delay on a response since I am currently chasing a problem caused by googlecode closing down resulting in us having to modify another component.

Regards
Geoff
The following user(s) said Thank You: Captainmoomoo

Please Log in or Create an account to join the conversation.

7 years 9 months ago #3 by Captainmoomoo
Replied by Captainmoomoo on topic Last Entry by "Name"
I got it to work! I passed the ID for the users into $user = JFactory::getUser($_username); and then printed out $user->name.

I was initially thinking about passing in the first and last name in as a placeholder, but I don't think that would work well. The first and last names of the users wont change for my website, as the website pulls the user's information from an Active Directory (AD). I'm sure a lot of people who use this plugin would not want to reveal personal information; but for my case, it is needed. Thanks again geoffc!

Please Log in or Create an account to join the conversation.

7 years 9 months ago - 7 years 9 months ago #4 by geoffc
Replied by geoffc on topic Last Entry by "Name"
Good solution.
Remember it would need to be in a template override otherwise the change would be lost on an update. :) .

Regards
Geoff

Please Log in or Create an account to join the conversation.

Time to create page: 0.117 seconds
Go To Top

Joomla! Debug Console

Session

Profile Information

Memory Usage

Database Queries