Skip to Content Skip to Menu

Avatar Gallery (was Avatar Matrix) beta released

  • houbahop
  • houbahop
  • OFFLINE
  • Posts: 50
  • Thanks: 0
  • Karma: 9
17 years 8 months ago #30492 by houbahop
Replied by houbahop on topic Re:Beta of Avatar Matrix .4 : pagination hack
Hi guys,

I have added joomla's pagination system to this great module.

To have it to work, you need to replace the content of mod_avatar_matrix4.php by the code below.

Please keep it mind that if I have tested it and all seem to work, you should backup the previous file in case of bug.
I think that one possible issue could happen if you don't use the same method as me to make this module visible on a page:

1) Create a new position in the backend (site->template->module position)
for each isntance of the module, create a new position

2) I have created a new section and inside of it a new category.
For each instance of this module, I have created a content article.

3) I use a mambot named "mosloadposition" to load the content o a position in an article (for an unknow reason, i can't use a static content item in second-level-menu-items, that's why I create a section,category and use an article)

so I write {mosloadposition mynewposition} in the article and save.

4) In the module parameters, set the active menu link for this module.

If you dont want to use this method, you must modify the code that generate the link to adapt it to your URL before to click of the pagination buttons

[code:1]
$mylink =index.php?option='.$option.'&task=view&sectionid='. $section .'&id='. $cat;
[/code:1]


There is something else that you need to know :

With this hack, the module has a new behaviour. Now, the values that you enter for

Number of avatars to display horizontally and
Number of avatars to display vertically
are now the number of users displayed per page, so you need to enter for example 7 and 10 if you want 70 users per page.

To finish I would say that it something shoud be changed in this modified module, it's the first request. Unlike previously, now there is two SQL request : one that is used to count the total number of users, the second is retriving the user informations.
Here the two requests are the same. It would be less time consuming for the server if the first one was modified to return a count of the users instead of currently returning all users informations, THEN counting them in php.

Too, I havn't tested that with the display of cb fields under the avatar, by I don't see any reason for that to fail.

I hope it will be usefull. ;)

[code:1]
<?php
/**
* The Avatar Matrix Module
* Copyright (C) 2006 Roger Davis, PhD, www.VisionSimulations.com
* All rights reserved
* Released under GNU/GPL License : www.gnu.org/copyleft/gpl.html
* Version 0.3 August 1, 2006
* Email Address: rogerdavis@gmail.com
* 3 feb 2007 : added by houbahop@gmail.com : pagination system : still in BETA
* please save your file before to apply this modification.
* search for the string "modif pagination" (without the quotes) to find what I have added.
**/

// CSS classes that can be used to format your Avatar Matrix are
// Whole table of results: <table class='rajavatarmatrixtable'>
// Odd rows of table: <tr class='rajavatarmatrixoddrow'>
// Even rows of table: <tr class='rajavatarmatrixevenrow'>
// Title of table: <p class='rajavatarmatrixtitle'>"
// When there are no search results: <tr class='rajavatarmatrixnoresults'>

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $database;

$search = $params->get( 'search' );
$across = $params->get( 'across' );
$down = $params->get( 'down' );
$setcustomavatardimensions = $params->get( 'setcustomavatardimensions' );
$imageheight = $params->get( 'imageheight' );
$imagewidth = $params->get( 'imagewidth' );
$noavatarfilename = $params->get( 'noavatarfilename' );
$maxusernamelength = $params->get( 'maxusernamelength' );
$caption1 = $params->get( 'caption1' );
$caption2 = $params->get( 'caption2' );
$caption3 = $params->get( 'caption3' );
$captionheading1 = $params->get( 'captionheading1' );
$captionheading2 = $params->get( 'captionheading2' );
$captionheading3 = $params->get( 'captionheading3' );
$counter='';
$align='';

// Perform some bounds checking

if ($across<= 0 || $down<=0) {
echo "Across and down much be greater than zero!";
return;
}

// Below we ask whether the SQL that guides the search is supplied through the backend or along the URL.

switch ($search) {
case "1":
$query = $params->get( 'querystring1' );
$title = $params->get( 'searchtitle1' );
break;
case "2":
$query = $params->get( 'querystring2' );
$title = $params->get( 'searchtitle2' );
break;
case "3":
$query = $params->get( 'querystring3' );
$title = $params->get( 'searchtitle3' );
break;
case "4":
$query = $params->get( 'querystring4' );
$title = $params->get( 'searchtitle4' );
break;
case "5":
$query = $params->get( 'querystring5' );
$title = $params->get( 'searchtitle5' );
break;
case "6":
$query = $params->get( 'querystring6' );
$title = $params->get( 'searchtitle6' );
break;
case "7":
$query = $params->get( 'querystring7' );
$title = $params->get( 'searchtitle7' );
break;
case "8":
$query = $params->get( 'querystring8' );
$title = $params->get( 'searchtitle8' );
break;
case "9":
$query = $params->get( 'querystring9' );
$title = $params->get( 'searchtitle9' );
break;
case "10":
$query = $params->get( 'querystring10' );
$title = $params->get( 'searchtitle10' );
break;
default:
// if a value for search is passed other than 1 through 5 or url, then die.
die;
}

// Prebuild some strings for use later
$noavatarpath = "<img src =\"$mosConfig_live_site/components/com_comprofiler/plugin/language/default_language/images/";
$imagelink = "<img src =\"$mosConfig_live_site/images/comprofiler/tn";
$gallerylink = "<img src =\"$mosConfig_live_site/images/comprofiler/";
$profilelink = "<a href='index.php?option=com_comprofiler&task=userProfile&user=";
$rowcss = 1; // by multiplying by -1 for each row, we know whether its an odd or even row
$number = $across * $down; //we know how many profiles to try to retrieve from the database, since it's a matrix of profile avatars


/////modif pagination////
$limit = $number ; // le nb d user par page
$limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) );
/////////////


// See if the user wants to set custom height or width for the avatars.
if ($setcustomavatardimensions == True ) {
if ($imagewidth != 0) $setwidth = " width=\"$imagewidth\""; //set image width
if ($imageheight != 0) $setheight = " height=\"$imageheight\""; // set image height
}

$Accumulator = "<table class='rajavatarmatrixtable'>";

////////////////////////////////////////////////////////////////////
//LOOKS LIKE WE'RE READY TO CONSTRUCT THE MATRIX!!!!!!!!!!!!!!!!!!
////////////////////////////////////////////////////////////////////

//removed for modif pagination//$query .= " LIMIT $number"; //we limit the search. Pass some rediculously large number to show the whole membership.
$database ->setQuery ($query);
$results = $database->loadObjectList();

////modif pagination ///
$nbresultats=count($results); // on compte le nombre de resultats
if ( $nbresultats <= $limit ) $limitstart = 0;
require_once( $GLOBALS . '/includes/pageNavigation.php' );
$pageNav = new mosPageNav($nbresultats, $limitstart, $limit);
$limit = "";
$limits = "LIMIT " . $pageNav->limitstart . ", " . $pageNav->limit;
// copie de la requelle precedente mais c pas top, il faudra remplacer celle du haut par un count() plus rapide
$query .= " $limits";
$database ->setQuery ($query);
$results = $database->loadObjectList();
////////////////////



if (empty($results)) {
echo "<p class='rajavatarmatrixnoresults'>" . "Sorry, no profiles found" . "</p>";
return;
}

foreach($results as $result){
if ($counter % $across == 0) { //if the remainder is 0, then we're at the beginning of a new row! else, just generate code for a table cell.
$rowcss = -$rowcss;
if ($rowcss == 1) { //we want to allow the admin to change the color of odd and even rows so that it's easier for users to digest the search results
$Accumulator .= "<tr class='rajavatarmatrixoddrow'><td>\n";
} else {
$Accumulator .= "<tr class='rajavatarmatrixevenrow'><td>\n";
}
}
else {
$Accumulator .= "<td" . $align . ">\n";
}

$avatarcaption1="";
$avatarcaption2="";
$avatarcaption3="";

if (empty($caption1)==false && is_null($result->$caption1)==false) $avatarcaption1 = "<p class='avatarcaption1'>" . $captionheading1 . $result->$caption1 . "</p>" ;
if (empty($caption2)==false && is_null($result->$caption2)==false) $avatarcaption2 = "<p class='avatarcaption2'>" . $captionheading2 . $result->$caption2 . "</p>" ;
if (empty($caption3)==false && is_null($result->$caption3)==false) $avatarcaption3 = "<p class='avatarcaption3'>" . $captionheading3 . $result->$caption3 . "</p>" ;

$imagefilename = $result->avatar;
if ($imagefilename==Null) $imagefilename= $noavatarfilename;
$imagefilename = $imagefilename . "\" alt=\"member image\"";
if ($imagewidth != 0) $imagefilename = $imagefilename . $setwidth;
if ($imageheight != 0) $imagefilename = $imagefilename . $setheight;

$query_name = "SELECT id,username FROM #__users WHERE id = ".$result->user_id;
$database ->setQuery ($query_name);
$usernames = $database->loadObjectList();

foreach($usernames as $username){
if (substr_count ( $imagefilename, $noavatarfilename)!=0) {
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $noavatarpath . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(gallery)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $gallerylink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(jpg)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(png)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(gif)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(bmp)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(jpeg)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
elseif(preg_match('/(tif)/',$imagefilename)){
$profile = "<div>" . $profilelink . $result->id . "'><p>" . $username->username . "</p>" . $imagelink . $imagefilename . ">" . $avatarcaption1 . $avatarcaption2 . $avatarcaption3 . "</a></div>\n";
}
}

$Accumulator = $Accumulator . $profile;
$counter++; //keep track of the number of profiles written out

if ($counter % $across == 0) { //need to close the table row and/or table cell
$Accumulator .= "</td></tr>\n";
}
else {
$Accumulator .= "</td>\n";
}

if ($counter > $number) { //we've reached the maximum number of results to return, so break out of the for-each loop. note that we may not generate enough table cells to fill the last row, and this is okay.
break;
}
}

$Accumulator .= "</table>\n";

//display the results
if (empty($title) == false) echo "<p class='rajavatarmatrixtitle'>" . $title . "</p>";

///////modif pagination///////
echo $pageNav->writePagesCounter()."<br />";
///////////////////////////////

echo $Accumulator;

///////modif pagination///////
$section = intval( mosGetParam( $_REQUEST, 'id', null ) );
$cat = intval( mosGetParam( $_REQUEST, 'Itemid', null ) );
$option = strval( strtolower( mosGetParam( $_REQUEST, 'option', null ) ) );
$mylink = 'index.php?option='.$option.'&task=view&sectionid='. $section .'&id='. $cat;
echo "<br />".$pageNav->writePagesLinks($mylink);
///////////////////////////////

return;

?>
[/code:1]



Houbahop.

Attachment mod_avatar_matrix4.zip not found



Post edited by: houbahop, at: 2007/02/03 20:59

Post edited by: houbahop, at: 2007/02/03 21:01

Post edited by: houbahop, at: 2007/02/03 21:03

Post edited by: houbahop, at: 2007/02/03 21:08

Post edited by: houbahop, at: 2007/03/08 01:57
Attachments:

Please Log in or Create an account to join the conversation.

  • Raj
  • Raj
  • OFFLINE
  • Posts: 191
  • Thanks: 0
  • Karma: 30
17 years 8 months ago #30494 by Raj
I haven't tested it, but it looks good. I'm glad people are elaborating it. You want to collaborate on version .5? Might speed development along, since I'm so busy.

Roger

Please Log in or Create an account to join the conversation.

  • houbahop
  • houbahop
  • OFFLINE
  • Posts: 50
  • Thanks: 0
  • Karma: 9
17 years 8 months ago #30495 by houbahop
Replied by houbahop on topic Re:Beta of Avatar Matrix .4 : pagination hack
Hi,

I'm sorry, I can't collaborate because I do that in my spare time too and I allready have too much things to do for myself :blush:

But I will post here any of the modifications that I will do to your module, thank you for your work, it's nice.

I had a previous experience with joomla's pagination system. That's why it was not too long to modify this one.

Good luck for V5 :side:

Houb.

Please Log in or Create an account to join the conversation.

  • Raj
  • Raj
  • OFFLINE
  • Posts: 191
  • Thanks: 0
  • Karma: 30
17 years 8 months ago #30496 by Raj
That's cool.... I'll try to build pagination into .5 and might ask for your help if I get stuck. I don't have a clue about pagination, but I'm looking forward to reviewing your code.

Roger

Post edited by: Raj, at: 2007/02/03 21:15

Please Log in or Create an account to join the conversation.

  • obendega
  • obendega
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
17 years 8 months ago #30512 by obendega
Replied by obendega on topic Re:Beta of Avatar Matrix .4 : pagination hack
Let me know if you need help beta testing .5!

Please Log in or Create an account to join the conversation.

  • Raj
  • Raj
  • OFFLINE
  • Posts: 191
  • Thanks: 0
  • Karma: 30
17 years 8 months ago #30513 by Raj
I do need help beta testing it. Will be working on the code tonight actually. :)

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum