显示和访问 CMS 链接的逻辑?
我们有一个内容管理系统,我们可以在其中创建不同类型的内容。网页内容、文件附件和 URL。创建内容后,它会以链接的形式显示在网站上。链接标题、其内容、url 文件附件和任何其他元数据都存储在数据库中。单击链接时,如果内容是应下载的文件附件,则我们必须打开内容。如果是 URL,则应在新窗口中打开。如果其网页内容应显示在同一页面中。此外,当我们访问内容时,我们需要维护访问矩阵。有人可以为此建议一个解决方案吗?我其实是在寻找逻辑。
We have a Content Management System where we create content of different types. Web Content,File Attachments and URL. After the content is created its displayed on the site in the form of links. The link title its content,url file attachement and any other metadata is stored in the database. When clicking on links we have to open the content if the content is file attachment it should download.If its url it should open in new window. If its web content it should show in same page. Also when we access a content we need to maintain the access matrix. Can somebody suggest a solution for this. I am actually looking for logic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户单击下载链接时,您可以通过提供如下所示的 mime 类型,使用标头部分控制浏览器行为:
然后浏览器应在窗口内将其作为图像打开(当然,您必须在标头后提供文件内容)。要强制下载,请将 Content-Type 设置为:
header("Content-Type: application/force-download");
至于 url,您可以简单地使用 target=_blank,如下所示:
You can partially control the browser behavior using headers when user clicks the download link by supplying the mime type like this:
Then the browser should open it inside the window as an image (Naturally you would have to supply the file contents after the header). To force download, you set the Content-Type to:
header("Content-Type: application/force-download");
As for the urls you can simply use target=_blank like so: