View Single Post
  #20  
Old 06-21-2009, 05:43 AM
nmilne nmilne is offline
 
Join Date: Aug 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Rather than use a plugin, another option is just to write a php file that you use as a php based module (as opposed to template based) and make a call to a template in the php code. You can also decide whether you want to have it link into a standalone gallery (as the examples given so far) or whether to link into an embedded gallery. You do this in the way you compose the request to get the latest/random/whatever image.

e.g.
http://{path to your gallery install}/main.php?g2_view=imageblock.External&g2_blocks=ran domImage&g2_show=fullSize&g2_show=title
gives a random image which will link to a stand alone gallery page

vs.
http://{path to your gallery integrated page}/gallery.php?g2_view=imageblock.External&g2_blocks= randomImage&g2_show=title
which gives a random image which links to an embedded gallery

Try both of the above just in a browser window and 'view source' to see the different links passed back by gallery in each case.

I'll give you an example here of what I did to put a latest image block in my web site.

Just create a new php file (called whatever you want) in your modules/ directory with the following content:
Code:
<?php
// ++=========================================================================++
// || Gallery block for vBAdvanced
// ++ ========================================================================++

// Get the latest image page block content from gallery
$gallery_content_url = $vbulletin->options['bburl'].'/gallery.php?g2_view=imageblock.External&g2_blocks=recentImage&g2_show=title';
$gallery_content = file_get_contents($gallery_content_url);

// Now call the template so that it can decide where to put the content
eval('$home["$mods[modid]"][\'content\'] = "' . fetch_template('adv_gallery_block') . '";');

?>
Then create a new module in VBA admin as a PHP module, choose the php file you created above in the 'file to include' drop down (make sure the file is in the modules directory), give it a unique id and add the name of a new template you need to create for the block (I called mine 'adv_gallery_block' but it can be whatever you want). Then add it to whatever VBA page definitions you have according to how you've set up your files and integration.

Finally, create a new template with the name you picked above (mine being called 'adv_gallery_block' in your desired style. You can design the template to garnish the image any way you want and reference the content that is extracted in the php file created previously. My simple example is -
Code:
<tr align="center">
	<td class="$bgclass">
		$gallery_content
	</td>
</tr>
Which simply dumps the content in the middle of a centred table data element. Make sure you've got he module enabled and the permissions are set correctly and you should be away and running

You can see mine in action at -

http://www.supermotoaus.com
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02330 seconds
  • Memory Usage 1,776KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete