publish::handle_item (private)

 publish::handle_item item_id [ args... ]

Defined in packages/acs-content-repository/tcl/publish-procs.tcl

Parameters:
item_id (required)
The id of the item to be rendered
Options:
-revision_id
{default The live revision} The revision which is to be used when rendering the item
-no_merge
Indicates that the item should NOT be merged with its template. This option is used to avoid infinite recursion.
-refresh
Re-render the item even if it exists in the cache. Use with caution - circular dependencies may cause infinite recursion if this option is specified
-embed
Signifies that the content should be statically embedded directly in the HTML. If this option is not specified, the item may be dynamically referenced, f.ex. using the <include> tag
-html
Extra HTML parameters to be passed to the item handler, in format {name value name value ...}
Returns:
The rendered HTML for the item, or an empty string on failure
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 content::item::get content::item::get (public) content::item::get_live_revision content::item::get_live_revision (public) publish::get_mime_handler publish::get_mime_handler (public) template::util::get_opts template::util::get_opts (public) template::util::is_nil template::util::is_nil (public) publish::handle_item publish::handle_item publish::handle_item->content::item::get publish::handle_item->content::item::get_live_revision publish::handle_item->publish::get_mime_handler publish::handle_item->template::util::get_opts publish::handle_item->template::util::is_nil

Testcases:
No testcase defined.
Source code:

  template::util::get_opts $args

  variable revision_html

  # Process options
  if { ![info exists opts(revision_id)] } {
    set revision_id [::content::item::get_live_revision -item_id $item_id]
  } else {
    set revision_id $opts(revision_id)
  }

  if { [template::util::is_nil revision_id] } {
    ns_log warning "publish::handle_item: No live revision for $item_id"
    return ""
  }

  if { ![info exists opts(no_merge)] } {
    set merge_str "merge"
  } else {
    set merge_str "no_merge"
  }

  # Create a unique key
  set revision_key "$merge_str $revision_id"
  if { [info exists opts(html)] } {
    lappend revision_key $opts(html)
  }

  # Pull the item out of the cache
  if { ![info exists opts(refresh)]
       && [info exists revision_html($revision_key)]
   } {
    ns_log debug "publish::handle_item: Fetching $item_id from cache"
    return $revision_html($revision_key)

  } else {

    # Render the item and cache it
    ns_log debug "publish::handle_item: Rendering item $item_id"

    content::item::get -item_id $item_id -array_name item_info
    set item_handler [get_mime_handler $item_info(mime_type)]

    if { $item_handler eq "" } {
      ns_log warning "publish::handle_item: No mime handler for mime type $mime_info(mime_type)"
      return ""
    }

    # Call the appropriate handler function
    set code [list $item_handler $item_id {*}$args]

    # Pass the revision_id
    if { ![info exists opts(revision_id)] } {
      lappend code -revision_id $revision_id
    }

    set html [{*}$code]
    ns_log debug "publish::handle_item: Caching html for revision $revision_id"
    set revision_html($revision_key$html

    return $html
  }
Generic XQL file:
packages/acs-content-repository/tcl/publish-procs.xql

PostgreSQL XQL file:
packages/acs-content-repository/tcl/publish-procs-postgresql.xql

Oracle XQL file:
packages/acs-content-repository/tcl/publish-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: