SimplePortal

Customization => Custom Coding => Topic started by: CasN on May 19, 2010, 06:26:01 AM

Title: Simple AEVA album block
Post by: CasN on May 19, 2010, 06:26:01 AM
Was experimenting with Aeva and the side blocks, this gives a simple overview of the 5 albums last mainatined
Code: [Select]
$query="SELECT distinct id_album,name FROM smf_aeva_albums,smf_aeva_media where smf_aeva_albums.id_album=smf_aeva_media.album_id order by time_added limit 5";
$result = mysql_query($query);;
while ($row = mysql_fetch_array($result)) {
   $linkurl= "index.php?action=media;sa=album;in=".$row['id_album'];
   echo "<a href=$linkurl >".$row['name']."</a> \n\n";
}
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on May 19, 2010, 08:50:43 AM
Great work if this satisfies your need. Cheers!
 
I have a few comments that I think will make this even better
1) This code will work for SMF 1.X, but not for 2.x. It will not be difficult to change it for SMF 2.X when you need to.
2) It is a good plan to close the database connection as soon as possible. Many viewers may want to see your website at the same time. In SMF 1.X, this is done with mysql_free_result.
3) The ";;" is not necessary.  Then again, it isn't hurting anything.
 
Code: [Select]
// code for SMF version 1.1.11
$query="SELECT distinct id_album,name FROM smf_aeva_albums,smf_aeva_media where smf_aeva_albums.id_album=smf_aeva_media.album_id order by time_added limit 5";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
   $linkurl= "index.php?action=media;sa=album;in=".$row['id_album'];
   echo "<a href=$linkurl >".$row['name']."</a> \n\n";
}
mysql_free_result($request);
Title: Re: Simple AEVA album block
Post by: CasN on May 31, 2010, 02:48:47 AM
Thanks for the feedback, you are right on all points. The ';;' was a typo. Closing indeed is better, just need to use the correct one ($result opposite $request).


Also found a block for scrolling the pics. Found it on TinyPortal but works equally great on Simple portal:
Code: [Select]
// Configurable Graphics block
// for use with Aeva multimedia mod for SMF
// by BlueSteel 18th April 2010
// @TinyPortal : http://www.tinyportal.net/index.php?topic=32504.0
// Scrolling Options - on/off direction, speed, delay
// Item display options Random/Newest, number of item to display,selectable albums
// Marquee script Variables
$marq_offon = 1;       
// 0=off 1=on
$marq_behavior = "scroll";         
// what should marquee do "scroll"
$marq_direction = "up";           
// "left" , "right" , "up", "down"
$marq_height = "200px";           
// size of viewable block area
$marq_scrolldelay = 10;           
// delay iteritions
$marq_scrollamount = 1;         
// how many pixels to scroll block each iteration
$marq_onmouseover = "this.stop()";
// what to do on mouseover
$marq_onmouseout = "this.start()"; 
// what to do on mouseout

// Aeva script variables
//       - Gets items : array aeva_getMediaItems(int start, int limit, string sort, bool all_albums, array albums, string custom)
$aeva_start = 0;                   
// where item number to start at
$aeva_limit = 25;                 
// maximum number of items to display
$aeva_sort = 'RAND()'; 
// sort see Aeva-Subs.php for values I use 'RAND()' or 'm.time_added DESC' DESC or ASC for sorting order
$aeva_all_albums = true;           
// all albums .. true or false
$aeva_albums = array();           
// for a single album put eg: array(10) for an array of albums eg: array(3,5,7) for all albums eg:array()
$aeva_custom ='m.id_media';       
// aeva custom string
// - Creates HTML for viewing items : string aeva_listItems(array items, bool in_album = false, string align, int per_line)
$aeva_in_album = false;           
// unknown paramiter .. set to false by default for now
$aeva_align = 'center';           
// allign items 'left' 'center' 'right'
$aeva_per_line = 1;               
// number of colums to display at once eg: 1 for single .. 3 for 3 items accrossglobal
$sourcedir;   require_once($sourcedir . '/Aeva-Subs.php');   
// -------------------------------------
// Don't edit anything below this line
// -------------------------------------
// Start marquee routine if set to do so
if ($marq_offon == 1){   
echo '<marquee behavior=',$marq_behavior,' direction=',$marq_direction,' height=',$marq_height,' scrolldelay=',$marq_scrolldelay,' scrollamount=',$marq_scrollamount,' onmouseover=',$marq_onmouseover,' onmouseout=',$marq_onmouseout,' >';
}
// end marquee routine
// start actual block to be displayed   
echo '<div style="width: 100% height:',$marq_height,'; overflow: hidden;">';   
echo aeva_listItems(aeva_getMediaItems($aeva_start,$aeva_limit,$aeva_sort,$aeva_all_albums,$aeva_albums,$aeva_custom),$aeva_in_album,$aeva_align,$aeva_per_line);   
echo '</div>';
// end actual block to be displayed
//start marquee routine   
if ($marq_offon == 1){
echo'</marquee>';
}
//end scrolling routine
Title: Re: Simple AEVA album block
Post by: eyeseven on September 19, 2010, 09:39:26 AM
Do you have Album Block for rc3?

thanks! :)
Title: Re: Simple AEVA album block
Post by: eyeseven on September 20, 2010, 04:17:06 PM
please, any code for rc3 recent album list,, please please pleasse...
Title: Re: Simple AEVA album block
Post by: headsortailsuk on November 04, 2010, 04:53:21 AM
I too am looking for a block that will display only the contents of a particular album for SMF 2 RC3, SP 2.3.2.

Are there any about?
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on November 04, 2010, 07:14:15 AM
Code: [Select]
function ab_album_AEVA($album=0, $order='random', $start=0, $count=5)
{
 global $sourcedir, $scripturl, $settings;
 include_once($sourcedir . '/Aeva-Subs.php');
 if ( is_int($album) && !($album==0) )
 {
  $aeva_albums = array($album);
  $aeva_all_albums = true;
 }
 else
 {
  $aeva_all_albums=TRUE;
  $aeva_albums = array();
 }
 if ( $order === 'random' )
  $aeva_order = 'RAND()';
 else
  $aeva_order = 'DESC';
 
  echo preg_replace('~<div class="highslide-maincontent">.*?</div>.*?</div>~', '',
          aeva_listItems(
     aeva_getMediaItems($start, $count, $aeva_order, $aeva_all_albums, $aeva_albums),
     false, '', 5)
  )
  ;
 
}
Title: Re: Simple AEVA album block
Post by: headsortailsuk on November 04, 2010, 07:38:27 AM
Many thanks, how do I go about specifying which album to display?
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on November 04, 2010, 08:31:58 AM
Code: [Select]
ab_album_AEVA(1);
or
Code: [Select]
ab_album_AEVA(array(1,3,5));
Title: Re: Simple AEVA album block
Post by: headsortailsuk on November 04, 2010, 09:52:57 AM
Do I add that or replace? I've tried replace the existing ab_album_AEVA... but it fails.
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on November 04, 2010, 01:18:18 PM
You will be using php to do this, so it will be a good idea to learn a little about programming with php:
http://w3schools.com/php/default.asp (http://w3schools.com/php/default.asp)
http://www.php.net/docs.php (http://www.php.net/docs.php)
 
1) Create a new php file.  Call it ab_album_AEVA.php. Save the file in your Sources directory.
2) put the following in a custom php block:
Code: [Select]
global $sourcedir;              // make sure to use SMF's global sourcedir variable.
include_once($sourcedir . '/ab_album_AEVA.php');    // load the file you need
ab_album_AEVA(1);          // call the function you want to use.
Title: Re: Simple AEVA album block
Post by: headsortailsuk on November 08, 2010, 05:46:24 AM
Many thanks for your help.

When I enter your code into the custom php block I get

'Syntax error in block code. Please check the code.'

Any ideas?
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on November 08, 2010, 10:13:08 AM
when you preview the block -- what error message do you get?
My first guess would be -- put the attached file in your Sources/ directory.
 
But -- note -- I have not tested this with the AEVA 1.4
Title: Re: Simple AEVA album block
Post by: headsortailsuk on November 08, 2010, 10:26:32 AM
On preview I get:-

Code: [Select]
Fatal error: Call to undefined function ab_album_AEVA() in /usr/virtual/latebay.co.uk/htdocs/Sources/PortalBlocks.php(3332) : eval()'d code on line 3
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on November 08, 2010, 11:01:40 AM
Your error message means that the function was not defined.
You can either put the function definition (given in http://simpleportal.net/index.php?topic=5550.msg38908#msg38908 (http://simpleportal.net/index.php?topic=5550.msg38908#msg38908)) in a file (as in the 3-line block example) or you can put it straight into the block.
 
Which would you prefer.
Title: Re: Simple AEVA album block
Post by: Morph on March 01, 2011, 01:53:24 PM
I know i wrote a similar thing in another topic, but now i see this and maybe i could have more help :)
the question is: ".....and if i would like to hide some albums? i'd like to show in the block only pictures from predefined albums"
Any idea?  :whistle:
Title: Re: Simple AEVA album block
Post by: AngelinaBelle on March 01, 2011, 02:14:00 PM
the question is: ".....and if i would like to hide some albums? i'd like to show in the block only pictures from predefined albums"

That's the idea of that function. You supply the list of albums. The function takes care of the rest.
 
Mind you -- I have not tested this code with the latest version of AEVA.
Title: Re: Simple AEVA album block
Post by: Morph on March 01, 2011, 02:22:25 PM
instead i have the latest version and SMF 1.1.13, so maybe a little different, in fact it does not work :)
Title: Re: Simple AEVA album block (latest albums list)
Post by: andy on November 27, 2012, 09:26:10 AM
Does anyone know how to display latest albums (list)?

Everything Ive found only displays photos but I would like to display a list of recent albums. It is shown as a list at the bottom of the media page but I would like to put it in a block in another place like the column of the forum page. This way people can see straight away there are new event photos rather than have to go to the gallery page and scroll down to the bottom of the page.
I cant find the code that displays this in the aeva media files...

Or perhaps the way most blocks work now by displaying an image, but it would be the icon photo for the album or default one with link. Just a simple url linked list would be good though with a variable for number of days to set as recent or latest.




SimplePortal 2.3.8 © 2008-2024, SimplePortal