[wordpress插件] Churro丘罗

wordpress 插件 文章 2020-03-23 15:10 469 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

Churro is a plugin that allows developers to easily create pages and functionality, in a style similar to CodeIgniter.

Churro是一个插件,允许开发人员以类似于CodeIgniter的样式轻松创建页面和功能。

By itself, Churro will not add any functionality to your WordPress site.

Churro本身不会向您的WordPress网站添加任何功能。

Tested with WordPress and WordPress MU 2.8.0 ~ 3.0.5

经过WordPress和WordPress MU 2.8.0〜3.0.5的测试

Requires PHP 5. PHP 4 is like 10 years old, you know?

需要PHP5。PHP4已有10年的历史了,

Churro Basics

Churro基础知识

= URLs =

=网址=

Churro requires friendly urls rather than query strings.

Churro需要友好的URL,而不是查询字符串。

Your url will usually be mapped as following: yoursite.com/class/method/variables

您的网址通常将按以下方式映射: yoursite.com/class/method/variables

Controllers

控制器

The controller will be directly mapped to a file and class with the same name.

控制器将直接映射到具有相同名称的文件和类。

For example,
        

例如,
        

yoursite.com/contact

yoursite.com/contact

will look for a file named contact.php in the /churro/ directory.

会在/ churro /目录中查找名为contact.php的文件。

This file should have a class contact that extends Churro.

该文件应具有扩展Churro的类联系人。

Without a defined method, it will default to index.

如果没有定义的方法,它将默认为索引。

All methods accessible through URLs will have ‘Action’ appended to it.

通过网址可访问的所有方法都将附加“操作”。

The following code will provide scaffolding for yoursite.com/contact and yoursite.com/contact/submit

以下代码将为 yoursite.com/contact yoursite.com/contact/submit 提供支架

  <?php

class contact extends Churro {    

班级联系扩展了Churro {    

public function indexAction(){    

公共函数indexAction(){    

}    

}    

public function submitAction(){    

公共功能SubmitAction(){    

}

}

}

}

Models

模型

Churro gives you access to several important WordPress Models through the $this keyword.

Churro使您可以通过 $ this 关键字访问几个重要的WordPress模型。

The $wp, $wpdb, and $wp_query classes, as well as $blog_id in MU are all availble

MU中的 $ wp $ wpdb $ wp_query 类以及MU中的 $ blog_id 均可用

without using the global keyword, eg $this->wpdb.

而不使用全局关键字,例如 $ this-> wpdb

Views

观看次数

Your views belong in your normal theme directory.

您的视图属于您的常规主题目录。

If you are using multiple themes, you can override the direcotry using $this->Theme( 'directory-name' ) any place in the controller.

如果使用多个主题,则可以在控制器中的任何位置使用 $ this-> Theme('directory-name')覆盖目录。

To specify a view to use, $this->View( 'file-name' ).

要指定要使用的视图,请 $ this-> View('file-name')

Seperating logic from views is the most important thing to remember in Churro.

在Churro中,将逻辑与视图分开是最重要的事情。

To set varaibles in your view, use $this->vars->var_name in the controller, and $var_name in your view.

要在视图中设置变量,请在控制器中使用 $ this-> vars-> var_name ,并在视图中使用 $ var_name

Ajax / Javascript

Ajax / Javascript

If you use the excellent jQuery javascript library, Churro will detect ajax requests and automatically return JSON.

如果您使用出色的jQuery javascript库,则Churro将检测ajax请求并自动返回JSON。

Churro defines a constant ISAJAX on each request.

Churro在每个请求上定义一个常量 ISAJAX

With a little planning, it is very easy to create a dynamic application in a way that is totally accessible without javascript.

只需进行一些计划,就可以轻松创建动态应用程序,而无需使用javascript就可以完全访问它。

Learning Churro

学习油条

There is much more functionality in Churro than outlined here.

Churro中的功能比这里概述的要多得多。

As of September 2, 2009, there is no complete, formal, documentation for writing code with Churro.

截至2009年9月2日,尚没有用于使用Churro编写代码的完整,正式的文档。

Stay tuned to Substance Labs for tutorials.

敬请关注物质实验室,以获取教程。

p>

>

安装步骤

    1. Place entire /churro/ directory to the /wp-content/plugins/ directory
    2. 将整个/ churro /目录放置到/ wp-content / plugins /目录中

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Write some code
    6. 写一些代码

下载地址
https://downloads.wordpress.org/plugin/churro.zip
-EOF-

AI助手支持GPT4.0