We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7858
    • 97 Posts
    Hi, strange thing:

    on this website build with MODx CMS http://danchervideo.de I've got a news list (button "weitere nachrichten" on the bottom. The news (in a list with pagination) are loaded via getJSON request.

    But it seems not to work properly in Opera 11.50. It loads several times and then i get empty answer from php script.
    If i clear cache in MODx, it works again for one-two times.

    In all other browsers everything works just fine.

    I really need help.
    Thx!


    var page = '';
    $.getJSON("template/scripts/news.php", {resid: "[[*id]]"}, function(output) {
        $('#news_short_container').html(output.content).show();
        $('#pagination').html(output.pagination).fadeIn();
        $('#pagination').delegate('a.pagenav', 'click', function() {
            var hrefArr = $(this).attr('href').split('/');
                    var page = hrefArr[hrefArr.length-1];
                    $('#news_short_container').fadeOut();
            $.getJSON("template/scripts/news.php", {resid: "[[*id]]", spp: page}, function(output) {
            $('#news_short_container').html(output.content).fadeIn();
            $('#pagination').html(output.pagination).show();
            });
            return false;
        });
    });




    <?php
    require_once '../../config.core.php';
    require_once MODX_CORE_PATH.'model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('web');
    $modx->getService('error','error.modError');
    function limit_words($string, $word_limit)
    {
        $words = explode(" ",$string);
        return implode(" ",array_splice($words,0,$word_limit));
    }
    
    $resid = $_GET['resid'];
    $nowitem = $modx->getObject('modResource',$resid);
    $nowmenuindex = $nowitem->get('menuindex'); //current item menu index
    
    $sortres = $modx->newQuery('modResource',array(
        'parent' => 21,
        'published' => 1,
    ));
    $sortres->sortby('menuindex','ASC');
    
    $news = $modx->getCollection('modResource',$sortres );
    
    $count = count($news); //items count
    
    
    $ipp = 5; //items per page
    
    $currentpage = ceil(($nowmenuindex+1)/$ipp);//current page
    if ($currentpage == 0){
    	$currentpage = 1;
    } 
    
    $countpagesraw = $count/$ipp; //pagination items count / pages count
    $countpages = ceil($countpagesraw); // pagination items count / pages count FLOOR
    $startpage = $_GET['spp'];//selected page
    
    $i = 0;
    
    $index = $nowmenuindex + 1; //menuindex + 1
    $block = ceil($index/$ipp);//page number
    
    if(!empty($startpage)){
    	$startindex = $startpage*$ipp - ($ipp);//starting index page selected
    }
    else{
    	$startindex = $ipp*($block-1);//starting index page not selected
    }
    
    
    foreach ($news as $newsitem) {
    	
    	$loadingindex = $newsitem->get('menuindex');
    	$activelink = ($nowmenuindex == $loadingindex) ? "activelink": "";
    	if ($i < $ipp && $loadingindex >= $startindex){
    	$thisid = $newsitem->get('id');
    	$date = strtotime($newsitem->get('createdon'));
    	$fullcontent = $newsitem->get('introtext');
    	$tv = $modx->getObject('modTemplateVar',array('name'=>'homeNewsImage'));
    	$image = $tv->renderOutput($thisid);
    	$options = "w=45&h=45&zc=1";
        $thumbnail = $modx->runSnippet("phpthumbof",array('input' => $image, 'options' => $options));	
    	
    	$output .= "<a href='".$newsitem->get('alias').".html'>";	
        $output .= "<div class='news_short ".$activelink."'>";
    	$output .= "<div class='date'>";
    	$output .= "<div class='day'>".date('d', $date).$tv."</div><div class='month'>".date('M', $date)."</div><div class='year'>".date('Y', $date)."</div>";
    	$output .= "</div>";
    	$output .= "<div class='news_short_cont'>";
    	$output .= "<div class='clearer'></div>";
        $output .= "<div class='news_short_title'>".$newsitem->get('pagetitle').'</div>';
    	$output .= "<div class='text_image'>";
    	$output .= "<div class='news_short_text'>".limit_words($fullcontent, 15).'...</div>';
    	
    	if(!empty($thumbnail)){
    	$output .= "<div class='news_short_image'><img src='".$thumbnail."'></div>";
    	}
    	$output .= "</div>";
    	$output .= "</div>";
    	$output .= "<div class='clearer'></div>";
    	$output .= "</div></a>";
    		$i++;
    	}
    }
    
    $pagedisplay = 7;//pages to display
    $page = 1;//counter
    $mpage = ceil($pagedisplay/2);//middle page
    $restpages = ceil(($pagedisplay-2)/2)-1;//restpages
    if(!empty($startpage)){
    $cpage = $startpage;//current page
    }
    else{
    $cpage = $currentpage;
    }
    $pagin .= "<div class='selpage'>seite</div>";
    if($countpages <= $pagedisplay){
    	while ($page <= $countpages){
    	$active = ($page == $cpage) ? "pageactive": "";
        $pagin .= '<div><a class="pagenav '.$active.'" href="'.$page.'">'.$page.'</a></div>'; 
        $page++;
    	}
    }
    else{
    	$active = ($cpage == 1) ? "pageactive": "";
    	$pagin .= '<div><a class="pagenav '.$active.'" href="1">1</a></div>'; //first page always 1 	
    	if($cpage <= $mpage){ 
    		$page = 2;
    		while ($page <= ($pagedisplay-1)) {
    			$active = ($page == $cpage) ? "pageactive": "";
    			$pagin .= '<div><a class="pagenav '.$active.'" href="'.$page.'">'.$page.'</a></div>';
    			$page++;
    		}
    	$pagin .= '<div><a class="pagenav" href="'.$countpages.'">'.$countpages.'</a></div>';
    	}
    	if($cpage > $mpage && $cpage < ($countpages - $restpages)){ 
    		$spage = $cpage-$restpages;
    		$page = 1;
    		while ($page <= ($pagedisplay-2)) {
    			$active = ($spage == $cpage) ? "pageactive": "";
    			$pagin .= '<div><a class="pagenav '.$active.'" href="'.$spage.'">'.$spage.'</a></div>';
    			$spage++;
    			$page++;
    		}
    	$pagin .= '<div><a class="pagenav" href="'.$countpages.'">'.$countpages.'</a></div>';
    	}
    	if($cpage >= ($countpages - $restpages) && $cpage != $countpages){
    		$pageback = $countpages-$cpage;	
    		$spage = $cpage-(($pagedisplay-2)-$pageback);
    		while ($page <= ($pagedisplay-2)) {
    			$active = ($spage == $cpage) ? "pageactive": "";
    			$pagin .= '<div><a class="pagenav '.$active.'" href="'.$spage.'">'.$spage.'</a></div>';
    			$spage++;
    			$page++;
    		}
    		$pagin .= '<div><a class="pagenav" href="'.$countpages.'">'.$countpages.'</a></div>';
    	}
    	if($cpage == $countpages){
    		$page = $countpages-$pagedisplay+2;
    		while ($page < $countpages) {
    			$pagin .= '<div><a class="pagenav" href="'.$page.'">'.$page.'</a></div>';
    			$page++;
    		}
    		$pagin .= '<div><a class="pagenav pageactive" href="'.$countpages.'">'.$countpages.'</a></div>';
    	}
    }
    
    
    echo json_encode(array("content" => $output, "pagination" => $pagin ));
    ?>
    [ed. note: dopeless last edited this post 15 years, 1 month ago.]
      • 7858
      • 97 Posts
      Solved

      stupid, the problem was, that I've mistyped in the "container suffix" setting in friendly url settings - .hrml instead of .html... don't know why, but it was causing a problem in Opera