Move your article’s data header to footer
After very busy work time I can write some other articles that I hope you find interesting.
I am involved in a large project for a news portal http://www.arezzonotizie.it/.
For this project I made some patches and writed some code personalization.
The first plugin I want to present is a mambot to move data from header to footer.
The standard joomla article's header show some elements in the header of the article:
- pdf icon
- print icon
- e-mail icon
- date created
- author name
The mambot I have developed move all of this elements in the footer of the article.
As a bonus if the author have a linked contact, shows hyperlink to the correspondig author contact page.
-
/**
-
* Authors Link Bot
-
* @version 1.0
-
* @package None
-
* @copyright (C) Copyright 2007-2007 by Marco Sbragi
-
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
-
*/
-
-
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosAuthorLink' );
-
-
function botMosAuthorLink( $published, &$row, &$params, $page=0 ) {
-
-
$showbottom = true;
-
-
// $row->created_by -> Id dell'autore
-
// $row->created_by_alias -> Alias autore
-
// $row->Author -> Nome Autore
-
-
if($_REQUEST['task'] != 'view') { return true; }
-
if(! $published) { return true; }
-
if($params->get( 'popup' ) ) { return true; }
-
-
-
if((@$row->created_by) && (! $my->id)) {
-
if((!$row->created_by_alias) || (strtolower(($row->created_by_alias) == strtolower($row->author)))) {
-
// Check If declared on Contacts
-
$database->setQuery( "SELECT id FROM #__menu WHERE link = 'index.php?option=com_contact' AND published=1" );
-
$Itemid = (int) $database->loadResult();
-
-
$query = "SELECT id"
-
. "\n FROM #__contact_details"
-
. "\n WHERE user_id = {$row->created_by}"
-
. "\n AND published = 1"
-
. "\n LIMIT 1";
-
-
$database->setQuery( $query );
-
$Id = (int) $database->loadResult();
-
if($Id) {
-
$author_link = sefRelToAbs("index.php?option=com_contact&task=view&contact_id={$Id}&Itemid={$Itemid}");
-
$row->created_by_alias = "<a href='" . $author_link . "'>" . $row->author . "</a>";
-
} else {
-
$row->created_by_alias = $row->author;
-
}
-
}
-
-
// Use standard jOOmla format
-
if(! $showbottom) {
-
return true;
-
}
-
-
$showEmail = $params->get('email');
-
$showPrint = $params->get('print');
-
$showPdf = $params->get('pdf');
-
-
$params->set('author',0);
-
$params->set('createdate',0);
-
$params->set('print',0);
-
$params->set('email',0);
-
$params->set('pdf',0);
-
-
$print_link = $mosConfig_live_site. '/index2.php?option=com_content&task=view&id=' . $row->id .'&pop=1&page='. $page . $row->Itemid_link;
-
-
$str_html = '<table style="clear: both;" width="100%" class="botAuthor" cellspacing="0" cellpadding="0">';
-
$str_html .= '<tr>';
-
$str_html .= '<td align="left">' . strtoupper(mosFormatDate($row->created)) . ' - ' . $row->created_by_alias . '</td>';
-
// $showPdf && $str_html .= botMosAuthor_PdfIcon($row, $params );
-
$showPrint && $str_html .= botMosAuthor_PrintIcon($row, $params, $print_link );
-
$showEmail && $str_html .= botMosAuthor_EmailIcon($row, $params);
-
$str_html .= '</tr>';
-
$str_html .= '</table>';
-
$row->text .= $str_html;
-
}
-
-
return true;
-
}
-
-
function botMosAuthor_PdfIcon( &$row, &$params ) {
-
-
if ( $params->get( 'popup' ) ) {
-
return '';
-
}
-
-
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
$link = $mosConfig_live_site. '/index2.php?option=com_content&do_pdf=1&id='. $row->id;
-
-
if ( $params->get( 'icons' ) ) {
-
$image = mosAdminMenus::ImageCheck( 'pdf_button.png', '/images/M_images/', NULL, NULL, _CMN_PDF, _CMN_PDF );
-
} else {
-
$image = ' '. _CMN_PDF;
-
}
-
$str_html = '<td align="right" width="16" class="buttonheading">';
-
$str_html .= '<a href="' . $link .'" target="_blank" onclick="window.open(\'' . $link .'\',\'win2\',\'' . $status. '\'); return false;" title="' . _CMN_PDF .'">' . $image . '</a>';
-
$str_html .= '</td>';
-
return $str_html;
-
}
-
-
function botMosAuthor_EmailIcon( &$row, &$params ) {
-
-
if ( $params->get( 'popup' ) ) {
-
return '';
-
}
-
-
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=400,height=250,directories=no,location=no';
-
-
$_Itemid = '&itemid='. $Itemid;
-
-
$link = $mosConfig_live_site .'/index2.php?option=com_content&task=emailform&id='. $row->id . $_Itemid;
-
-
if ( $params->get( 'icons' ) ) {
-
$image = mosAdminMenus::ImageCheck( 'emailButton.png', '/images/M_images/', NULL, NULL, _CMN_EMAIL, _CMN_EMAIL );
-
} else {
-
$image = ' '. _CMN_EMAIL;
-
}
-
$str_html = '<td align="right" width="16" class="buttonheading">';
-
$str_html .= '<a href="' . $link .'" target="_blank" onclick="window.open(\'' . $link .'\',\'win2\',\'' . $status. '\'); return false;" title="' . _CMN_EMAIL .'">' . $image . '</a>';
-
$str_html .= '</td>';
-
return $str_html;
-
}
-
-
function botMosAuthor_PrintIcon( &$row, &$params, $link ) {
-
-
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
-
$_Itemid = '&itemid='. $Itemid;
-
-
if ( $params->get( 'icons' ) ) {
-
$image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT, _CMN_PRINT );
-
} else {
-
$image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP;
-
}
-
-
$str_html = '<td align="right" width="16" class="buttonheading">';
-
if ( $params->get( 'popup' ) ) {
-
$str_html .= '<a href="#" onclick="javascript:window.print(); return false;" title="' . _CMN_PRINT . '">' . $image . '</a>';
-
} else {
-
$str_html .= '<a href="' . $link .'" target="_blank" onclick="window.open(\'' . $link .'\',\'win2\',\'' . $status. '\'); return false;" title="' . _CMN_PRINT .'">' . $image . '</a>';
-
}
-
$str_html .= '</td>';
-
return $str_html;
-
}
For anyone of you interested in how to write mambot for jOOmla read this article on jOOmla help site http://help.joomla.org/content/category/12/113/125
If you wish to use the mambot as a simple author to contact link and want to leave the standard jOOmla layout you must change the declaration at line 15 from
-
// $showbottom = true;
-
// To
-
$showbottom = false;