登山扣问题——Codeigniter 库
当我使用登山扣库时,我的 css 和 js 文件会附加到页面顶部。有没有一种方法可以指定文件应附加到的位置,也许可以尝试将文件作为数组发送到我的视图文件?
谢谢
When I use the carabiner library, my css and js files are appended to the top of the page. Is there a way i could specify where the files should be appended maybe try to send the files as an array to my view files?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您呈现视图的方式,可能会略有不同,但对于传统的、乏善可陈的方法,这里有一个示例:
主控制器:
标题视图:
May differ slightly based on how you are rending your views, but with the conventional, lackluster way of doing it, here's an example:
Home controller:
Header view:
这是我对登山扣无缓冲输出的主要烦恼之一。每个输出函数都会
echo
返回值,而不是......返回它。在不破坏库的情况下(我个人会这样做),这里是一个如何执行您所要求的操作的示例:
现在您有一个带有 js/css 标记输出的变量,您可以将其发送到视图文件或模板。如果没有输出缓冲,这会立即将标签打印到输出中。请注意,如果您愿意,另一种解决方法是确保在需要输出函数之前不调用它们,就像在模板本身中一样。
如果您想永久修复此问题,请浏览 Carabiner 库并将
echo $some_return_value;
的每个实例替换为return $some_return_value;
(任何输出函数的最后一行)。有很多,所以这需要一些时间。至于返回数组,我不太确定 - 我从来没有用登山扣做到那么远(不喜欢它)。希望这仍然有帮助。祝你好运!
了解有关输出缓冲的更多信息: http://php.net/manual/en/book.outcontrol .php
This was one of my major annoyances with Carabiner, unbuffered output. Every output function
echo
s the return value instead of.. returning it.Without hacking up the library (which I would personally do), here is an example of how to do what your'e asking:
Now you have a variable with the js/css tag output you can send to your view file or template. Without the output buffering, this would print the tags to your output immediately. Note that if you want, another workaround is to make sure you don't call the output functions until you need them, like in the template itself.
If you wanted to fix this permanently, go through the Carabiner library and replace every instance of
echo $some_return_value;
toreturn $some_return_value;
(last line of any output function). There are a lot, so this will take a little time.As far as returning arrays, I'm not too sure - I never made it that far with Carabiner (didn't like it). Hopefully this helps all the same. Good Luck!
Read more on output buffering: http://php.net/manual/en/book.outcontrol.php