Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: Не работает виджет: Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE)

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Описание: Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE)
МихаилИ
Отправлено: 09 Марта, 2016 - 15:34:04
Post Id


Новичок


Покинул форум
Сообщений всего: 2
Дата рег-ции: Март 2016  


Помог: 0 раз(а)




Помогите, пожалуйста, найти ошибку в коде. Выдает ошибку Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) on line 70. Весь мозг уже поломан, решение не находится. Проблема проявилась при переносе с локального сервера на сервер провайдера. На локальном все работало.

PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP
  3. // =============================== My Carousel widget ======================================
  4. class MY_FredCarouselWidget extends WP_Widget {
  5.     /** constructor */
  6.     function MY_FredCarouselWidget() {
  7.         parent::WP_Widget(false, $name = 'My - FredCarousel'); 
  8.     }
  9.  
  10.     /** @see WP_Widget::widget */
  11.     function widget($args, $instance) {        
  12.         extract( $args );
  13.         $title = apply_filters('widget_title', $instance['title']);
  14.                                 $limit = apply_filters('widget_limit', $instance['limit']);
  15.                                 $cats = apply_filters('widget_cats', $instance['cats']);
  16.                                 $count = apply_filters('widget_count', $instance['count']);
  17.                                 $thumb_w = apply_filters('widget_thumb_w', $instance['thumb_w']);
  18.                                 $thumb_h = apply_filters('widget_thumb_h', $instance['thumb_h']);
  19.                                 $show_type = apply_filters('widget_show_type', $instance['show_type']);
  20.  
  21.  
  22.                                 if( ! $thumb_h =  absint($instance["thumb_h"] ))  $thumb_h=50;                 
  23.                                 if( ! $thumb_w =  absint($instance["thumb_w"] ))  $thumb_w=50;
  24.                                 //if( ! $category = $instance["category"] )  $category='';                     
  25.                                 if( ! $show_type = $instance["show_type"] )  $show_type='post';
  26.  
  27.         ?>
  28.                                 <?PHP echo $before_widget; ?>
  29.                                         <?PHP if ( $title )
  30.                                                                 echo $before_title . $title . $after_title; ?>
  31.                                                        
  32.                                                         <!-- Elastislide Carousel -->
  33.                                                         <div class="list_carousel">
  34.                                             <ul id="foo2">
  35.                                                 <?PHP
  36.                                                 $carouselPosts = new WP_Query();
  37.                                                 echo $cats[1];
  38.                                                 foreach ($cats as $key => $value) {
  39.                                                         echo $key[$value];
  40.                                                 }
  41.                                                 $carouselPosts->query('category_name=offers'.'&showposts='.$count.'&post_type='.$show_type);
  42.                                                 ?>
  43.                                                 <?PHP while ($carouselPosts->have_posts()) : $carouselPosts->the_post(); ?>
  44.                                          
  45.                                                 <li>
  46.                                                     <a href="<?PHP the_permalink() ?>" title="<?PHP the_title(); ?>" >
  47.                                                         <?PHP
  48.                                                                                                 $thumb = get_post_thumbnail_id();
  49.                                                                                                 $img_url = wp_get_attachment_url( $thumb,'sliderimg'); //get img URL
  50.                                                                                                 $image = aq_resize( $img_url, $thumb_w, $thumb_h, true ); //resize & crop img
  51.  
  52.                                                                                                 if(has_post_thumbnail()) { ?>
  53.                                                                                                         <img src="<?PHP echo $image ?>" alt="<?PHP the_title(); ?>" />
  54.                                                                                         <?PHP  {} ?>
  55.                                                     </a>
  56.                                                     <div class="slidertitle">
  57.                                                             <a href="<?PHP the_permalink() ?>" rel="bookmark" title="Permanent Link to <?PHP the_title_attribute(); ?>">
  58.                                                                 <?PHP the_title(); ?>
  59.                                                             </a>
  60.                                                     </div>
  61.                                                     <div class="excerpt">
  62.                                                         <?PHP $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,$limit); ?>
  63.                                                     </div>
  64.  
  65.                                                     <a class="details" href="<?PHP the_permalink() ?>" title="<?PHP the_title(); ?>">details</a>
  66.  
  67.                                                 </li>
  68.                                          
  69.                                                                        
  70.                                                 <?PHP endwhile; ?>
  71.                                             </ul>
  72.                                          
  73.                                                 <div class="caroNav">
  74.                                                     <a class="prev" id="prev2" href="#"><span>prev</span></a>
  75.                                                     <a class="next" id="next2" href="#"><span>next</span></a>
  76.                                             </div>
  77.                                         </div>
  78.  
  79.                                                         <script type="text/javascript">
  80.                                                             jQuery(function($) {
  81.                                                                     $('#foo2').carouFredSel({
  82.                                                                         prev: '#prev2',
  83.                                                                         next: '#next2',
  84.                                                                         scroll : {
  85.                                                                                     items           : 1,
  86.                                                                                     easing          : "linear",
  87.                                                                                     duration        : 500,                        
  88.                                                                                     pauseOnHover    : true
  89.                                                                                 }        
  90.                                                                     });
  91.                                                                 });
  92.                                                         </script>
  93.                                                         <!-- End Elastislide Carousel -->
  94.                        
  95.                        
  96.                                 <?PHP echo $after_widget; ?>
  97.         <?PHP
  98.     }
  99.  
  100.     /** @see WP_Widget::update */
  101.     function update($new_instance, $old_instance) {    
  102.  
  103.         return $new_instance;
  104.     }
  105.  
  106.     /** @see WP_Widget::form */
  107.     function form($instance) {                         
  108.                         $title = esc_attr($instance['title']);
  109.                         $limit = esc_attr($instance['limit']);
  110.                         //$category = esc_attr($instance['category']);
  111.                         $count = esc_attr($instance['count']);
  112.                         $thumb_w = esc_attr($instance['thumb_w']);
  113.                         $thumb_h = esc_attr($instance['thumb_h']);
  114.                         $show_type = esc_attr($instance['show_type']);
  115.  
  116.  
  117.     ?>
  118.  
  119.                 <p><label for="<?PHP echo $this->get_field_id('title'); ?>"><?PHP _e('Title:'); ?> <input class="widefat" id="<?PHP echo $this->get_field_id('title'); ?>" name="<?PHP echo $this->get_field_name('title'); ?>" type="text" value="<?PHP echo $title; ?>" /></label></p>
  120.  
  121.         <p><label for="<?PHP echo $this->get_field_id('limit'); ?>"><?PHP _e('Limit Text:'); ?> <input class="widefat" id="<?PHP echo $this->get_field_id('limit'); ?>" name="<?PHP echo $this->get_field_name('limit'); ?>" type="text" value="<?PHP echo $limit; ?>" /></label></p>
  122.  
  123.  
  124.                 <p><label for="<?PHP echo $this->get_field_id('count'); ?>"><?PHP _e('Number of posts to show:'); ?></label>
  125.         <input id="<?PHP echo $this->get_field_id('count'); ?>" name="<?PHP echo $this->get_field_name('count'); ?>" type="text" value="<?PHP echo $count; ?>" size="3" /></p>
  126.        
  127.     <?PHP
  128.         if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") ) : ?>
  129.        
  130.         <p>        
  131.             <label for="<?PHP echo $this->get_field_id("thumb"); ?>">        
  132.                 <input type="checkbox" class="checkbox" id="<?PHP echo $this->get_field_id("thumb"); ?>" name="<?PHP echo $this->get_field_name("thumb"); ?>"<?PHP checked( (bool) $instance["thumb"], true ); ?> />        
  133.                 <?PHP _e( 'Show post thumbnail' ); ?>        
  134.             </label>        
  135.         </p>
  136.        
  137.         <p>        
  138.             <label>        
  139.                 <?PHP _e('Thumbnail dimensions'); ?>:<br />        
  140.                 <label for="<?PHP echo $this->get_field_id("thumb_w"); ?>">        
  141.                     W: <input class="widefat" style="width:40%;" type="text" id="<?PHP echo $this->get_field_id("thumb_w"); ?>" name="<?PHP echo $this->get_field_name("thumb_w"); ?>" value="<?PHP echo $thumb_w; ?>" />
  142.                 </label>  
  143.                        
  144.                 <label for="<?PHP echo $this->get_field_id("thumb_h"); ?>">        
  145.                     H: <input class="widefat" style="width:40%;" type="text" id="<?PHP echo $this->get_field_id("thumb_h"); ?>" name="<?PHP echo $this->get_field_name("thumb_h"); ?>" value="<?PHP echo $thumb_h; ?>" />
  146.                 </label>        
  147.             </label>        
  148.         </p>
  149.        
  150.     <?PHP endif; ?>    
  151.  
  152.         <p>
  153.             <label for="<?PHP echo $this->get_field_id('cats'); ?>"><?PHP _e('Categories:');?>
  154.                
  155.                                 <!-- <select class="widefat" id="<?PHP echo $this->get_field_id('show_type'); ?>" name="<?PHP echo $this->get_field_name('show_type'); ?>">
  156.                                                 <?PHP
  157.                                                     /*global $wp_post_types;
  158.                                                     foreach($wp_post_types as $k=>$sa) {
  159.                                                         if($sa->exclude_from_search) continue;
  160.                                                         echo '<option value="' . $k . '"' . selected($k,$show_type,true) . '>' . $sa->labels->name . '</option>';*/
  161.                                                     //}
  162.                                                 ?>
  163.                                                 </select> -->
  164.  
  165.                 <?PHP
  166.                    $categories=  get_categories('hide_empty=0');
  167.                      echo "<br/>";
  168.                      foreach ($categories as $cat) {
  169.                          $option='<input type="checkbox" id="'. $this->get_field_id( 'cats' ) .'[]" name="'. $this->get_field_name( 'cats' ) .'[]"';
  170.                             if (is_array($instance['cats'])) {
  171.                                 foreach ($instance['cats'] as $cats) {
  172.                                     if($cats==$cat->term_id) {
  173.                                          $option=$option.' checked="checked"';
  174.                                     }
  175.                                 }
  176.                             }
  177.                             $option .= ' value="'.$cat->term_id.'" />';
  178.        
  179.                             $option .= $cat->cat_name;
  180.                            
  181.                             $option .= '<br />';
  182.                             echo $option;
  183.                          }
  184.                    
  185.                     ?>
  186.             </label>
  187.         </p>
  188.         <p>
  189.             <label for="<?PHP echo $this->get_field_id('show_type'); ?>"><?PHP _e('Show Post Type:');?>
  190.                 <select class="widefat" id="<?PHP echo $this->get_field_id('show_type'); ?>" name="<?PHP echo $this->get_field_name('show_type'); ?>">
  191.                 <?PHP
  192.                     global $wp_post_types;
  193.                     foreach($wp_post_types as $k=>$sa) {
  194.                         if($sa->exclude_from_search) continue;
  195.                         echo '<option value="' . $k . '"' . selected($k,$show_type,true) . '>' . $sa->labels->name . '</option>';
  196.                     }
  197.                 ?>
  198.                 </select>
  199.             </label>
  200.         </p>
  201.        
  202.  
  203.  
  204.                
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.        
  214.       <?PHP
  215.     }
  216.  
  217. } // class Carousel Widget
  218.  
  219.  
  220. ?>
  221.  
 
 Top
andrewkard
Отправлено: 09 Марта, 2016 - 18:12:18
Post Id


Участник


Покинул форум
Сообщений всего: 1372
Дата рег-ции: Нояб. 2014  


Помог: 30 раз(а)




Замените:
PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP while ($carouselPosts->have_posts()) : $carouselPosts->the_post(); ?>
  3. //
  4. <?PHP endwhile; ?>
  5.  


на
PHP:
скопировать код в буфер обмена
  1.  
  2.  <?PHP while ($carouselPosts->have_posts()) { $carouselPosts->the_post(); ?>
  3. //
  4. <?PHP } ?>
  5.  

(Добавление)
Тег <?php пишем строчными
 
 Top
МихаилИ
Отправлено: 09 Марта, 2016 - 18:36:56
Post Id


Новичок


Покинул форум
Сообщений всего: 2
Дата рег-ции: Март 2016  


Помог: 0 раз(а)




ОГРОМНОЕ СПАСИБО!
Этот кусок кода проскочили!
Выявились другие вопросы, буду "копать" дальше...
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« Если скрипт не работает »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB