onethink 插件模板定位
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +---------------------------------------------------------------------- namespace Home\Controller;
use Think\Controller; /**
* 扩展控制器
* 用于调度各个扩展的URL访问需求
*/
class AddonsController extends Controller{ protected $addons = null; public function execute($_addons = null, $_controller = null, $_action = null){
if(C('URL_CASE_INSENSITIVE')){
$_addons = ucfirst(parse_name($_addons, 1));
$_controller = parse_name($_controller,1);
} if(!empty($_addons) && !empty($_controller) && !empty($_action)){
$Addons = A("Addons://{$_addons}/{$_controller}")->$_action();
} else {
$this->error('没有指定插件名称,控制器或操作!');
}
} protected function display($templateFile = '', $charset = '', $contentType = '', $content = '', $prefix = '') {
$templateFile = $this->getAddonTemplate ( $templateFile );
$this->view->display ( $templateFile, $charset, $contentType, $content, $prefix );
}
function getAddonTemplate($templateFile = '') {
if (file_exists ( $templateFile )) {
return $templateFile;
}
//dump ( $templateFile );
$oldFile = $templateFile;
if (empty ( $templateFile )) {
$templateFile = T ( 'Addons://' . _ADDONS . '@' . _CONTROLLER . '/' . _ACTION );
} elseif (stripos ( $templateFile, '/Addons/' ) === false && stripos ( $templateFile, THINK_PATH ) === false) {
if (stripos ( $templateFile, '/' ) === false) { // 如index
$templateFile = T ( 'Addons://' . _ADDONS . '@' . _CONTROLLER . '/' . $templateFile );
} elseif (stripos ( $templateFile, '@' ) === false) { // // 如 UserCenter/index
$templateFile = T ( 'Addons://' . _ADDONS . '@' . $templateFile );
}
} if (stripos ( $templateFile, '/Addons/' ) !== false && ! file_exists ( $templateFile )) {
$templateFile = ! empty ( $oldFile ) && stripos ( $oldFile, '/' ) === false ? $oldFile : _ACTION;
}
// dump ( $templateFile );//exit;
return $templateFile;
} }
上面是定位源码,重写了display方法
下面是使用方法
<?php namespace Addons\Hello\Controller;
use Home\Controller\AddonsController; class HelloController extends AddonsController{
public function replyText(){
$this->display('replyText');
}
}
通过链接访问插件
<a class="item" href="{:addons_url('Hello://Hello/replyText')}">自定义菜单</a>
onethink 插件模板定位的更多相关文章
- 使用 WordPress 插件模板开发高质量插件
WordPress 插件样板是标准化的,有组织的,面向对象的基础,用于构建高品质的 WordPress 插件.样板遵循编码标准和文件标准,所以你不必自己学习这些,根据注释编写代码即可. 官方网站 ...
- VBA Editor Addins --> VBE插件模板开发众筹
https://www.cnblogs.com/Charltsing/p/VBEAddins.html QQ:564955427 8月8日测试版功能说明 1.VBE菜单的创建 2.toolwindow ...
- javascript&&jquery编写插件模板
javascrpt插件编写模板 这里不分享如何编写插件,只留一个框架模板,使用面向对象的形式进行编写,方便管理 ;(function(window,document){ function FnName ...
- BeatSaber节奏光剑插件开发官方教程1-创建一个插件模板
原文:https://wiki.assistant.moe/modding/intro 一.简介 Beat Saber 开发环境:unity2018.C#..NET framework 4.6. 此教 ...
- cordova使用cordova-plugin-baidumaplocation插件获取定位
原文:cordova使用cordova-plugin-baidumaplocation插件获取定位 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/m ...
- Jenkins Email Extension插件模板
Jenkins Email Extension插件模板 <!DOCTYPE html> <html> <head> <meta charset="U ...
- Ztree插件,定位节点时(focus)不能进入可视区域BUG解决方案
相关插件版本: jquery.ztree.exedit-3.4.js jquery.ztree.all-3.4.js jquery-1.8.0.js function onAsyncSuccess(e ...
- jQuery 插件模板
1.为每一个DOM对象创建一个插件对象 模板定义: (function($) { $.pluginName = function(element, options) { var defaults = ...
- 我最喜欢的jQuery插件模板
我使用jQuery已经有相当长的时间了,并且我会常常为它写一些插件(plugin).我尝试过用不同的方式去写,现在这个模板是我最喜欢的: 1 2 3 4 5 6 7 8 9 10 11 12 13 1 ...
随机推荐
- hadoop 集群常见错误解决办法
hadoop 集群常见错误解决办法 hadoop 集群常见错误解决办法: (一)启动Hadoop集群时易出现的错误: 1. 错误现象:Java.NET.NoRouteToHostException ...
- 2018宁夏邀请赛L Continuous Intervals
题目链接:https://nanti.jisuanke.com/t/28412 题意: 给出n个数的序列.问序列中有多少个区间满足,排序完之后任意两个相邻的数之差不大于1. 题解: 用max表示区间最 ...
- 【CF MEMSQL 3.0 D. Third Month Insanity】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- CentOS 7, Attempting to create directory /root/perl5
By francis_hao Apr 10,2017 在使用CentOS 7的时候,首次登陆会出现新建一个perl5文件夹的提示,删除该文件后,之后登陆还是会出现该提示并新建了perl5文件夹. ...
- taotao单点登录的用户Controller、service(注册、登录、验证是否登录方法)
接口文档: 1.1. 注册接口 1.1.1. 检查数据是否可用 请求方法 GET URL http://sso.taotao.com/user/check/{param}/{type} 参数说明 格式 ...
- 【BZOJ5005】乒乓游戏 [线段树][并查集]
乒乓游戏 Time Limit: 10 Sec Memory Limit: 256 MB Description Input Output Sample Input 5 1 1 5 1 5 11 2 ...
- 【BZOJ1146】【CTSC2008】网络管理 [整体二分]
网络管理 Time Limit: 50 Sec Memory Limit: 162 MB[Submit][Status][Discuss] Description M公司是一个非常庞大的跨国公司,在 ...
- 【洛谷 P3846】 [TJOI2007]可爱的质数 (BSGS)
题目链接 \(BSGS\)模板题..不会点这里 #include <cstdio> #include <cmath> #include <map> using na ...
- NYOJ 127 星际之门(一) (数学)
题目链接 描述 公元3000年,子虚帝国统领着N个星系,原先它们是靠近光束飞船来进行旅行的,近来,X博士发明了星际之门,它利用虫洞技术,一条虫洞可以连通任意的两个星系,使人们不必再待待便可立刻到达目的 ...
- 愚蠢的LCAAAAA~~~~(>_<)~~~~
很愤怒!特别愤怒!超级愤怒!!! 我LCA居然错了!!而且是那种特别愚蠢的错误 我把代码都交错了!!! silasila 话不多说,代码上特别详细了 #include<bits/stdc++.h ...