Welcome Guest, Not a member yet? Register   Sign In
Suggestion building multiple used HTML Construct in Views
#1

[eluser]Publisher1[/eluser]
What do you suggest.

Situation 1:
1. Get DB Datas with the Model
2. Build the HTML Construct in thad Model method, with a parameter to return only Array or HTML constcuction
- Contra: HTML in Model
3. So we can output this smart in multiple views:
- Pro: smart identical codes in multiple views

Like:

Model:
Code:
public function getObjects($i_user_id,
          $b_get_html = false // Get default as array. Or you can get the HTML construct
          ) {
// .. 120  Code Lines, within HTML Construction
          }

View:
Code:
if(!empty($objects)) {
   echo $objects;
        } else {
            die();
        }


Situation 2:
1. Get DB Datas with the Model
2. Build the HTML Construct in the view and iterate through the array for construct the HTML
- Pro: No HTML in the Model
3. Construct same HTML in the Views:
- Contra: Identical big codes in multiple views

Model:
Code:
public function getObjects($i_user_id) {
// .. 20  Code Lines
          }

View:
Code:
if(!empty($return_array)) {
   // 120 code lines of HTML Construction on each view
        } else {
            die();
        }
#2

[eluser]Publisher1[/eluser]
My solution: i am loading a new view with the big HTML construct, into my views that i need.

View in view




Theme © iAndrew 2016 - Forum software by © MyBB