ccdog wrote:ffaabbss wrote:
simi wrote:
Is there any way to make a module like here (at the right)?
hxxp://www.kimyamuhendisi.com/index.php?option=com_content&task=view&id=52&Itemid=1
Post edited by: simi, at: 2007/07/13 13:14
that would be really interesting indeed? How is that done?
Hi guys,
Here's how I think you would do this.
1) Create a module. In that module, do the following:
2) Test to see if you are on a content item page (check the GET parameters from the URL for option=com_content and task=view)
3) Get the content id from the URL (it should say "id=x" where x is some number)
4) Get the data from the #_content table in the database where id is equal to the content id you found in step 3
5) Check that data for the author id
6) Use the author id to generate a link to the author's profile and get the thumbnail image of the author.
7) Only publish the module on pages that have content items.
If someone feels like coding this, that would be great. I'm sure it would be most appreciated by the community!
[code:1]<?
/**
Community Builder - Author Info!
@author bigodines
@date April, 2005
@description Este mambot acrescenta uma pequena tabela com as informações do autor quando for digitada a tag {mosauthorinfo}
@requirements Community Builder 1.4 or higher
@package Mambo_4.5.2.1
*/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/* Vou registrar meu mambot :«»D */
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botAuthorInfo' );
/**
Essa função verifica se a tag {mosauthorinfo} existe no conteúdo. Se existir, troca por uma tabela com
as informações do autor daquele conteúdo.
*/
function botAuthorInfo( $published, $row, $mask=0, $page=0 ) {
global $database;
if (!$published) {
return true;
}
// define the regular expression for the bot
$expressao = "#{mosauthorinfo}#s";
//echo "<pre>";
//print_r($row);
//echo "</pre>";
/* PARA USO EM OUTROS CASOS QUE NÃO O MAMBOPROS.NET, TROCAR OS CAMPOS DO SELECT PARA OS
CAMPOS DESEJADOS DO COMMUNITY BUILDER */
$database->setQuery("SELECT cb_firstname, cb_lastname, avatar, user_id, username, email, occupation, cb_website, interests, city, SUM( notas.rating_sum ) / SUM( notas.rating_count ) as media
FROM #__comprofiler AS perfil
LEFT JOIN #__users AS user ON user_id = perfil.user_id
LEFT JOIN #__content AS c ON c.created_by = perfil.id
LEFT JOIN #__content_rating AS notas ON notas.content_id = c.id
WHERE perfil.id = '$row->created_by'
GROUP BY cb_firstname"«»);
//$database->setQuery("SELECT * FROM #__users WHERE id = $row->created_by"«»); // teste local
$linha = null;
$database->loadObject( $linha );
$html = "<table width=\"180\" border=0 align=\"left\"><tr><td align=\"left\"><table width=\"175\" style=\"border: 1px solid silver\" bgcolor=\"#F5F5F5\" cellpadding=\"2\">\n";
$html .= "<tr><td><b>Yazar Bilgisi:</b></td></tr>";
if ($linha->avatar)
$html .= "<tr><td align=\"center\" bordercolor=\"#F0F0F0\"><img src=http://www.yoursite.com/images/comprofiler/".$linha->avatar.">";
if ($linha->cb_firstname)
if ($linha->cb_website)
//Na proxima linha vo tentar mostrar o perfil pra visitantes, assim qeu descobrir como
//$html .= "<tr><td bordercolor=\"#F0F0F0\">Name: <a href=http://www.yoursite.com/index.php?option=com_comprofiler&task=userProfile&user=".$linha->user_id." &lang=\" target=\"_blank\">".$linha->cb_firstname." ".$linha->cb_lastname."";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Adı&Soyadı: ".$linha->cb_firstname." ".$linha->cb_lastname."</td></tr>";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Üye Adı: ".$linha->username."</td></tr>";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Şehir: ".$linha->city."</td></tr>";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Gönderi Sayısı: ";
$html .= $linha->media ? $linha->media * 2 : "0.00" ;
$html .= "</td></tr>";
//if ($linha->apresentacao)
$html .= "<tr><td bordercolor=\"#F0F0F0\">Yazar Hakkında: <i>".$linha->interests."</i></td></tr>";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Yazarın: <a href=http://www.yoursite.com/index.php?option=com_comprofiler&task=userProfile&user=".$linha->user_id.">Profili";
$html .= "<tr><td bordercolor=\"#F0F0F0\">Yazarın: <a href=http://www.yoursite.com/index.php?option=com_mhauthor&task=show&auth=".$linha->user_id.">Diğer Yazıları";
$html .= "</td></tr></table></table>";
//echo "<pre>";
//print_r($linha); // debug
//echo "</pre>";
$html;
// vamos trocar!
$row->text = preg_replace( $expressao, $html, $row->text );
// beleza. retorno true para que o mambo continue fazendo o que deve ser feito.
return true;
}
?>[/code:1]
This is mosauthorinfo.php
[code:1]<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall version="4.5.2" type="mambot" group="content">
<name>mosauthorinfo</name>
<author>Matheus Mendes</author>
<creationDate>April - 2005</creationDate>
<copyright>(C) 2005 </copyright>
<license>
www.gnu.org/copyleft/gpl.html
GNU/GPL
<authorEmail>bigodines at gmail.com</authorEmail>
<authorUrl>
www.joomla.com.br
<version>1.0</version>
<description>Add author's info to content</description>
<files>
<filename mambot="mosauthorinfo">mosauthorinfo.php</filename>
</files>
<params/>
</mosinstall>[/code:1]
This is mosauthorinfo.xml
Hi
I want to convert this mambot to modul or I want show in the left block this mambot. What can I do?
Post edited by: toplumdusmani, at: 2007/10/27 23:21
Post edited by: toplumdusmani, at: 2007/10/27 23:22