I have a CakePHP controller action where I would like to let the user download an HTML page for publishing through our internal CMS. I'm thinking that the notion of a Media View is what I want, except that they seem to require a filename and path. I already have the HTML content stored in a string and if possible I would like to be able to avoid saving it to disk just to make this work. Does anybody know a way of passing the content to Media Views as a string rather than as a filename and path?
我有一个CakePHP控制器操作,我想让用户下载一个HTML页面,通过我们的内部CMS发布。我认为媒体视图的概念是我想要的,除了它们似乎需要文件名和路径。我已经将HTML内容存储在字符串中,如果可能的话,我希望能够避免将其保存到磁盘只是为了使其工作。有没有人知道将内容作为字符串而不是文件名和路径传递给媒体视图的方法?
2 个解决方案
#1
Looking at the source code of media.php
, it seems that you can't do this directly using that view. Unless anybody has a better idea, I'm tempted to modify the view to support a content
parameter.
查看media.php的源代码,似乎无法直接使用该视图执行此操作。除非有人有更好的想法,否则我很想修改视图以支持内容参数。
#2
Check out this thread from the Google group. http://groups.google.com/group/cake-php/browse_thread/thread/9e99a7b99b54017d/bbaa1d6fd46cf299?hl=en&lnk=gst&q=mediaview#
查看Google小组中的此主题。 http://groups.google.com/group/cake-php/browse_thread/thread/9e99a7b99b54017d/bbaa1d6fd46cf299?hl=en&lnk=gst&q=mediaview#
There are instructions and patch that on how to create your own media view that handles this.
有关于如何创建自己的媒体视图来处理此问题的说明和补丁。
#1
Looking at the source code of media.php
, it seems that you can't do this directly using that view. Unless anybody has a better idea, I'm tempted to modify the view to support a content
parameter.
查看media.php的源代码,似乎无法直接使用该视图执行此操作。除非有人有更好的想法,否则我很想修改视图以支持内容参数。
#2
Check out this thread from the Google group. http://groups.google.com/group/cake-php/browse_thread/thread/9e99a7b99b54017d/bbaa1d6fd46cf299?hl=en&lnk=gst&q=mediaview#
查看Google小组中的此主题。 http://groups.google.com/group/cake-php/browse_thread/thread/9e99a7b99b54017d/bbaa1d6fd46cf299?hl=en&lnk=gst&q=mediaview#
There are instructions and patch that on how to create your own media view that handles this.
有关于如何创建自己的媒体视图来处理此问题的说明和补丁。