Jump to content


Picture Block


  • You cannot reply to this topic
14 replies to this topic

#1 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 14 December 2006 - 02:49 PM

Ok I need help now does anyone know the code to use to display a random Gallery picture on the portal please.

#2 RisingPhoenix

    Advanced Member

  • Administrators[Admin]
  • PipPipPip
  • 249 posts
  • Gender:Male
  • Location:Fort Benning, GA
  • Interests:I am currently in the US Army. I am not a coder. I am really familiar with Unreal Portal and IPB. So if it isn't in reference to something I have on my site ba4life.com then there isn't much I can do to help you.<br /><br />I am a normal user like most of you. Please don't invade my personal life by asking me questions that can already be found on this website.

Posted 14 December 2006 - 03:06 PM

Working on it.
Posted Image
MultiGaming Clan Playing Games since 1997

#3 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 14 December 2006 - 03:34 PM

Excellant mate thank you :P :P

#4 lucidservant

    Member

  • Members
  • PipPip
  • 22 posts

Posted 16 December 2006 - 07:21 PM

another one waiting :-)

#5 Guest_miguelmayo_*

  • Guests

Posted 18 December 2006 - 06:45 AM

First add a new custom block, give it a Block Name *The name has to be lowercase and only one word for it to work, then put in a descpription below that of what the header will read, then paste the code below into the text box form.

<?php 
echo('<Center><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`,`description`,`comments`,`views` FROM `ibf_gallery_images` , `ibf_members` WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1 and ibf_gallery_images.pinned=1 ORDER BY rand() LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) { echo('<TD ALIGN=center width=99%> <a href="../forum/index.phpact=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('</B>'.$MZrow['caption'].'</B><BR><BR><IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0></a><BR><i>'.$MZrow['description'].'</i><BR><BR>by '.$MZrow['mname'].'</br><b>Comments</b>: '.$MZrow['comments'].' :: <a href="../forum/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">View Comments</a>');
echo (' :: Views: '.$MZrow['views'].'</TD></TR></TR>');
}
echo('</TR></TABLE>');
?>


The above box has a tendancy to garble up when copy pasting to your "add custom block" posting screen. Just make sure that the ";" are at the end of each line break. If you get strange errors after adding the block, go back and edit the php so that the line breaks are happening after the ";" it wont parse correctly otherwise if it gets word wrapped in the wrong order.


This is a modification from a random gallery image block from the previous version portal that I modified. This will only use pinned photos, shown randomly, if you dont want that remove this code
and ibf_gallery_images.pinned=1


- also you can size the photos by adding a width where the code reads
<IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0>


Add a width statement and the pixle number you want it at!
<IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 width=360>


Or use the thumb nails instead

<IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/'tn_.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0>


I went so far as to make the pinned button in the gallery viewable by only a global moderator so that we can control whats pinned on the portal.

forum/modules/gallery/img_view.php line 752

//-------------------------------------------------------
		// Pin Image Button
		//-------------------------------------------------------
		if( $this->is_moderator )


Change to
//-------------------------------------------------------
		// Pin Image Button
		//-------------------------------------------------------
		if($this->ipsclass->member['g_mod_albums']  )


#6 Guest_miguelmayo_*

  • Guests

Posted 18 December 2006 - 07:00 AM

Oh to see how it looks on my portal

http://www.vfrdiscussion.com

#7 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 18 December 2006 - 01:18 PM

Thanks for this however is this for 2.2 as I cannot get it to work at all.

#8 Guest_miguelmayo_*

  • Guests

Posted 18 December 2006 - 03:52 PM

yea my board is 2.2 and gallery 2.1 it does work!

#9 redalert19882000

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 19 December 2006 - 08:44 AM

Random image

First run the query...

INSERT INTO ibf_unrealportal VALUES ('', 'random_image', 'Random Image', 'right', 1, 24);



Open: ./sources/action_admin/uportal.php

Find:

$this->ipsclass->adskin->td_header[] = array( "&nbsp;"   , "40%" );
		$this->ipsclass->adskin->td_header[] = array( "&nbsp;"   , "60%" );

		$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Custom Blocks" );


Add Above:

# Start
		$this->ipsclass->adskin->td_header[] = array( "&nbsp;"   , "40%" );
		$this->ipsclass->adskin->td_header[] = array( "&nbsp;"   , "60%" );

		
		$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Show Random Image?</b>", $this->ipsclass->adskin->form_yes_no( "random_image", $GLOBALS['block']['random_image'] )
																	)	  );

		$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
								# end



Open: ./sources/action_public/uportal.php

Find:

$this->data['site_search']	= $this->do_site_search();


Add Below:

$this->data['random_image']	= $this->do_random_image();


Find:

}
?>


Add Above:

# Random Image
	function do_random_image()
	{
		if( ! $GLOBALS['block']['random_image'] ) return FALSE;

		$i = 0; $imgs = array();
		$img  = $this->ipsclass->vars['img_url'].'/nophoto.gif';
		$path = 'path to images';

		if( is_dir($path) )
		{
			if( $dh = @opendir($path) )
			{
				@clearstatcache();
				while( ($entry = readdir($dh)) !== false )
				{
					if( is_file($path."/".$entry) && ($entry != ".") && ($entry != "..") && preg_match("/\.(bmp|gif|jpeg|jpg|png|tif|tiff)/", $entry) )
					{
						$imgs[$i++] = $entry;
					}
				}
				@closedir($dh);

				srand((double) microtime()*1000000);
				$img = $path.'/'.$imgs[rand(0, sizeof($imgs)-1)];
			}
		}

		$output .= $this->ipsclass->compiled_templates['skin_uportal']->block_header( $this->collapse( 'random_image' ), 'randimage' );
		$output .= $this->ipsclass->compiled_templates['skin_uportal']->random_image( $img );
		$output .= $this->ipsclass->compiled_templates['skin_uportal']->block_footer();

		return $output;
	}


Goto: Admin CP: Skin & Templates: Skin Manager: Edit Template HTML: skin_uportal:

Click on "Add Template Bit" button
- New Template Bit Name: random_image
- New Template Bit Incoming Data Variables: $img=""
- New Template Bit Group...: skin_uportal
- Add New Template Bit:

<tr><td class='row1' align='center'><img src='$img' width='80' border='0' alt='' /></td></tr>





Edit the link $path = 'path to images (gallery)';

#10 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 19 December 2006 - 03:50 PM

Quote

yea my board is 2.2 and gallery 2.1 it does work!


This is all I get when I put yours in mate.

IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 4 of /sources/action_public/uportal.php(855) : eval()'d code)


And RedAlert yours is an add on and does not connect to the gallery, also you have to install it into every skin before the skin will display.

I guess it puts us back to the drawing board.

#11 redalert19882000

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 20 December 2006 - 08:22 AM

Yeah! This script is shows random image from every images but you can use it !

#12 Guest_miguelmayo_*

  • Guests

Posted 25 December 2006 - 02:57 AM

View PostGerry, on Dec 19 2006, 05:50 PM, said:

This is all I get when I put yours in mate.

IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 4 of /sources/action_public/uportal.php(855) : eval()'d code)


And RedAlert yours is an add on and does not connect to the gallery, also you have to install it into every skin before the skin will display.

I guess it puts us back to the drawing board.

Like I mentioned before it is sensitive to line breaks, there must be a ";" at the end of each line break or the server wont recognize it as valid mysql. I went back and edited the code block I posted above and removed a line break at line 4 - just as it said in your error message. try it again, It works for me and I just upgraded to 2.2.1 and upgraded the gallery too. Its just raw php so it its not dependant on the version, if its parsing php it should work!

#13 Drew

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 06 January 2008 - 10:50 AM

I am also getting the error mayo

Call to undefined method skin_uportal_2::block_header() in /home/db/public_html/old_stuff/R2/sources/action_public/uportal.php on line 1330


And can you explain to a noob this plz

Edit the link $path = 'path to images (gallery)';

is this the link to my gallery or the gallery random images or the folder in my ftp?

I have just installed this mod on my site so I am on a bit of a learning curve here lol

#14 Paul

    Member

  • Members
  • PipPip
  • 16 posts

Posted 22 September 2009 - 02:30 AM

Anyone got this working for 3.0.3? whould be great to have a pinned picture block

Paul

#15 deanhennings

    Newbie

  • Members
  • Pip
  • 3 posts
  • Gender:Male

Posted 03 December 2009 - 06:53 PM

Hi I have a few blocks done

iAvertise
Gallery
Member Panel (invisionmoddings)
Board Footer

PM me and will send a file, works very well on my site and should work on anysite.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users