Begin main content
Search · Index
No registered users in community s5-xowiki-tutorial
in last 10 minutes

CRUD Example

# Prerequisites
# - Initialize package instance
::xowiki::Package initialize -url /xowiki

# - Get the id of the Content Repository Folder (folder_id)
set folder_id [$package_id folder_id]

# READ operation: Check, whether a page_name is already used
set page_name "my_page_[clock scan now]"

if {[::xo::db::CrClass lookup -name $page_name -folder_id $folder_id] == 0} {
  # We can CREATE the page
  # First create an XOTcl Object in memory
  ::xowiki::PlainPage create $page_name \
     -set text {This is the content of the new Page} \
     -set title {This is the Title of the new Page} \
     -name $page_name \
     -parent_id $folder_id \
     -package_id $package_id

  # persist the page in the content repository
  $page_name save_new

  # optionally, destroy the XOTcl object
  $page_name destroy