Project

General

Profile

Actions

Feature proposal #7828

closed

Implement support for nested substitutions

Added by krileon about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
29 January 2020
Due date:
% Done:

100%

Estimated time:

Description

This should allow for substitutions within substitution attributes. So for example the following could be allowed.

[cb:userfield field="avatar" user="[cb_mentor]" /]

This needs to ensure the resulting value from the nested substitution is substitution safe. Meaning doesn't contain substitutions itself to prevent large substitution loops and to prevent user content being passed through substitutions. So in this case the substitution result must be strict so it should be cast to int unless it's a valid string value for the user attribute (e.g. #me).

Actions #1

Updated by krileon about 4 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Implemented in MR !1528

This is implemented by improving the processing order of substitutions. First raw field substitutions will take place (e.g. [FIELD_NAME]) followed by custom $extraString usages (e.g. [user]). Next userdata, userfield, date, config, etc.. substitutions will take place and last IF substitutions will take place. What this means is since raw substitutions have already parsed BEFORE userdata, userfield, if, etc.. usages you can place the raw substitutions inside of them. Example as follows.

[cb:userfield field="avatar" user="[cb_mentor]" /]
[cb:if user="#me" user_id="[cb_mentor]"]I am this users mentor![/cb:if]

What is not allowed is a userdata inside of a userfield. This is because they are both parsed by the same parsing behavior and logic wise it wouldn't make much since due to being prone to format output errors. So for example the below is not allowed.

[cb:userfield field="avatar" user="[cb:userdata field="cb_mentor" user="#me" /]" /]

The above maybe supported at a later time, but for now it is not and only raw nesting will be supported. In addition to this a below usecase is no longer supported due to the processing order change.

[cb:userfield field="avatar" user="[cb:if user_id="myid"]#displayed[cb:else]#me[/cb:else][/cb:if]" /]

This usecase would just be written as follows instead.

[cb:if user_id="myid"][cb:userfield field="avatar" user="#displayed" /][cb:else][cb:userfield field="avatar" user="#me" /][/cb:else][/cb:if]

The above makes more sense and is easier to read what is happening as well so the usecase isn't technically gone, but it has been changed.

Actions #2

Updated by beat about 4 years ago

  • Target version changed from CB 2.4.4 to CB 2.8
Actions #3

Updated by beat about 4 years ago

  • Target version changed from CB 2.8 to CB 2.4.5
Actions #4

Updated by beat almost 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF