设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 手机 数据 公司
当前位置: 首页 > 运营中心 > 建站资源 > 经验 > 正文

帝国CMS内容点击无限加载思路共享

发布时间:2021-12-17 10:23 所属栏目:19 来源:互联网
导读:帝国CMS无限加载是借鉴别的CMS插件更改的,现在还在制作样式中,完成后会以插件分享给大家. 无限加载常见的原理是利用PHP文件调用数据库信息,在用JS读取PHP信息,最后插入显示到页面. PHP文件代码: ?php require_once(../../e/class/connect.php); //引入数据库
帝国CMS无限加载是借鉴别的CMS插件更改的,现在还在制作样式中,完成后会以插件分享给大家.
 
无限加载常见的原理是利用PHP文件调用数据库信息,在用JS读取PHP信息,最后插入显示到页面.
 
PHP文件代码:
 
<?php
require_once('../../e/class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../e/class/db_sql.php'); //引入数据库操作文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$editor=1; //声明目录层次
 
$last = $_POST['last'];
$amount = $_POST['amount'];
 
$user = array('demo1','demo2','demo3','demo3','demo4');
$sql=$empire->query("select * from ceshi_ecms_news order by id desc limit $last,$amount");
 
while ($row=$empire->fetch($sql)) {
    $addurl="<a href=".$row['titleurl'].">".$row['title']."</a>";
    $sayList[] = array(
        'content'=>$row['username'],
        'author'=>$addurl,
        'url'=>$row['titleurl'],
        'date'=>date('m-d H:i',$row['newstime'])
      );//开源软件:Cuoxin.com
}
echo json_encode($sayList);
 
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量
?>
      
    var methods = {
        init  :   function(options){
            return this.each(function(){
                
                if(options){
                    $.extend(settings, options);
                }
                template = $(this).children(settings.template).wrap('<div/>').parent();
                template.css('display','none')
                $(this).append('<div class="more_loader_spinner">'+settings.spinner_code+'</div>')
                $(this).children(settings.template).remove()    
                target = $(this);
                if(settings.scroll == 'false'){                     
                    $(this).find(settings.trigger).bind('click.more',methods.get_data);
                    $(this).more('get_data');
                }                 
                else{
                    if($(this).height() <= $(this).attr('scrollHeight')){
                        target.more('get_data',settings.amount*2);
                    }
                    $(this).bind('scroll.more',methods.check_scroll);
                }
            })
        },
        check_scroll : function(){
            if((target.scrollTop()+target.height()+parseInt(settings.offset)) >= target.attr('scrollHeight') && lock == false){
                target.more('get_data');
            }
        },
        debug :   function(){
            var debug_string = '';
            $.each(variables, function(k,v){
                debug_string += k+' : '+v+'/n';
            })
            alert(debug_string);
        },      
        remove        : function(){             
            target.children(settings.trigger).unbind('.more');
            target.unbind('.more')
            target.children(settings.trigger).remove();
        },
        add_elements  : function(data){
            //alert('adding elements')
              
            var root = target        
         //   alert(root.attr('id'))
            var counter = 0;
            if(data){
                $(data).each(function(){
                    counter++
                    var t = template                     
                    $.each(this, function(key, value){                           
                        if(t.find('.'+key)) t.find('.'+key).html(value);
                    })          
                    //t.attr('id', 'more_element_'+ (variables.last++))
                    if(settings.scroll == 'true'){
                    //    root.append(t.html())
                    root.children('.more_loader_spinner').before(t.html())   
                    }else{
                    //    alert('...')
                            
                          root.children(settings.trigger).before(t.html())   
 
                    }
 
                    root.children(settings.template+':last').attr('id', 'more_element_'+ ((variables.last++)+1))   
                   
                })
                  
                  
            }             
            else  methods.remove()
            target.children('.more_loader_spinner').css('display','none');
            if(counter < settings.amount) methods.remove()             
 

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读