Log message #4050454

# At Username Text
# 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:
# Jul 11th 2017, 09:02 savant that value can be a single character or a lot of html
# Jul 11th 2017, 09:02 savant and then pull the value out
# Jul 11th 2017, 09:02 savant you assign a value into them
# Jul 11th 2017, 09:02 savant viewblocks arent meant for what you are trying to use them for
# Jul 11th 2017, 09:01 savant if its too small to dedicate, just make your viewblock wrap around a for loop instead
# Jul 11th 2017, 09:01 savant a helper would also be a good fit
# Jul 11th 2017, 09:01 glanceded I think you need a helper. check out this page https://book.cakephp.org/3.0/en/views/helpers.html#creating-helpers
# Jul 11th 2017, 09:00 jonasz because it is small thing, and far too small to dedicate separate file for it. i'm applying x-editor UI to two text elements on my page - it is basically rendering some js code around them. the only vriable is the db field name. currently i chave to copy/paste it in the view - like 6 lines of code. I would prefer to have it in separate block
# Jul 11th 2017, 08:58 savant or something like that
# Jul 11th 2017, 08:58 savant foreach ($records as $record) echo $this->element(‘whatever’, [‘data’ => $record];
# Jul 11th 2017, 08:57 savant no, but why do you *need* it to be in the same file?
# Jul 11th 2017, 08:57 jonasz but i believe u cannot create element within view file. i will read more in doc, thx
# Jul 11th 2017, 08:57 glanceded you could pass your needed var to an element layout block by passign an array after the layout, like this: $this->element('your_element', ['var1' => 'value1']); and in your Elements/your_element.ctp $var1
# Jul 11th 2017, 08:55 savant then I would use an element, as @glanceded says
# Jul 11th 2017, 08:55 jonasz view cell seem to me as too much. i thought they are designed to cross layout/view and my piece of code is used only in single view.. hmm, maybe it would be handy feature to have 3rd param for View::fetch(), which would pass arguments to itself? Anyway, thx for your suggestions
# Jul 11th 2017, 08:52 savant they might be what you want
# Jul 11th 2017, 08:52 savant @jonasz look into View Cells
# Jul 11th 2017, 08:52 glanceded view block = $this->element()?
# Jul 11th 2017, 08:51 jonasz Morning Guys, have u ever passed any arguments to the view block? I have repetitive part of view, so I though it is good idea to put it into the view block and fetch it few times, but it doesn't seem to support any arguments I could possibly pass? I'm using cake 3.2.x.
# Jul 11th 2017, 08:48 savant trait all the things!
# Jul 11th 2017, 08:48 savant they are great
# Jul 11th 2017, 08:48 cleptric You mentioned that you like traits quite often in the cakeadvent last year ^^
# Jul 11th 2017, 08:47 savant trait jokes?
# Jul 11th 2017, 08:47 cleptric Yeees, more Trait jokes incoming :slightly_smiling_face:
# Jul 11th 2017, 08:47 savant that was last years cakeadvent
# Jul 11th 2017, 08:47 savant yeah