CodeIgniter动态钩子

时间:2015-08-11 07:18:28

标签: php codeigniter hook

我正在使用CI 3.0来调用namespace System.Web.Http { /// <summary> /// Annotates a controller with a route prefix that applies to all actions within the controller. /// </summary> [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class RoutePrefixAttribute : Attribute, IRoutePrefix { /// <summary> /// Gets the route prefix. /// </summary> public virtual string Prefix { get; private set; } /// <summary> /// Initializes a new instance of the <see cref="T:System.Web.Http.RoutePrefixAttribute"/> class. /// </summary> protected RoutePrefixAttribute() { } /// <summary> /// Initializes a new instance of the <see cref="T:System.Web.Http.RoutePrefixAttribute"/> class. /// </summary> /// <param name="prefix">The route prefix for the controller.</param> public RoutePrefixAttribute(string prefix) { if (prefix == null) throw Error.ArgumentNull("prefix"); this.Prefix = prefix; } } } 钩子中的脚本,该脚本将替换[[templatedata:head]]等令牌,其中包含与模板头部相关的所有脚本和CSS,因此它将在模板中注入相关的display_override作为< script >标记,但由于不同的模板可能有不同的脚本,因此需要在注入时动态确定。脚本源是配置文件中的数组,模板名称为数组键。

有没有办法可以设置一个常规变量或会话变量来保存该模板名称以便钩子脚本可以访问,以便调用脚本的正确数组子部分?

1 个答案:

答案 0 :(得分:0)

通过更改执行脚本和链接替换的钩子来运行post_controller而不是pre_controller来解决问题,并在主index.php文件中设置一个静态变量,然后获取更新模板的调用位置,从而对模板进行必要的替换。

相关问题