网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 内容管理demo之route controllers-CI(codeigniter)PHP框架
内容
    学习codeigniter几天后,根据前面学习的做了一个简单的demo,内容管理,很简单,顺便把前面的复习一下 ,本文是route路径和controllers 内容
    route路径内容
    $route['news'] = 'news/index';
    $route['news/(:num)'] = 'news/index/$1';
    $route['news/(:any)'] = 'news/$1';
    controllers 的内容
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class News extends CI_Controller {
    public function __construct(){
    parent::__construct();
    $this->load->model('news_model');
    }
    public function index($pn=1)
    {
    $data['news']=$this->news_model->get_news($pn);
    $data['title'] = '新闻列表';
    $this->load->view('news/index.html', $data);
    }
    public function show($id){
    }
    public function add(){
    $this->load->view('news/add.html');
    }
    public function addaction(){//这里采用的是 定义的{}模板符
    $this->load->library('parser');
    if($this->news_model->addaction()){
    $data['message']="添加成功!";
    }else{
    $data['message'] ="添加失败" ;
    }
    $this->parser->parse("message.html",$data);
    }
    public function change($id){
    $data = $this->news_model->get_news_id($id);
    if($data){
    $this->load->view('news/change.html',$data);
    }else{
    $this->load->view('message.html','没有该新闻或者参数错误!');
    }
    }
    public function changeaction($id){
    $this->load->library('parser');
    if($this->news_model->changeaction($id)){
    $data['message'] ='修改成功!';
    }else{
    $data['message'] ='修改失败!';
    }
    $this->parser->parse("message.html",$data);
    // redirect('/login/form/', 'refresh');
    }
    }
    这里是两个模块内容。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/22 14:42:11