Sziaztok, újabb érdekes dologba botlottam.
Megoldható az, hogy egy bizonyos widget megjelenjen a sidebarban mindenhol kivéve a főoldalon?
Ha a kódban kellene turkálni, akkor adott a válasz egy IF -fel megoldható. Na de így widgettel? köszi
Persze, a widget kódjában kell módosítani.
Pl így:
if ($wp_query->is_home == 1) return;
És akkor a főoldalon kívül mindehol megjelenik
oh köszi ez jó megoldás lehet.
nextgen-gallery widgetről van szó, akkor azt jelenti, hogy a nggwidget.php-be kellene ezt beletennem?
de hova?, melyik sorba?
nextgen-gallery/nggwidget.php
az ngg_widget_output() funkción belül, mondjuk, az extract($args); után, vagyis a 359. sorba tenném.
Előre bocsátom, hogy nem használok nextgent, és nem próbáltam ki hogy ez így működik-e. De a kód átnézése után, erre jutottam.
köszönöm, az infót, de valami miatt nem megy. Ugyanúgy kint marad a widget a nyitóoldalon is.
most így néz ki a kód a 353-376 között:
global $wpdb;
extract($args);
if ($wp_query->is_home == 1) return;
// We could get this also as parameter
if (!$options)
$options = get_option('ngg_widget');
// get the effect code
$thumbcode = nggallery::get_thumbcode("sidebar_".$number);
$items = $options[$number];
$exclude = $options[$number];
$list = $options[$number];
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE exclude != 1 ");
if ($count < $options[$number])
$options[$number] = $count;
$exclude_list = "";
így gondoltad?
a
global $wpdb;
sort cseréld erre:
global $wpdb, $wp_query;
Ha így sem jó, felteszek egy nextgent és megnézem
tényleg nagyon köszi:) de nem történik semmi. Ugyanúgy működik, de a nyitooldalon IS ott van továbbra is. Sajnos ehhet a részéhez már én nem tudok mit hozzáadni, megköszönöm, ha felteszed, és megnézed
Thx.
Nem voltál egyértelmű, van ugye a widget és van a slideshwo widget…
Én a sima widgetet néztem és erre írtam a megoldást, de neked úgy tűnik a slideshow-t kell eltüntetni.
nggwidget.php 86. sorától így kell kinéznie és jó lesz
global $wp_query;
extract($args);
if ($wp_query->is_home == 1) return;
valami nem OK. Most így néz ki a kód a 73-102 sor között:
/* Slidehow widget control
/**********************************************************/
function widget_ngg_slideshow() {
// Check for the required plugin functions.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
function widget_show_ngg_slideshow($args) {
global $wp_query;
extract($args);
if ($wp_query->is_home == 1) return;
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_nggslideshow');
// These lines generate our output.
echo $before_widget . $before_title . $options . $after_title;
nggSlideshowWidget($options , $options , $options);
echo $after_widget;
}
biztos valamit rosszul csinálok. De egyébként valóban a slideshow widgetről van szó, sorrry.. :)
jajj!
A funkciónév támpontként volt csak benne, másrészt, nem ugyanazt a verziót használjuk. Én a legfrissebbet szedtem le, nálad valami régebbi van.
Csak ennyit tegyél bele:
if ($wp_query->is_home == 1) return;
hm… eddig gondoltam hátha el tudom kerülni azt hogy bevágjam ide egy az egyben az egész php-t, de látom hogy ezt már nem tudom elkerülni.
Kérlek szépen írd ebbe bele, úgy ahogyan ki kell néznie… és szúrd be ide… jelenleg így áll, és így sem jó, pedi érzem higy egy két soron múlik a siker
Köszönöm.
/*
Plugin Name: NextGEN Gallery Widget
Description: Adds a sidebar widget support to your NextGEN Gallery
Author: NextGEN DEV-Team
Version: 1.22
Author URI: http://alexrabe.boelinger.com/
Plugin URI: http://alexrabe.boelinger.com/?page_id=80
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**********************************************************/
/* Slidehow widget function
/**********************************************************/
function nggSlideshowWidget($galleryID,$irWidth,$irHeight) {
// Check for NextGEN Gallery
if ( !function_exists('nggShowSlideshow') )
return;
global $wpdb;
$ngg_options = get_option('ngg_options');
if (empty($irWidth) ) $irWidth = $ngg_options;
if (empty($irHeight)) $irHeight = $ngg_options;
$out .= "n".'';
$out .= "nt".'';
$out .= "nt".'<!--';
$out .= "nt".'//<![CDATA[';
$out .= "ntt".'var sbsl = new SWFObject("'.NGGALLERY_URLPATH.'imagerotator.swf", "ngg_slideshow'.$galleryID.'", "'.$irWidth.'", "'.$irHeight.'", "7", "#'.$ngg_options.'");';
$out .= "ntt".'sbsl.addParam("wmode", "opaque");';
$out .= "ntt".'sbsl.addVariable("file", "'.NGGALLERY_URLPATH.'nggextractXML.php?gid='.$galleryID.'");';
$out .= "ntt".'sbsl.addVariable("linkfromdisplay", "false");';
$out .= "ntt".'sbsl.addVariable("shownavigation", "false");';
// default value changed in 3.15 : linkfromdisplay, shownavigation, showicons
if (!$ngg_options) $out .= "ntt".'sbsl.addVariable("shuffle", "false");';
if (!$ngg_options) $out .= "ntt".'sbsl.addVariable("showicons", "false");';
if ($ngg_options) $out .= "ntt".'sbsl.addVariable("showicons", "true");';
$out .= "ntt".'sbsl.addVariable("overstretch", "'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("backcolor", "0x'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("frontcolor", "0x'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("lightcolor", "0x'.$ngg_options.'");';
if (!empty($ngg_options)) $out .= "ntt".'sbsl.addVariable("screencolor", "0x'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("rotatetime", "'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("transition", "'.$ngg_options.'");';
$out .= "ntt".'sbsl.addVariable("width", "'.$irWidth.'");';
$out .= "ntt".'sbsl.addVariable("height", "'.$irHeight.'");';
$out .= "ntt".'sbsl.write("ngg_widget_slideshow'.$galleryID.'");';
$out .= "nt".'//]]>';
$out .= "nt".'-->';
$out .= "nt".'';
echo $out;
}
/**********************************************************/
/* Slidehow widget control
/**********************************************************/
function widget_ngg_slideshow() {
// Check for the required plugin functions.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
function widget_show_ngg_slideshow($args) {
global $wp_query;
extract($args);
if ($wp_query->is_home == 1) return;
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_nggslideshow');
// These lines generate our output.
echo $before_widget . $before_title . $options . $after_title;
nggSlideshowWidget($options , $options , $options);
echo $after_widget;
}
// Admin section
function widget_control_ngg_slideshow() {
global $wpdb;
$options = get_option('widget_nggslideshow');
if ( !is_array($options) )
$options = array('title'=>'Slideshow', 'galleryid'=>'0','height'=>'120','width'=>'160',);
if ( $_POST ) {
$options = strip_tags(stripslashes($_POST));
$options = $_POST;
$options = $_POST;
$options = $_POST;
update_option('widget_nggslideshow', $options);
}
$title = htmlspecialchars($options, ENT_QUOTES);
$height = $options;
$width = $options;
// The Box content
echo '[align=right:2j2lyw77]' . __('Title:', 'nggallery') . ' [/align:2j2lyw77]';
echo '[align=right:2j2lyw77]' . __('Select Gallery:', 'nggallery'). ' ';
echo '';
echo '<option value="0" ';
if ($table->gid == $options['galleryid']) echo "selected='selected' ";
echo '>'.__('All images', 'nggallery').''."nt";
$tables = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY 'name' ASC ");
if($tables) {
foreach($tables as $table) {
echo 'gid.'" ';
if ($table->gid == $options['galleryid']) echo "selected='selected' ";
echo '>'.$table->name.''."nt";
}
}
echo '[/align:2j2lyw77]';
echo '[align=right:2j2lyw77]' . __('Height:', 'nggallery') . ' [/align:2j2lyw77]';
echo '[align=right:2j2lyw77]' . __('Width:', 'nggallery') . ' [/align:2j2lyw77]';
echo '';
}
register_sidebar_widget(array('NextGEN Slideshow', 'widgets'), 'widget_show_ngg_slideshow');
register_widget_control(array('NextGEN Slideshow', 'widgets'), 'widget_control_ngg_slideshow', 300, 200);
}
add_action('widgets_init', 'widget_ngg_slideshow');
/**
* nggWidget - The widget control for NextGEN Gallery ( require WP2.2 or hiogher)
*
* @package NextGEN Gallery
* @author Alex Rabe
* @copyright 2008
* @version 1.00
* @access public
*/
class nggWidget {
function nggWidget() {
// Run our code later in case this loads prior to any required plugins.
add_action('widgets_init', array(&$this, 'ngg_widget_register'));
}
function ngg_widget_register() {
if ( !class_exists('nggallery') )
return;
// For K2 Sidebar manager we do different
if(class_exists('K2SBM') && K2_USING_SBM ) {
K2SBM::register_sidebar_module('NextGEN Gallery', 'ngg_sbm_widget_output', 'sb-ngg-widget');
K2SBM::register_sidebar_module_control('NextGEN Gallery', 'ngg_sbm_widget_control');
} else {
// test for widget plugin > 2.2
if ( !function_exists('wp_register_sidebar_widget') )
return;
$options = get_option('ngg_widget');
$number = $options;
if ( $number < 1 ) $number = 1;
if ( $number > 9 ) $number = 9;
$dims = array('width' => 410, 'height' => 300);
$class = array('classname' => 'ngg_widget');
for ($i = 1; $i <= 9; $i++) {
$name = sprintf(__('NextGEN Gallery %d','nggallery'), $i);
$id = "ngg-widget-$i"; // Never never never translate an id
wp_register_sidebar_widget($id, $name, $i <= $number ? array(&$this, 'ngg_widget_output') : /* unregister */ '', $class, $i);
wp_register_widget_control($id, $name, $i <= $number ? array(&$this, 'ngg_widget_control') : /* unregister */ '', $dims, $i);
}
add_action('sidebar_admin_setup', array(&$this, 'ngg_widget_admin_setup'));
add_action('sidebar_admin_page', array(&$this, 'ngg_widget_admin_page'));
}
}
function ngg_widget_admin_page() {
$options = get_option('ngg_widget');
?>
<?php for ( $i = 1; $i < 10; ++$i ) echo "$i"; ?>
<input type="submit" name="ngg-number-submit" id="ngg-number-submit" value="" />
<?php
}
function ngg_widget_admin_setup() {
$options = $newoptions = get_option('ngg_widget');
if ( isset($_POST) ) {
$number = (int) $_POST;
if ( $number > 9 ) $number = 9;
if ( $number < 1 ) $number = 1;
$newoptions = $number;
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('ngg_widget', $options);
$this->ngg_widget_register($options);
}
}
function ngg_widget_control($number, $is_K2_SMB = false) {
$options = $newoptions = get_option('ngg_widget');
// These post parameter are expected
$params = array('title','items','show','type','width','height','exclude','list');
// get the parameter from POST
if ( $_POST["ngg-submit-$number"] ) {
foreach ($params as $parameter) {
$value = trim(strip_tags(stripslashes($_POST["ngg-$parameter-$number"])));
// remove all non numeric values from the list
if ($parameter == 'list') {
$numeric_ids = array();
$ids = explode(',',$value);
if (is_array($ids)) {
foreach ($ids as $id) {
$id = trim($id);
if (is_numeric($id))
$numeric_ids[] = $id;
}
$value = implode(',', $numeric_ids);
}
}
$newoptions[$number][$parameter] = $value;
}
}
// save the parameter
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('ngg_widget', $options);
}
// Init parameters check
if (empty($options[$number]))
$options[$number] = array('title'=>'Gallery', 'items'=>4,'show'=>'thumbnail' ,'type'=>'random','width'=>75, 'height'=>50, 'exclude'=>'all');
foreach ($params as $parameter) {
$post[$parameter] = attribute_escape($options[$number][$parameter]);
}
// get the parameter from options -> POST
$items = (int) $options[$number];
if ( empty($items) || $items < 1 ) $items = 10;
// Here comes the form (Not for K2 Style)
if (!$is_K2_SMB) {
?>
div .ngg-widget p {
text-align:left;
}
div .ngg-widget label {
float:left;
margin:0.4em 0px;
padding:0pt 10px;
text-align:right;
width:120px;
}
<?php
}
?>
<label for="ngg-title-">
<input style="width: 250px;" id="ngg-title-" name="ngg-title-" type="text" value="" />
<label for="ngg-items-">
<select id="ngg-items-" name="ngg-items-">
<?php for ( $i = 1; $i <= 10; ++$i ) echo "$i"; ?>
<select id="ngg-show-" name="ngg-show-" >
<option value="thumbnail">
<option value="orginal">
<label for="ngg-type-">
<input name="ngg-type-" type="radio" value="random" />
<input name="ngg-type-" type="radio" value="recent" />
<label for="ngg-width-">
<input style="width: 50px;" id="ngg-width-" name="ngg-width-" type="text" value="" /> x
<input style="width: 50px;" id="ngg-height-" name="ngg-height-" type="text" value="" /> (px)
<label for="ngg-exclude-">
<select id="ngg-exclude-" name="ngg-exclude-">
<option value="all" >
<option value="denied" >
<option value="allow" >
<label for="ngg-list-">
<input style="width: 250px;" id="ngg-list-" name="ngg-list-" type="text" value="" />
<input type="hidden" id="ngg-submit-" name="ngg-submit-" value="1" />
<?php
}
function ngg_widget_output($args, $number = 1 , $options = false) {
global $wpdb;
extract($args);
// We could get this also as parameter
if (!$options)
$options = get_option('ngg_widget');
// get the effect code
$thumbcode = nggallery::get_thumbcode("sidebar_".$number);
$items = $options[$number];
$exclude = $options[$number];
$list = $options[$number];
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE exclude != 1 ");
if ($count < $options[$number])
$options[$number] = $count;
$exclude_list = "";
// THX to Kay Germer for the idea & addon code
if ( (!empty($list)) && ($exclude != "all") ) {
$list = explode(',',$list);
// Prepare for SQL
$list = "'" . implode("', '", $list) . "'";
if ($exclude == "denied")
$exclude_list = "AND NOT galleryid IN ($list)";
if ($exclude == "allow")
$exclude_list = "AND galleryid IN ($list)";
}
if ( $options[$number] == "random" )
$imageList = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE exclude != 1 $exclude_list ORDER by rand() limit $items");
else
$imageList = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE exclude != 1 $exclude_list ORDER by pid DESC limit 0,$items");
echo $before_widget . $before_title . $options[$number] . $after_title;
echo "n".'
if (is_array($imageList)){
foreach($imageList as $image) {
$out = '[url url="'.nggallery::get_image_url($image->pid)."]description).'" '.$thumbcode.'>';
if ( $options[$number] == "orginal" )
$out .= '[img]'.NGGALLERY_URLPATH.[/img]pid.'&width='.$options[$number].'&height='.$options[$number].'" title="'.$image->alttext.'" alt="'.$image->alttext.'" />';
else
$out .= '[img]'.nggallery::get_thumbnail_url($image->pid).[/img]alttext.'" alt="'.$image->alttext.'" />';
echo $out . '[/url]'."n";
}
}
echo '
echo $after_widget;
}
}
// let's show it
$nggWidget = new nggWidget;
/**
* ngg_sbm_widget_control()
* ONLY required for K2 Theme (tested with K2 RC4)
*
* @return return widget admin
*/
function ngg_sbm_widget_control() {
if ( !function_exists('checked') ) {
function checked( $checked, $current) {
if ( $checked == $current)
echo ' checked="checked"';
}
}
$number = 1;
// Check for Module id
if(isset($_POST))
$number = $_POST;
nggWidget::ngg_widget_control($number, true);
}
/**
* ngg_sbm_widget_output($args)
* ONLY required for K2 Theme
*
* @return widget content
*/
function ngg_sbm_widget_output($args) {
global $k2sbm_current_module;
$number = $k2sbm_current_module->id;
nggWidget::ngg_widget_output($args, $number , false);
}
/**
* nggDisplayRandomImages($number,$width,$height,$exclude,$list)
* Function for templates without widget support
*
* @return echo the widget content
*/
function nggDisplayRandomImages($number, $width = "75", $height = "50", $exclude = "all", $list = "") {
$options[1] = array('title'=>'',
'items'=>$number,
'show'=>'thumbnail' ,
'type'=>'random',
'width'=>$width,
'height'=>$height,
'exclude'=>'all',
'list'=>$list );
nggWidget::ngg_widget_output($args = array(), 1, $options);
}
/**
* nggDisplayRecentImages($number,$width,$height,$exclude,$list)
* Function for templates without widget support
*
* @return echo the widget content
*/
function nggDisplayRecentImages($number, $width = "75", $height = "50", $exclude = "all", $list = "") {
$options[1] = array('title'=>'',
'items'=>$number,
'show'=>'thumbnail' ,
'type'=>'recent',
'width'=>$width,
'height'=>$height,
'exclude'=>'all',
'list'=>$list );
nggWidget::ngg_widget_output($args = array(), 1, $options);
}
?>
leírtam az előbb…
global $wp_query;
extract($args);
if ($wp_query->is_home == 1) return;
ezt a részt cseréld erre:
if ($wp_query->is_home == 1) return;
Nem akarok full amatőrnek tűnni, de én ezt megcsináltam, és az egész WP-m lehalt. Konkréten, white blank page.
Szóval visszatettem az eredetit.
Nálad a fenti működik? WP 2.5.1 fut még az oldal alatt.
Összecsomagoltam a működő kódot.
(Ez a legfrissebb 0.98 as NextGen kódja, megpatchelve a kért dologgal)
http://djz.hu/files/nextgen-gallery-0.98-patched.zip
nekem azt írja hogy hibás a csomagolt file. nem tudom kitömöríteni.
Tényleg köszönöm a fáradozásodat, tök jó, ,meg nagyon szeretném használni, de nem birom megnyitni se a becsomagolt fájlt… ránézel?
újra raktam, próbáld most
hm. Nálam nem működik. a slideshow widget ugyanúgy kint van a nyitóoldalon is. Érdekes… Nálad működik?
Nálam működik.
ok. a gallery verzió biztos hogy ugyanaz. hisz azt használom amit Te küldtél. A WP? nálad 2.6? nálam még 2.5.1.
Ez lehet az eltérés oka?