Closed (works as designed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Sep 2011 at 15:30 UTC
Updated:
29 Jul 2014 at 20:01 UTC
Jump to comment: Most recent file
Comments
Comment #0.0
dozymoe commenteds/by of/,/
Comment #1
dozymoe commentedOn second thought, it would be better if I can have,
rendered first then have it converted to,
somehow. :S
This is for #theme whose arguments expect simple text or predefined html markup.
Comment #2
dozymoe commentedI came up with:
Basically it merges several children listed in $values part of #map_childs into a single key. Presumable, like in the sample below, points to #text, an argument that goes to theme_link.
Implemented here.
Doesn't work with #type such as '#type' => 'link' because the #pre_render clashed. I think. Dunno.
So it's fine if we just use '#theme' => 'link'.
PS: I see similar applications in drupal_pre_render_links.
Comment #3
dozymoe commentedChanged title and marked as need review.
Also served as snippet page, if anybody is interested. :3
Comment #4
dozymoe commentedFailed at theme_links() XD. Bummer.
Comment #5
dozymoe commentedThe following code works, with a little exception.
The change is, for theme function that expects the argument to be an array, #map_childs' value has to be a string, not array. This tells drupal_pre_render_map_childs not to set the argument with results from drupal_render_children(), but link it by reference to $element[$value], thus result in an array that we wanted.
Example follows.
Notice that html value is '1' (a string). Either wise that element is passed to element_children() and produce warnings.
Warning: Invalid argument supplied for foreach() in element_children()Ugly as hell, but in my use case, it works. 0.0b
PS: set html to value '1' or '0' works as if it is set with TRUE and FALSE. Me need to spent more time debugging. This could replace drupal_pre_render_links() with a bit more functionality.
Comment #6
dozymoe commentedSimple fix, modified drupal_render() in includes/common.inc, before:
And after:
Maybe I should add
!count($elements)in there. Hm.First attempt on OnionHead _failed_.
Comment #7
dozymoe commentedIn case somebody is waiting for this to hit need review ~(‾-‾")~, forgotten to mark the patch listed, no changes made.
Reduce possible hick-up to one.
That is if the theme function requires 2 or more level-deep array-argument.
Might become a problem since drupal_render_children automatically adds #printed and #children element.
This two elements can be an unexpected baggage in the theme function.
Comment #8
dozymoe commented#6: argument_totheme_asrenderarray.patch queued for re-testing.
Comment #9
xjmThanks for your work on this patch. I'm not sure whether we'd want to include this callback in core or not; however, here are some suggestions for cleaning up the patch a little.
Let's try to fit this on one line. Maybe:
Also, generally, let's change "childs" to "children" everywhere in the patch.
Finally, note that the Drupal 8.x patch will need to be rerolled, because the core directory structure for Drupal 8 has now changed. (For more information, see #22336: Move all core Drupal files under a /core folder to improve usability and upgrades). When the patch has been rerolled, please set the issue back to "Needs Review."
Tagging as novice for the task of rerolling the Drupal 8.x patch.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #10
dozymoe commentedA quick note:
This function uses iteration, can cause deep iteration if the render array is nested too deep.
PHP is not optimized to do iteration, I think.
Unless, drupal uses SPL iterators, then this might just work for the general cases.
I'll try to find the link where I've read that, in stackoverflow.com IIRC.
Comment #11
musicnode commentedRe-rolled per xjm's suggestions:
1) Changed comment to: Pre-render callback: renders specified children as the value of another child.
2) Changed change "childs" to "children" everywhere in the patch.
Comment #12
musicnode commentedUploaded the patch, so unassign.
Comment #13
dozymoe commentedClosed as works as designed I guess, to be removed from the issue queue active priority.
Comment #13.0
dozymoe commentedheh. s/of//