avatar sql query in module uzbirthday

11 years 4 months ago #216231 by marianaf
avatar sql query in module uzbirthday was created by marianaf
Hello,

i´m trying to display the avatar of CB members who are displayed in the module uzbirthday (birthay date) but i can´t get the image to display correctly. There´s something wrong about the query that i m not being able to solve.

Here´s what i added to the default.php of the uzbirthday module code:

$config =& JFactory::getConfig();
$database=& JFactory::getDBO();

$query = "SELECT avatar FROM `#__comprofiler` WHERE `user_id` = {USERID} AND `avatarapproved` = '1'";
$database->setQuery( $query );
$avatar = $database->loadResult();

$avatarlink = $config->liveSite.'/images/comprofiler/'.$avatar;
echo JHTML::image($avatarlink, 'avatar');



and the code of the defaul.php is:
<?php
/**
* Module: mod_uzbirthdays
* Version: 3.12
* Joomla: 1.5 and 1.6
* Author: Udo Zaydowicz -> www.zaydowicz.de/joomla.html
* Date: 2011-09-22
* License: GNU/GPL v3 -> www.gnu.de/documents/gpl-3.0.de.html
*/

defined( '_JEXEC' ) or die( 'Restricted access' );
$config =& JFactory::getConfig();
$database=& JFactory::getDBO();

$query = "SELECT avatar FROM `#__comprofiler` WHERE `user_id` = {USERID} AND `avatarapproved` = '1'";
$database->setQuery( $query );
$avatar = $database->loadResult();

$avatarlink = $config->liveSite.'/images/comprofiler/'.$avatar;
echo JHTML::image($avatarlink, 'avatar');


function Load_CBfield($fieldname) {
global $database;
$user =& JFactory::getUser();
$userId = $user->get( 'id' );
$sql = "SELECT avatar FROM `#__comprofiler` WHERE `user_id` = {USERID} AND `avatarapproved` = '1'";
$database->setQuery( $sql );
echo $database->loadResult();
}

echo ('<img src="images/comprofiler/'.$avatar.'>');

// Set bold type
if (1 == $params->get('show_boldface', 0))
{
$boldstart = "<b>";
}
else
{
$boldstart = "";
}
$boldend = $boldstart;

// Display birthdays
if ($uz_birthdays)
{
$future = 0;
$actual = 0;
$id = 0;

// Output
$html = "<ul style=\"list-style-type:none;\">\n";

foreach ($uz_birthdays as $day)
{
// Prevent duplicate entries for admin (logged in backend + frontend)
if ($id == $day->user_id)
{
continue;
}

if (0 == $day->days_to_go)
{
$actual = 1;
}

// Title for future birthdays
if ($day->days_to_go > 0)
{
if (0 == $actual)
{
$actual = 1;
$html .= $boldstart . $params->get('text_no_birthday', 'no birthdays') . $boldend;
}

if (0 == $future)
{
$future = 1;
$html .= "</ul>\n";
$soon = $params->get('text_future', 'soon');
if (strlen($soon) > strlen(trim($soon, "%b")))
{
$html .= "<br />";
$soon = trim ($soon, "%b");
}
$html .= $boldstart . $soon . $boldend;
$html .= "<ul style=\"list-style-type:none;\">\n";
}
}

// List entries
$html .= "<li>";
$html .= $boldstart;

// Show online status
if (1 == $params->get('show_status', 1))
{
if ($day->time > 0)
{
$html .= "<img src=\"" . JURI::base() . "/modules/mod_uzbirthdays/images/online.gif\" title=\"online\"/>&nbsp;";
}
else
{
$html .= "<img src=\"" . JURI::base() . "/modules/mod_uzbirthdays/images/offline.gif\" title=\"offline\"/>&nbsp;";
}
}

// Username or Realname with or without profile link
if (0 == $params->get('show_realname', 0)) // username
{
if (1 == $params->get('show_link', 1))
{
$html .= "<a href=\"index.php?option=com_comprofiler&task=userProfile&user=" . $day->user_id . "\">" . $day->username . "</a>";
}
else
{
$html .= $day->username;
}
}
else // real name
{
if (1 == $params->get('show_link', 1))
{
$html .= "<a href=\"index.php?option=com_comprofiler&task=userProfile&user=" . $day->user_id . "\">" . $day->name . "</a>";

}
else
{
$html .= $day->name;
}
}
$html .= $boldend;

// Show_day/age or not
if (0 == $day->days_to_go)
{
if (1 == $params->get('show_age', 1))
{
if ('' == $params->get('age_unit', ''))
{
$html .= " (" . $day->age . ")";
}
else
{
$html .= " (" . $day->age . " " . $params->get('age_unit', '') . ")";
}
}
}
else
{
if ($params->get('days_in_future', 7) > 0)
{
switch ($params->get('date_type', 0))
{
case 0:
$date = $day->gday . "." . $day->gmonth . ".";
break;
case 1:
$date = $day->gmonth . "." . $day->gday . ".";
break;
case 2:
$date = $day->gday . "-" . $day->gmonth;
break;
case 3:
$date = $day->gmonth . "-" . $day->gday;
break;
}

if (1 == $params->get('show_age', 1))
{
if ('' == $params->get('age_unit', ''))
{
$html .= " (" . $day->age . ")";
}
else
{
$html .= " (" . $day->age . " " . $params->get('age_unit', '') . ")";
}
}
if (1 == $params->get('show_date', 1))
{
$html .= " (" . $date. ")";
}
}
}

$html .= "</li>\n";

$id = $day->user_id;
}

$html .= "</ul>\n";
echo $html;
}
else
{
// Show if no birthdays were found
echo $boldstart . $params->get('text_no_birthday', 'no birthdays') . $boldend;
}
?>

Please Log in to join the conversation.

11 years 3 months ago - 11 years 3 months ago #217843 by kaefee
Replied by kaefee on topic Re: avatar sql query in module uzbirthday
Here is how I managed to

1. First modified the modules/mod_uzbirthdays/helper.php file, add cb.avatar, in the query - Line 30.
// get birthdays
		$sql = "SELECT j.email, j.name, j.username, cb.user_id, s.time, cb.avatar,

This add the avatar link to the array of the query.

2. Make a copy of the modules/mod_uzbirthdays/tmpl/default.php file into your template in templates/YOUR_TEMPLATE/html/mod_uzbirthdays/default.php
This is just to use the override system of Joomla and make the changes in the copied file of your template.

3. Change some options of the default file (This section depends on what you want), I insert some lines in 110 because I need to display the real name of the user, so change this

else // real name
		{					
			if (1 == $params->get('show_link', 1)) 
			{
				$html .= "<a href=\"index.php?option=com_comprofiler&task=userProfile&user=" . $day->user_id . "\">" . $day->name . "</a>";
			}
			else 
to this
else // real name  - modified by kaefee
		{					
			if (1 == $params->get('show_link', 1)) 
			{
				
				$html .= "<div><a href=\"index.php?option=com_comprofiler&task=userProfile&user=" . $day->user_id . "\">" . $day->name . "</a>";
			    $html .= "<span>SOME ADDITIONAL TEXT IF YOU WANT</span></div>";
			    $avatarlink = JURI::base(). "/images/comprofiler/".$day->avatar;
			    $html .= "<img src=". $avatarlink. " alt='imagen' width='47px' height='47px'/>" ;
			}
			else


I hope that helps
The following user(s) said Thank You: juan_pantera

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.203 seconds

Facebook Twitter LinkedIn