Welcome Guest, Not a member yet? Register   Sign In
In views use <?php echo $title; ?> or <?=$title?> ?
#11

[eluser]Georgi Budinov[/eluser]
It is personal/team point of view. I agree about the fact the views are the field of designers, but here we have a dilemma we must solve, about the statement mentioned above e.g. &lt;?=isset($alabala)?'<div>'.$alabala.'</div>':''?&gt;:

1) prepare $alabala with the surrounding html altogether from the controller ( I do not like)
2) make this simple condition in the view

By complex logic I meant more complex if statement for example or longer surrounding html with different attributes defining specific UI, which goes to designers' field.

Which one is the right depends on the php skills of designers ... and team conventions
#12

[eluser]Derek Jones[/eluser]
Quote:but here we have a dilemma we must solve, about the statement mentioned above e.g. &lt;?=isset($alabala)?’<div>’.$alabala.’</div>’:’‘?&gt;:

To me, it's not a dilemma. I don't use ternary operators in View files, for my previously stated reasons. I also set <em>all</em> view variables, so I'd use:

Code:
&lt;?php if ($alabala): ?&gt;
    <div>&lt;?=$alabala?&gt;</div>
&lt;? endif; ?&gt;

It's a bit more verbose, but to me far more legible, particularly to non-coders.

Quote:It is personal/team point of view.

Quite, and that hits the nail on the head. Almost akin to coding style, the important thing is that you and your team choose one way and stick to it consistently.
#13

[eluser]Georgi Budinov[/eluser]
To be honest, I have never tried out the 'if(): endif;'. This makes sense and a better alternative to the way I write now.

Code:
&lt;? if ($alabala): ?&gt;
    <div>&lt;?=$alabala?&gt;</div>
&lt;? endif; ?&gt;

vs

Code:
&lt;?php if ($alabala) { ?&gt;
    <div>&lt;?php echo $alabala; ?&gt;</div>
&lt;?php } ?&gt;

You got me here! I will try this approach in a few views to make a decision Smile
#14

[eluser]EugeneS[/eluser]
[quote author="Georgi Budinov" date="1284397246"]
By complex logic I meant more complex [/quote]

for more complex logic you have Controller Smile

but in the view should be simple logic of data representation ...
simple flags, simple loops, simple functions like date(), include() etc. easy understanding things ... designer shouldnt know anything about OOP etc.

try to make your views as close to smarty attitude as possible. all designers can use and understand If-s and loops in smarty Smile

try alternative syntax, welcome to the club Wink




Theme © iAndrew 2016 - Forum software by © MyBB