Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Author Mini Bio for Joomla! Posts
<?php
// no direct access
defined('_JEXEC') or die('Go Away');
// pull user id
$jomauth_article =& JTable::getInstance('content');
$jomauth_article->load(JRequest::getInt('id'));
$jomauth_authorid = $jomauth_article->created_by;
// pull required fields
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__contact_details WHERE user_id = " . $jomauth_authorid ;
$db->setQuery($query);
$jomauth_contact = $db->loadAssoc();
// split author array into variables - name, biopic, meta desc (as brief bio), and weblink (back to author bio page)
$jomauth_name = $jomauth_contact['name'];
$jomauth_img = $jomauth_contact['image'];
$jomauth_bio = $jomauth_contact['metadesc'];
$jomauth_web = $jomauth_contact['webpage'];
// display content
echo '<div class="uk-panel uk-panel-box uk-panel-box-secondary uk-margin-large-top">';
echo "<img src=\"" . JURI::base( true ) . $jomauth_img . "\" class=\"uk-thumbnail uk-thumbnail-mini uk-float-left uk-margin-right\" alt=\"Profile Picture\" />";
echo "<h5 class=\"uk-article-lead uk-margin-small uk-margin-top-remove\">" . $jomauth_name . "</h5><hr class=\"uk-margin-small\" />";
echo "<p class=\"uk-margin-small\">" . $jomauth_bio . "</p>";
echo "<a href=\"$jomauth_web\" class=\"uk-button uk-button-small\">Visit Bio Page<i class=\"uk-icon-caret-right uk-margin-small-left\"></i></a>";
echo '</div>';
?>
@HaeckDesign

This comment has been minimized.

Copy link
Owner Author

@HaeckDesign HaeckDesign commented Jun 25, 2016

This PHP snippet is intended to be added to the end of com_content/article/default.php. It is required that each user is tied to a single contact (may add on future functionality for multiple authors). Currently styled for UIkit CSS, but adjust classes as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment