开发者

CakePHP SignBox Component

开发者 https://www.devze.com 2023-01-18 07:17 出处:网络
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 follow

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:

  1. I thought a simple element will do the job, but i realized than i can't include 开发者_如何学Ccss or js(not inline) from an element because the $scripts_for_layout would be already sent to the output buffer.

  2. 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消