xowiki::PageInstance instproc get_from_template (public)

 <instance of xowiki::PageInstance[i]> get_from_template var \
    [ default ]

Defined in packages/xowiki/tcl/xowiki-procs.tcl

Get a property from the parent object (template). The parent object might by either an ::xowiki::Form or an ::xowiki::FormPage

Parameters:
var
default (optional)
Returns:
either the property value or a default value

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) xowiki::PageInstance instproc get_from_template xowiki::PageInstance instproc get_from_template test_create_form_with_form_instance->xowiki::PageInstance instproc get_from_template

Testcases:
create_form_with_form_instance
Source code:
set form_obj [:get_template_object]

#:msg "get $var from template form_obj=$form_obj [$form_obj info class]"

# The resulting page should be either a Form (PageTemplate) or
# a FormPage (PageInstance)
#
#:msg "parent of self ${:name} is [$form_obj name] type [$form_obj info class]"
#
# If it is as well a PageInstance, we find the information in the
# properties of this page. Note that we cannot distinguish here between
# intrinsic (starting with _) and extension variables, since get_from
# template does not know about the logic with "_" (just "property" does).
#
if {[$form_obj istype ::xowiki::PageInstance]} {
  #:msg "returning property $var from parent formpage $form_obj => '[$form_obj property $var $default]'"
  return [$form_obj property $var $default]
}

#
# .... otherwise, it should be an instance variable ....
#
if {[$form_obj exists $var]} {
  #:msg "returning parent instvar [$form_obj set $var]"
  return [$form_obj set $var]
}
#
# .... or, we try to resolve it against a local property.
#
# This case is currently needed in the workflow case, where
# e.g. anon_instances is tried to be fetched from the first form,
# which might not contain it, if e.g. the first form is a plain
# wiki page.
#
#:msg "resolve local property $var=>[:exists_property $var]"
if {[:istype ::xowiki::FormPage] && [:exists_property $var]} {
  #:msg "returning local property [:property $var]"
  return [:property $var]
}
#
# if everything fails, return the default.
#
#:msg "returning the default <$default>, parent is of type [$form_obj info class]"
return $default
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: