CakePHP SignBox 组件
我正在尝试为我的网络应用程序实现一个简单的登录框,如果没有检测到会话,则只是一个常规的用户名和密码字段,如果有,则为一条欢迎消息,我从以下内容开始:
我认为是一个简单的元素会完成这项工作,但我意识到我不能包含元素中的 css 或 js(不是内联),因为 $scripts_for_layout 已经被发送到输出缓冲区。
我现在正在考虑将其实现为一个组件,不确定这是否是正确的架构(是吗?),但我绝对可以添加 js/css 并将它们输出到 head 标签中。现在的问题是我应该在哪里放置登录框的标记,可能是元素或视图,以及如何将它们注入到视图中?组件中的简单 $this->set('x', htmlmarkup) 和视图中的另一个 echo 。什么是正确的方法来做到这一点。
谢谢。 叶希亚
I'm trying to implement a simple login box to my web application, just a regular username and password field if no session is detected and a welcome message if there is one, i started with the following:
I thought a simple element will do the job, but i realized than i can't include css or js(not inline) from an element because the $scripts_for_layout would be already sent to the output buffer.
I'm now thinking of implementing it as a component, not sure if this would be the right architecture(is it?) but i can definitely add the js/css and output them in the head tag from there. The question is now where should i place the markup for the login box, an element or view maybe, and how do i inject them to the view? a simple $this->set('x', htmlmarkup) in the component and another echo in the view. What's right way to do it.
Thanks.
Yehia
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
元素绝对是您所需要的,因为它是在多个页面上重复使用的前端元素。
为了解决无法在元素中包含 CSS 或 JS 的问题,您可以为登录框创建单独的 CSS 和 JS 文件,并将它们包含在布局中。
An element is definitely what you need as it is a front-end element that is reused on several pages.
To get around the issue of not being able to include CSS or JS from an element you could create separate CSS and JS files for the login box and include them in the layout.