# |
Jul 11th 2017, 09:43 |
heter |
@savant are u still here ? |
# |
Jul 11th 2017, 09:13 |
jonasz |
each day i'm learning more ;) |
# |
Jul 11th 2017, 09:13 |
savant |
no problem |
# |
Jul 11th 2017, 09:13 |
jonasz |
i understand. thank you for help |
# |
Jul 11th 2017, 09:12 |
savant |
the overhead is super minimal |
# |
Jul 11th 2017, 09:12 |
savant |
than the inclusion of one more file in your application |
# |
Jul 11th 2017, 09:12 |
savant |
its far more likely that you have a sql query that is unnecessarily joining tables which causes a slowdown in your application |
# |
Jul 11th 2017, 09:11 |
savant |
and then that stat call will be cached by the operating system |
# |
Jul 11th 2017, 09:11 |
savant |
since the file will be stat’d once |
# |
Jul 11th 2017, 09:11 |
savant |
there is minimal overhead on including another file |
# |
Jul 11th 2017, 09:11 |
jonasz |
thx, that is exactly what i was looking for ;) |
# |
Jul 11th 2017, 09:11 |
savant |
again, as @glanceded said, elements or helpers would be better suited to this problem |
# |
Jul 11th 2017, 09:11 |
savant |
which is better done at the user-level |
# |
Jul 11th 2017, 09:10 |
savant |
its just not possible to do what you’re asking without some hokey-pokey extra logic |
# |
Jul 11th 2017, 09:10 |
savant |
(or whatever the equivalent is |
# |
Jul 11th 2017, 09:10 |
savant |
`echo str_replace('some_var', 'derp', $this->fetch('sidebar'))` |
# |
Jul 11th 2017, 09:10 |
jonasz |
aha, i get u now |
# |
Jul 11th 2017, 09:10 |
savant |
but then, why cant you just do the following |
# |
Jul 11th 2017, 09:10 |
savant |
for instance |
# |
Jul 11th 2017, 09:09 |
savant |
`{{some_var}}` |
# |
Jul 11th 2017, 09:09 |
savant |
so we’d need to come up with some alternative syntax for embedding variables |
# |
Jul 11th 2017, 09:09 |
savant |
not when you call `$this->fetch('sidebar', ['some_var' => 'derp']);` |
# |
Jul 11th 2017, 09:09 |
savant |
as is, the `$some_var` is interpolated at the time of the entire template inclusion |
# |
Jul 11th 2017, 09:08 |
savant |
lets say you want to use that element elsewhere |
# |
Jul 11th 2017, 09:08 |
savant |
$this->start(‘some-element’); echo “derp ${some_var}“; $this->end(); |
# |
Jul 11th 2017, 09:07 |
savant |
consider the following |
# |
Jul 11th 2017, 09:07 |
savant |
we cant really do that |
# |
Jul 11th 2017, 09:07 |
savant |
adding a third argument would mean interpolation |
# |
Jul 11th 2017, 09:07 |
savant |
in order to use one |
# |
Jul 11th 2017, 09:07 |
savant |
you dont need to share an element |
# |
Jul 11th 2017, 09:07 |
jonasz |
i get your points, but still, I think adding 3rd argument to fetch(), so it acts a little bit as an element, would enrich capabilities of framework slightely. that would suit one particular case where u don't share a snipet between multiple views/layouts ;) aloso loading element is additional overhead - reading new file etc. thx for advice |
# |
Jul 11th 2017, 09:03 |
savant |
(usually) |
# |
Jul 11th 2017, 09:03 |
savant |
so you can trust my advice |
# |
Jul 11th 2017, 09:03 |
savant |
if it helps give some strength behind my argument, I’m one of the cakephp core developers |
# |
Jul 11th 2017, 09:03 |
savant |
easiest of the three to setup - just one extra file - and you can assign the output of the element to a view block if you really needed it |
# |
Jul 11th 2017, 09:02 |
savant |
i would go with an element |
# |
Jul 11th 2017, 09:02 |
savant |
those are your options |
# |
Jul 11th 2017, 09:02 |
savant |
- use a helper |
# |
Jul 11th 2017, 09:02 |
savant |
- use an element |
# |
Jul 11th 2017, 09:02 |
savant |
- use a view cell |
# |
Jul 11th 2017, 09:02 |
savant |
if you want conditional output, you’ll need to either: |