Skip to content

Instantly share code, notes, and snippets.

@HaeckDesign
Last active December 16, 2016 06:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaeckDesign/70ef294f6d505ad02292dd9943a66ec8 to your computer and use it in GitHub Desktop.
Save HaeckDesign/70ef294f6d505ad02292dd9943a66ec8 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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