templates - how to create complex container in php -
I am creating a container type that contains a lot of:
- Form Bar
- Tab Bar
- Custom Bar
- Information < Li> action / status bar
- content area
Of these, only the content area is required, there are sub-types that share common sets of bars , But they can also be mixed and arbitrary numbers Can match in the plans Also, there may be content on the left or right edge of each bar-type
I am going down the path to building a panel square with properties:
// erosion __toString () if ($ this- & gt; info_left || $ this- & gt; info_right) {$ results. = $ This- & gt; Add_bar ('info', $ this- & gt; info_left, $ this- & gt; info_right); } If ($ this- & gt; search_button || $ this- & gt; search_right) {$ Result = $ This- & gt; Add_bar ('search', $ this- & gt; search_bound, $ this- & gt; search_right); } // End Snip Personal Function add_bar ($ type, $ left, $ right) {$ result = & lt; & Lt; & Lt; Here & lt; Div class = "$ type" & gt; & Lt; Div class = "left" & gt; $ Left & lt; / Div & gt; & Lt; Div class = "right" & gt; $ Right & lt; / Div & gt; & Lt; / Div & gt; here; } and to instantiate a panel:
$ p = new panel ("my panel"); $ P- & gt; Info_left = "my left content"; $ P- & gt; Search_right = "my right search content"; Echo $ p; So far, I have stayed away from using a template engine because the argument seems quite complex that I am trying to keep it around in class. (There is very little business logic in class, but there are lots of presentation logic.) Maybe there is a better view ....?
Looks like you're rebuilding the divs, I think it would be better if you divas Define the format, and then different CSS styles make each style of different divs in style.
Then something like this will happen:
& lt; Div class = "title" & gt; & Lt; Div class = "left" & gt; My left material & lt; / Div & gt; & Lt; Div class = "right search" & gt; My true search content & lt; / Div & gt; & Lt; / Div & gt; I have complex arguments for CSS rules, and after that you create separate templates for each type.
Comments
Post a Comment