在codeigniter视图中的主要内容之前加载侧栏内容?

时间:2014-12-23 09:37:08

标签: jquery codeigniter

您好我从不同的服务器获取新闻并在我的网站上显示,目前首先加载新闻内容,然后在每次刷新页面后加载右侧栏。我想制作首先我的页眉,页脚,侧栏(类=" span3侧栏侧栏右)加载然后我的新闻被加载

我的观看文件

<div id="content">
  <div class="container">
    <div class="row-fluid">
      <h2 class="title-divider"><?php echo $page_heading; ?></h2>
    </div>
    <div class="row"> 
        <script> function myfunction(){ </script>
      <!--Blog Roll Content-->
      <div class="span9 blog-roll blog-list"> 
        <?php if(!empty($newsArray)) { foreach($newsArray as $result){ ?>
        <!-- Blog post -->
        <div class="media row-fluid">
          <div class="span1 hidden-phone"> 
            <!-- Date desktop -->
            <div class="date-wrapper"> <span class="date-m"><?php echo $result['monthName']; ?></span> <span class="date-d"><?php echo $result['day']; ?></span> <span class="date-y"><?php echo $result['year']; ?></span></div>
          </div>
          <div class="span11">
            <div class="media-body">
              <h4 class="title media-heading"><a href="<?php echo base_url('news/detail/'.$result['ID']); ?>"><?php echo $result['TTL']; ?></a></h4>
              <div class="tag"></div>
              <ul class="inline meta muted">
                <li><i class="icon-user"></i><?php echo $result['SRC']; ?></li>
                <!-- Meta details mobile -->
                <li><span class="visible-phone"><i class="icon-calendar"></i> <span class="visible-desktop">Created:</span><?php echo $result['day_letter']; echo ' '; echo $result['day']; ?><sup><?php echo $result['daySup']; ?></sup> <?php echo $result['monthName']; echo ' '; echo $result['year']; ?></span></li>
              </ul>
              <p><?php if(!empty($result['CNTNT']))echo $result['CNTNT'].' ...'; ?></p>
              <ul class="inline links">
                <li><a href="<?php echo base_url('news/detail/'.$result['ID']); ?>" class="btn btn-mini"><i class="icon-circle-arrow-right"></i> Read more</a></li>
              </ul>
            </div>
          </div>
        </div>
        <?php }?>
        <div class="pagination pagination-centered">
         <?php if(isset($links)){echo $links;} ?>
        </div>
        <?php  }else { ?>
                    <div class="alert alert-error">
                        <h4>No News Found!</h4>
                    </div>  
            <?php } ?> 
     </div>
      <!--Sidebar-->
      <div class="span3 sidebar sidebar-right">
                  <?php 
            $this->load->view('news/news_sidebar');
            ?>
      </div>
    </div>
  </div>
  <!--.container--> 
</div>
<!--#content-->

1 个答案:

答案 0 :(得分:0)

您应该创建一个不同的函数来获取控制器中的新闻,并在文档就绪时通过ajax调用它,并在从该控制器返回数据时将视图附加到页面。