1

我有从数据库获取所有帖子的页面,我将使用 codeigniter 的分页类。

但我需要使用 facebook 技术来发布更多帖子,我该怎么做。

我的控制器:-

  public function index($page=1) {

        $options = new Option();
        $options->get();
        $oppArray = array();
        foreach($options as $opt){
            $oppArray[$opt->name]= $opt->value;
        }
        $this->data['options'] = $oppArray;

        //if($this->session->userdata('id'))
        if(isset($_SESSION['user_id']) || !empty($_SESSION['user_id']))
        {
            $this->template->set_layout('default');
            $this->template->build('home_view',$this->data);
        }
        else{
            $this->template->set_layout('reg');
            $data['title']= 'الرئيسية || تسجيل الدخول او تسجيل جديد بالموقع';
            $this->template->build('registration_view',$this->data);
        }

/************************************** Post *******************************************************************/

        $this->load->model('blog');

        if(isset($_POST['post']) && (!empty($_POST['post']) || strlen($_FILES['inputUpProfile']['name']) > 0) ){
        if(strlen($_FILES['inputUpProfile']['name']) > 0) 
        {
        $pic = $this->do_upload('inputUpProfile');

        if ($this->input->post('post') == ''){$type="image";} else {$type="image-with-text";}
        }

        else {$pic = ""; $type = "text"; }

            $result = $this->blog->addPost($_SESSION['user_id'], $type  , $this->input->post('post'),$pic);
        }
        if(isset($_SESSION['user_id']) || !empty($_SESSION['user_id'])){

        $config['base_url'] = site_url("./home/index");
        $config['total_rows'] = $this->blog->countPosts($_SESSION['user_id']);
        $config['per_page'] = 10;
        $config['uri_segment'] = 3;
        $config['num_links'] = 1;
        $config['use_page_numbers']= True;
        $config['display_pages'] = True; 
        $this->pagination->initialize($config);

        $this->data['blog'] =  $this->blog->getPosts($_SESSION['user_id'], $config['per_page'] , ($page-1)*$config['per_page']); 
        $this->template->build("home_view" , $this->data);      
        }
        else
        {
        $this->template->build('registration_view',$this->data);
        }

    }

观点是:-

<div id="inner-page-home">

<div class="boxx" id="doctor">
<div id="doc-title">
    <h1>مـــاذا تعمل الان</h1>
    <a href="#">عرض الكل</a>
</div>

<div id="massge" style="float:right">
<form method="post" action="<?php echo site_url('home')?>" enctype="multipart/form-data">
<div class="upimgstatus">

</div>
<div class="textstatus">
<input id="inputUpProfile" name="inputUpProfile" class="inputUpProfile hidefile" type="file" />
<input type="button" id="PicUpProfile" class="sentpic" value="اضافة صورة">

<input name="post" type="text" id="text" placeholder="اكتب رسالتك هنا ...">
<input type="submit" id="sent" value="إرسال"> 
</div>
</form>
</div>

<div style="clear: both"></div>

<ol class="timeline clear">
  <li class="spine">

  </li>

  <?php 
  $counter=0;
  foreach ($blog as $row) { 
  if($counter % 2 == 0){$class= "right";} else $class="left";
  ?>
  <!-- li class="<? //$class ?>" -->
  <li class="right" id="post_row<?php echo $row->ev_id; ?>">
    <i class="pointer"></i>
    <div class="unit">
      <!-- Story -->
      <div class="storyUnit">
        <div class="imageUnit">
        <? if (empty($row->pic)) { ?>
          <a href="#"><img width="32" height="32" alt="" src="images/nopic.png"></a>
          <? } else  { ?>
          <a href="#"><img width="32" height="32" alt="" src="uploads/<?php echo $row->pic; ?>"></a>
          <? } ?>
          <? if ($row->ev_user_id == $_SESSION['user_id']){ ?>
          <div id="delpost" style="float:left"><a href="#" id="deletepost" onClick="delete_post('<?=$row->ev_id;?>'); return false;">X</a></div>
          <? } ?>
          <div class="imageUnit-content">
            <h4><a href="./myaccount/profile/<?php echo $row->id; ?>"><?php echo $row->fullname; ?></a></h4>
            <p><?php echo $row->ev_date ?></p>
          </div>

        </div>

        <p><?php echo $row->ev_text; ?></p>
        <? if (!empty($row->ev_pic)) { ?>
        <p><img src="uploads/<?php echo $row->ev_pic ?>" width="250" height="250"</p>
        <? } ?>
      </div>
      <!-- / Story -->

     <!-- Units -->
      <ol class="storyActions" id="storyActions<?php echo $row->ev_id; ?>">
<?
$selectComment = mysql_query("select * from comment,users where 
comment.co_postid = '".$row->ev_id."'
and comment.co_userid = users.id order by co_date ");
while($rows=mysql_fetch_array($selectComment)){
?>
            <div id="resultcomment<?php echo $row->ev_id; ?>"></div>
      <div id="resultcomment" style="border-top:1px solid #fff;">
      <a href="./myaccount/profile/<?php echo $rows['id']; ?>">
      <img src="uploads/<?=$rows["pic"];?>" width="32" height="32" class="rightc" />
      </a>
      <b><a href="./myaccount/profile/<?php echo $rows['id']; ?>"><?=$rows["fullname"]; ?></a></b>
      <span>&nbsp;&nbsp;</span>
      <span><?=$rows["co_comment"]; ?></span>
      <br />
      <span class="commentdate"><?=$rows["co_date"]; ?></span></br></div>

<? } ?>      

      <form action="" method="post" accept-charset="utf-8">
       <input type="text" class="commentwall" id="comment<?php echo $row->ev_id; ?>" name="comment<?php echo $row->ev_id; ?>" size="41" />
       <input type="hidden" id="postid<?php echo $row->ev_id; ?>" name="postid<?php echo $row->ev_id; ?>" size="41" value="<?php echo $row->ev_id; ?>" />
       <button type="button" id="submit" onclick="add_comment_wall(<?php echo $row->ev_id; ?>)">ارسل</button>
       </form>

      </ol>
      <!-- / Units -->

    </div>
  </li>
   <?php $counter++; } ?>
   <div class="clear"></div>
           <div class="paginate">
            <ul>
                <?=$this->pagination->create_links(); ?>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
</ol>



</div>

</div>

<script type="text/javascript">


            function add_comment_wall($id) {

                //get input data as a array
                var post_data = {
                    'comment': $("#comment"+$id+"").val(),
                    'postid': $("#postid"+$id+"").val()
                     };

                $.ajax({
                    type: "POST",
                    url: "<?php echo base_url(); ?>home/insertCommentWall",
                    data: post_data,
                    success: function(comment) {
                        // return success message to the id='result' position
                        $("#storyActions"+$id+"").append(comment);
                         $("#comment"+$id+"").val("");
                    }
                });



        }
    </script>

所以,当打开这个视图时,它显示 10 条记录,而我不会在向下滚动浏览器时打开 10 到 20 条记录

4

0 回答 0