dseslyh6662605 2017-04-28 10:27
浏览 42

在codeigniter php中动态显示基于页面的页面标题

How to display page titles dynamically based on the pages displayed.

Hi i am having a site developed in codeigniter php but the problem is need to display page titles dynamically based on the pages.These pages titles should be fetched from database.Can anyone have any idea how to do this.

Controller:

public function index()
{

    $config = array();
    $config["base_url"] = base_url('testimonial/index');
    $config['total_rows'] =   $this->testimonial_model->record_count();//here we will count all the data from the table
    $config['per_page'] = 6;//number of data to be shown on single page
    $config['first_link'] = 'First';
    $config['last_link'] = 'Last';
    $this->pagination->initialize($config);
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data["records2"] = $this->testimonial_model->get_all_testimonials($config["per_page"], $page);
    $data['records7'] = $this->index_model->get_all_banners();
    $data["links"] = $this->pagination->create_links();//create the link for pagination
    $data['mainpage'] = "testimonial";
    $this->load->view('templates/template',$data);
}

Model:

function get_all_testimonials($limit, $start)
{
    $this->db->limit($limit, $start);
    $this->db->select('T.*');
    $this->db->from('testimonials AS T');
    $this->db->where(array('T.status'=>1));
    $q = $this->db->get();
    if($q->num_rows()>0)
    {
        return $q->result();
    }
    else 
    {
        return false;
    }
}

View:

<div class="container"> 
<div class="row testimonialpage"> 
<div class="col-md-12 testimonialpage">         
    <div class="col-md-9 testimonials" >    
    <div class="testimonialpagetext">       
    </div>  
    <?php if(isset($records2) && is_array($records2)):?>    
    <?php foreach ($records2 as $r):?>          
    <div class="testimonial1">          
    <div class="testimonialtext1">      
    <?php echo $r->description;?>   
    <ul class="founders">
        <li class="founder"><?php echo $r->client_name;?></li>
        <li class="founder"><?php echo $r->founder;?></li>          
    </ul>
    </div>      
    </div>      
    <?php endforeach ;endif;?>  
    <div class="pagination"><?php echo $links; ?></div> 
    </div>  
    </div>      
    </div> 
  • 写回答

2条回答 默认 最新

  • dongxibo2095 2017-04-28 11:04
    关注

    For Ex:: Your url is www.example.com/controller/register when you get uri segment(2) means you will get (register). based on this you can identify that you are on the register page. now you can find the title for register page from your database.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题