i found a Tutorial for IP.Gallery 2.2.3 that show how can randomly show 5 images on Board index 2.2.6
here is code
Open Sources/Action_public/boards.php
find
$this->process_all_cats();
ad after
$this->rand_gallery_images();
find
} ?>
add above
function rand_gallery_images()
{
$rand5_html = "";
if ( $this->ipsclass->vars['gallery_offline'] || ! $this->ipsclass->member['id'] )
{
return $rand5_html;
}
$this->ipsclass->DB->build_query(array('select' => 'gallery_perms', 'from' => 'members', 'where' => "id=".$this->ipsclass->member['id']));
$this->ipsclass->DB->exec_query();
$this->ipsclass->member = array_merge($this->ipsclass->member, $this->ipsclass->DB->fetch_row());
$perms = explode(':', $this->ipsclass->member['gallery_perms']);
if (! $perms[2])
{
return $rand5_html;
}
define( 'GALLERY_PATH' , ROOT_PATH . 'sources/components_public/gallery/' );
define( 'GALLERY_LIBS' , GALLERY_PATH . 'lib/' );
require_once( ROOT_PATH . 'sources/api/api_core.php' );
require_once( ROOT_PATH . 'sources/api/gallery/api_gallery.php' );
$this->ipsclass->vars['gallery_img_show_rate'] = 1;
$this->ipsclass->vars['gallery_use_rate'] = 1;
$this->ipsclass->load_language( 'lang_gallery' );
$this->ipsclass->load_template( 'skin_gallery_global' );
$this->ipsclass->DB->load_cache_file(ROOT_PATH.'sources/sql/'.SQL_DRIVER.'_gallery_queries.php', 'gallery_sql_queries');
require_once( GALLERY_LIBS . 'lib_gallery.php' );
$this->glib = new lib_gallery();
$this->glib->ipsclass =& $this->ipsclass;
$this->glib->category =& $this->category;
require( GALLERY_LIBS . 'lib_categories.php' );
$this->category = new lib_categories();
$this->category->ipsclass =& $this->ipsclass;
$this->category->normal_init();
require( GALLERY_LIBS . 'lib_albums.php' );
$this->albums = new lib_albums();
$this->albums->ipsclass =& $this->ipsclass;
$this->albums->glib =& $this->glib;
require_once ( GALLERY_LIBS . 'lib_imagelisting.php' );
$img_list = new lib_imagelisting();
$img_list->ipsclass =& $this->ipsclass;
$img_list->glib =& $this->glib;
$img_list->category =& $this->category;
$img_list->init();
$gal_api = new api_gallery;
$gal_api->ipsclass = $this->ipsclass;
$gal_api->glib = & $this->glib;
$gal_api->category = & $this->category;
if ($this->ipsclass->vars['gallery_stats_where'] == 'both' || $this->ipsclass->vars['gallery_stats_where'] == 'cat')
{
$allow_cats = $this->category->get_allowed_cats(1, $this->category->data);
if (! count($allow_cats)) return $rand5_html;
}
if ($this->ipsclass->vars['gallery_stats_where'] == 'both' || $this->ipsclass->vars['gallery_stats_where'] == 'album')
{
$allow_albums = $this->glib->get_allowed_albums();
if (! count($allow_albums)) return $rand5_html;
}
$total = $this->ipsclass->vars['gallery_idx_num_row'];
$img_list->get_listing_data(array(
'st' => 0,
'show' => $total,
'approve' => 1,
'sort_key' => 'RAND()',
'allow_cats' => $allow_cats,
'allow_albums' => $allow_albums,
) );
$show['name'] = str_replace("<#NUM#>", $total, $this->ipsclass->lang['random5']);
$collapsed_ids = ','.$this->ipsclass->my_getcookie('collapseprefs').',';
$show['div_fo'] = 'show';
$show['div_fc'] = 'none';
if (strstr($collapsed_ids, ',rand,'))
{
$show['div_fo'] = 'none';
$show['div_fc'] = 'show';
}
$rand5_html .= $this->ipsclass->compiled_templates['skin_boards']->galleryrand_top($show);
$rand5_html .= $img_list->get_html_listing(array('imgs_per_col' => $this->ipsclass->vars['gallery_idx_num_col'], 'imgs_per_row' => $this->ipsclass->vars['gallery_idx_num_row'], 'can_rate' => ($this->ipsclass->vars['gallery_use_rate'] && $this->ipsclass->member['g_rate']) ? 1 : 0));
$rand5_html .= $this->ipsclass->compiled_templates['skin_boards']->galleryrand_end($total);
return $rand5_html;
}
But unfortunately the skin adding part is damaged during converting IPB 2.2 to 3.0
but i have maked 2 templates in Board_index 1.galleryrand_top 2.galleryrand_end with data variable $show""
here it is
template galleryrand_top
<div class='borderwrap' style="display:{$show['div_fc']}" id='fc_rand'>
<div class='maintitle'>
<p class='expand'><a href="javascript:togglecategory('rand',0);"><{E_PLUS}></a></p>
<p><{CAT_IMG}> {$show5['name']}</p>
</div>
</div>
<div class='borderwrap' style="display:{$show['div_fo']}" id='fo_rand'>
<div class='maintitle'>
<p class='expand'><a href="javascript:togglecategory('rand',1);"><{E_MINUS}></a></p>
<p><{CAT_IMG}> {$show['name']}</p>
</div>
<table class='ipbtable' cellspacing='1'>
template galleryrand_end
<tr><td class='catend' colspan='5'><!-- --></td></tr> </table> </div><br />
but nothing show because i 100 sure my skin codes are rong could you please help me to fix this skin issue if possible ?
thanks you




Ten temat jest zablokowany
















