Page MenuHomePhabricator

Templates can't detect whether they're included directly or through another page
Open, LowPublicFeature

Description

Author: majuki

Description:
In specific use cases there is currently no way to detect the following:

ArticleA contains this code:

{{TemplateX}}

ArticleB contains this code:

{{:ArticleA}}

TemplateX is unable to detect when it is being included in ArticleB.

Why this is a problem:
In several scenarios you want something to automatically occur when TemplateX is used, by example: Adding a page to a specific category. This is often not the desired result on composite pages like ArticleB that want to display the content of ArticleA but not necessarily use all the features related to it. Because of the include flow the only means to modify TemplateX's behaviour on the two separate pages would be to detect when {{: is being used. There is currently no mechanism for that.


Version: unspecified
Severity: enhancement

Details

Reference
bz22588

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:02 PM
bzimport set Reference to bz22588.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

Bug 835 might be relevant to your use-case.

majuki wrote:

It is related, though more directly related to categories which is merely an example. The core issue is being able to detect the difference, as you appropriately adjusted the title to reflect, between a direct inclusion and inclusion through another page.

urkle wrote:

I would like to be able to "detect" inclusion, but more specifically for extensions.

I have an parser hook extension that attaches on to a <changesignature> tag, and I need the tag to be attached to the page that contains the tag not the one that included it.

ie.. I am creating a large policy manual and am using this extension (that I wrote) to track acceptance of the changes by staff. And the HR dept is wanting to split the manual into multiple pieces to easier maintenance as well as to track signatures per-section. However the tag doesn't get processed until after inclusion is done so I lose the originating page.

Right now I'm walking through the code to determine where the inclusion happens to I can *hack in* a hook to provide me this functionality so I can modify the <changesignature> tag to include the original page ID as an attribute/argument.

Note that Lua modules are capable of doing this, via frame:getParent():getTitle().

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.