表达式引擎控制器 [英] Expression Engine Controllers

查看:114
本文介绍了表达式引擎控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表达式引擎中建立我的第一个网站,我想知道如何在EE中使用自定义控制器,就像我在Codeigniter中,或什么是EE等效的。

解决方案

控制器是应用程序的核心,因为它们决定了HTTP请求的处理方式。



- 知道,不出意料地宽松模仿一个CodeIgniter应用程序—毕竟,EE 是建立在CI上的。



例如,考虑这个URI: example.com/index。 php / blog




  • CodeIgniter将尝试查找名为<$ c的

    < / c>< / c>< / li>之间加载 继续这个例子,URI的第二段确定控制器中的哪个函数被调用(对于CodeIgniter)或加载哪个模板(对于ExpressionEngine)。



    构建相同的URI: example.com/index.php/blog/entry




    • CodeIgniter会尝试找到名为 blog.php 的控制器并加载它。

    • ExpressionEngine会尝试找到名为 blog 模板组并加载名为模板 $ c>。



    从第三个或更多URL段开始,CodeIgniter和ExpressionEngine开始采用不同的方法。



    虽然CodeIgniter和ExpressionEngine之间有许多相似之处,但在a非常低级的


    CodeIgniter允许您构建 Web Apps

    Im building my first site in Expression Engine, I was wondering how to use custom controllers in EE, like I would in Codeigniter, or what is the EE equivalent?

    解决方案

    Controllers are the heart of your application, as they determine how HTTP requests should be handled.

    As you're probably well-aware, a CodeIgniter Controller is simply a class file that is named in a way that can be associated with a URI.

    <?php
        class Blog extends CI_Controller {
    
            public function index() {
                echo 'Hello World!';
            }
        }
    ?>
    

    The ExpressionEngine equivalent are template groups and templates, and are managed from within the Control Panel's Template Manager.

    Since EE's template groups and templates can be named anything you want, the URL structure unsurprisingly loosely mimics a CodeIgniter app — after all, EE is built on CI.

    For example, consider this URI: example.com/index.php/blog

    • CodeIgniter would attempt to find a controller named blog.php and load it.
    • ExpressionEngine would attempt to find the template group named blog and load the template named index.

    Continuing with this example, the second segment of the URI determines which function in the controller gets called (for CodeIgniter) or which template gets loaded (for ExpressionEngine).

    Building off the same URI: example.com/index.php/blog/entry

    • CodeIgniter would attempt to find a controller named blog.php and load it.
    • ExpressionEngine would attempt to find the template group named blog and load the template named entry.

    Starting with the third and beyond URL segments is where CodeIgniter and ExpressionEngine start to take different approaches. (A full explanation of their differences is beyond the scope of this answer).

    While there are many similarities between CodeIgniter and ExpressionEngine, at a very low-level, CodeIgniter lets you build Web Apps while ExpressionEngine lets you build Web Sites.

    这篇关于表达式引擎控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆