Hello,

i use the News 2 Template. In my articles i would like to show the Author - on the left Side- with his Profile image.
Example : here

I know this is made with the K2 Componetn which is not available for Joomla 4.

How can i create a similar View with the Joomla Article Component?

Thx in advance

    6 days later

    Hi macanroe,
    I have checked, and I can customize it to show the author. However, do you need an author link, or just the author name without linking to the author's posts?

    Hello, thanks for checking out.

    If possible, with the link and of course with the Photo of the Author

    Thank You!

      Hi macanroe,
      Customizing the template has proven to be quite challenging. Our technical team will make an effort to address this section within the upcoming week.

      12 days later

      Hi macanroe,
      To show the avatar and username in the article detail, you can add the following code to the \templates\gk_news2\html\com_content\article\default.php file, line 301.

      <?php 
          $author_obj = JFactory::getUser($this->item->created_by);
          $author_email = $author_obj->email;
          $author_name = $author_obj->name; // Get the full name
          
          // Generate the Gravatar URL
          $avatar_hash = md5(strtolower(trim($author_email)));
          $avatar_size = 120; 
          $default_image = 'https://example.com/default-avatar.jpg'; // URL to your default image
          
          $avatar_url  = 'https://www.gravatar.com/avatar/'.$avatar_hash.'.jpg';
          $avatar_url .= '?s='.$avatar_size;
          $avatar_url .= '&d='.urlencode($default_image);
          
          // Construct the profile URL
          $profile_url = JRoute::_('index.php?option=com_users&view=profile&user_id=' . $author_obj->id);
      
          echo '<img src="'.$avatar_url.'" alt="" />';
          echo '<p><a href="'.htmlspecialchars($profile_url, ENT_QUOTES, 'UTF-8').'">'.htmlspecialchars($author_name, ENT_QUOTES, 'UTF-8').'</a></p>';
      ?>

      The default.php file:

      default.zip
      5kB

      Note: To use the code for retrieving a Gravatar, please ensure you have uploaded your desired image to Gravatar using the following link.

      Write a Reply...
      You need to Login to view replies.