Picture Block
Started by Gerry, Dec 14 2006 02:49 PM
14 replies to this topic
#5 Guest_miguelmayo_*
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.
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
- also you can size the photos by adding a width where the code reads
Add a width statement and the pixle number you want it at!
Or use the thumb nails instead
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
Change to
<?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_*
#8 Guest_miguelmayo_*
Posted 18 December 2006 - 03:52 PM
yea my board is 2.2 and gallery 2.1 it does work!
#9
Posted 19 December 2006 - 08:44 AM
Random image
First run the query...
Open: ./sources/action_admin/uportal.php
Find:
Add Above:
Open: ./sources/action_public/uportal.php
Find:
Add Below:
Find:
Add Above:
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:
Edit the link $path = 'path to images (gallery)';
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( " " , "40%" ); $this->ipsclass->adskin->td_header[] = array( " " , "60%" ); $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Custom Blocks" );
Add Above:
# Start $this->ipsclass->adskin->td_header[] = array( " " , "40%" ); $this->ipsclass->adskin->td_header[] = array( " " , "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
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.
#12 Guest_miguelmayo_*
Posted 25 December 2006 - 02:57 AM
Gerry, on Dec 19 2006, 05:50 PM, said:
This is all I get when I put yours in mate.
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.
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
Posted 06 January 2008 - 10:50 AM
I am also getting the error mayo
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
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
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users













