xowiki::PageInstance instproc www-use-template (public)

 <instance of xowiki::PageInstance[i]> www-use-template

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

This web-callable method can be used to change the "template" of a PageInstance. The caller provides the "form" as query parameter which should be used in future for handling the instance parameters of the PageInstance. This method can be as well be used for changing the associated workflow of a workflow instance.

Partial Call Graph (max 5 caller/called nodes):
%3 ad_return_url ad_return_url (public) xowiki::PageInstance instproc www-use-template xowiki::PageInstance instproc www-use-template xowiki::PageInstance instproc www-use-template->ad_return_url

Testcases:
No testcase defined.
Source code:
set formName [:query_parameter "form" ""]
if {$formName eq ""} {
  error "no form specified"
}
::${:package_id} get_lang_and_name -default_lang [::xo::cc lang] -path $formName lang stripped_url
set d [::${:package_id} item_ref -default_lang $lang -parent_id [::${:package_id} folder_id] $formName]
set item_id [dict get $d item_id]
if {$item_id == 0} {
  error "cannot lookup page $formName"
}
::xo::db::CrClass get_instance_from_db -item_id $item_id
if {![nsf::is object ::$item_id]
    || "::xowiki::PageTemplate" ni [::$item_id info precedence]} {
  error "OK $formName is not suited to be used as template. Should be a Form!"
}
if {${:page_template} == $item_id} {
  :msg "old page_template $item_id is already the same as the new one"
} else {
  set msg "change template_id ${:page_template} to $item_id"
  :page_template $item_id
  :save
  #:msg "ok $msg"
}
::${:package_id} returnredirect [ad_return_url]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: