Page MenuHomePhabricator

Allow SlotRoleHandlers to control page layout
Open, Needs TriagePublic

Description

The Layout of the output returned by RenderedRevision::getCombinedParserOutput() should be based on the layout hints returned by the respective SlotRoleHandlers.

Implementation notes:

For SlotRoleHandlers to control the layout of the output returned by RenderedRevision::getCombinedParserOutput(), RevisionRenderer should inject a callback into RenderedRevision that can be used to combine the ParserOutputs for the individual slots. That callback would in turn call code in RevisionRenderer that would use the SlotRoleRegistry to get the appropriate SlotRoleHandlers, and ask them for layout hints.

Option for more flexible layout:
We could replace getOutputLayoutHints with getOutputLayout, which returns a list of "chunks", each containing an HTML string and layout hints. This way, slots could put output in multiple locations of the layout. How the SlotRoleHandler extracts the "extra bits" from the ParserOutput is specific to the slot and content model - it could be done by parsing the HTML, or using getExtensionData, or some other mechanism.

Related Objects

StatusSubtypeAssignedTask
Declineddchen
OpenNone
OpenNone
DuplicateNone
OpenFeatureNone
OpenBUG REPORTNone
OpenNone
StalledNone
OpenFeatureNone
DuplicateNone
ResolvedNone
OpenNone
OpenNone
OpenFeatureNone
OpenNone
ResolvedNone
ResolvedNone
OpenFeatureNone
OpenNone
OpenFeatureNone
StalledNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolveddaniel
InvalidTgr
ResolvedAnomie
ResolvedAnomie
OpenNone
Resolveddaniel
Resolveddaniel
OpenNone
OpenNone

Event Timeline

I kind of wish there was basically some sort of hook here where i could combine things in arbitrary ways. I don't think a few predefined options is ever going to be sufficient.

It seems like now, most people regex out the mw:slotheader in ParserOutputPostCacheTransform, which is icky (regexing html always a bad time), but also doesn't let you do it in such a way that the result is actually cached in parser cache.

I kind of wish there was basically some sort of hook here where i could combine things in arbitrary ways. I don't think a few predefined options is ever going to be sufficient.

I agree, but the conceptual question is: what component decides on the layout of a page? I think we should have something like a PageTypeHandler ([[T209924]])

See also T151952 and linked tasks, including T90914. I suspect what we want is a proper "page layout specification" that you can "pour" the article text, sidebars, media etc into. But it's hard to find the right balance that allows some customization while maintaining a uniform overall appearance for the site which is compact enough to allow reasonably reskinning for print/mobile/etc (ie without having to recode a bazillion different page layouts).