Project

General

Profile

Actions

Feature proposal #2279

closed

CB Substitutions: add default, output, formatting, reason options for fields and tab

Added by krileon almost 14 years ago. Updated almost 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
02 February 2011
Due date:
% Done:

100%

Estimated time:
2:00 h

Description

Having the option to specify specifically how to output and format from where a fields value would give much finer control. For example when substituting in Avatar it will always be full size and non-linked as the output, formatting, and reason are hardcoded in for Profile View. This limits substitution usage quite greatly.


Files

2279.patch (2.36 KB) 2279.patch krileon, 02 February 2011 18:43
2279-rev2.patch (2.36 KB) 2279-rev2.patch krileon, 02 February 2011 18:46

Related issues 1 (0 open1 closed)

Related to CB - Feature proposal #1895: Add new substitutions for CBClosedbeat21 July 2010

Actions
Actions #1

Updated by krileon almost 14 years ago

  • File 2279.patch 2279.patch added
  • Status changed from New to Resolved
  • Assignee set to beat
  • Target version set to CB 1.4.0
  • % Done changed from 0 to 100

Added support to getTab for output, formatting, and reason. Extended REGEX to capture output="STRING", formatting="STRING", and reason="STRING". Test case as follows (confirmed working). Completely backwards compatible as the additional options are similar to user= and not required.

Without User:
[cb:userfield field="avatar" output="html" formatting="none" reason="list" /]

With User:
[cb:userfield field="avatar" user="#me" output="html" formatting="none" reason="list" /]

Any combination of user, output, formatting, or reason can be used as well. So all 3/4 are not required to be provided. You can simply provide just reason such as follows.

[cb:userfield field="avatar" reason="list" /]

Actions #2

Updated by krileon almost 14 years ago

Sorry, named $output as $display, makes more sense to be $output. Rev2 fixes this.

Actions #3

Updated by beat almost 14 years ago

  • Estimated time set to 2:00 h
Actions #4

Updated by beat almost 14 years ago

  • getField() has one more param: $defaultValue = null than the suggested tab implementation. We should become 100% coherent there with params.
  • suggested getTab has default for $formatting = null the getField default $formatting is 'none'.
Actions #5

Updated by beat almost 14 years ago

  • Subject changed from Substitutions: add output, formatting, reason options for fields to CB Substitutions: add default, output, formatting, reason options for fields and tab
  • Status changed from Resolved to Closed

Thanks Kyle.

Implemented in r1424 with following changes:
  • added default="....." which displays when field or tab is not showed to user for any reason (access level, no user, and so on).
  • added $default to getTab() API as well, to make it consistent with getField().

Probably the regexp could be changed as follows:

instead of:

#\[cb:user(data +field|field +field|tab +tab|position +position)="([a-zA-Z0-9_]+)"(?: +user="([^"/\] ]+)")?(?: +default="((?:[^"]|\\")+)")?(?: +output="([a-zA-Z]+)")?(?: +formatting="([a-zA-Z]+)")?(?: +reason="([a-zA-Z]+)")? */\]#

to something like this:

#\[cb:user(data +field|field +field|tab +tab|position +position)="([a-zA-Z0-9_]+)"(?: +(user|default|output|formatting|reason)="((?:[^"]|\\")+)")* */\]#

or even:

#\[cb:([^ ]+)(?: +(field|tab|position|user|default|output|formatting|reason|[a-zA-Z]+)="((?:[^"]|\\")+)")* */\]#

That would then allow to generalize the parser...and even make it fully extensible.

That is as forethought for related feature #2297

Actions

Also available in: Atom PDF