Personal tools
You are here: Home   Additional documentation   Cheat sheet  
Search
 
Document Actions

Cheat sheet

by Balazs Ree last modified 2007-10-30 19:05

Listing of commands and parameter provider functions


This page is obsolete. Read this for more information.


This list is just gives the list of available commands and parameter provider functions, with no attempt to teach their usage. It should be used as a cheat sheet for those already familiar with KSS.

Commands (in core)

Parameters shown after the command. All parameters are passed by name (like **kw in python). Some parameters are mandatory, some have default value.

HTML functions to insert stuff

These commands are the ones that are most commonly used.

  • replaceInnerHTML: replace all children of the given node (previously: setHtmlAsChild)

    • html: the html to insert
  • replaceHTML: replace HTML including the given node.

    • html: the html to use as replacement (only the first node is used in the replace)
    • selector: (optional) a CSS selector. If this is given, this is used to select a node from within the html parameter, and only this part is inserted. I am not sure any more what use case made us implement this and it seems we need to get rid of it.
  • appendHTML: add HTML after last child of given node

    • html: the html to insert
  • insertHTMLBefore: add HTML before given node.

    • html: the html to insert

  • insertHTMLAfter: add HTML after given node

    • html: the html to insert
  • insertHTMLAsFirstChild: add HTML inside the given node, at the beginning

    • html: the html to insert

  • insertHTMLAsLastChild: add HTML inside the given node, at the end

    • html: the html to insert

Ability to do stuff with nodes client side

  • deleteNode: delet e the node
  • clearChildNodes: delete all the children of the node
  • deleteNodeAfter: delete the next node
  • deleteNodeBefore: delete the previous node

We seriously think we do not need the next commands so will either be deprecated or moved out of the core into an extension. We do not suggest to use them at the moment.

  • moveNodeAfter:
    • html_id: the id of the second node
  • moveNodeBefore:
    • html_id: the id of the second node
  • copyChildNodesFrom:
    • html_id: the id of the second node
  • copyChildNodesTo:
    • html_id: the id of the second node

Attributes

  • setAttribute: Sets a given HTML attribute of the node.
    • name: the attribute name. "style" cannot be used.
    • value: the attribute value to set
  • setKssAttribute: Sets a given KSS attribute of the node, available for reading with the kssAttr() parameter producer function.
    • name: the attribute name.
    • value: the attribute value to set
  • removeAttribute: Removes a given HTML attribute of the node (unimplemented) Remark: same result is achieved if set an attribute to an empty string.
    • name: the attribute name
  • setStyle: Sets a given style element on the node.
    • name: the name of the style element.
    • value: the style element value to set

Miscellaneous

  • setStateVar: sets a variable that resides on the client, in a global namespace. You can also use namespace-name to separate namespaces. This variable can be sent back to a server action later, as a parameter.
    • varname: the variable name
    • value: the value to set

The next command is only needed for advanced use cases ans needs additional explanation elsewhere:

  • triggerEvent: Triggers an event in the same event binder instance that sent the request to the server. Optionally, id and namespace can be used to select a different event id. This is an advanced command that enables to execute a continuation event on the client and is only useful with complex stateful events.
    • name: the event name
    • id (optional): the event instance id, if we want a different one from the current
    • namespace (optional): can be used with id, unless it is a global event name

Value Providers

They have positional parameters (no key=value ! ) This is because we wanted to stay reasonably within the syntax of css that we mimic.

All the functions operate on the selected node as a scope. This is the node that triggered the current event.

Fetching form data

Form data can be fetched in two selection levels:

  • a given form can be used or the current form where the node resides in
  • a given variable can be used or the current node content will be utilized.

Functions to fetch a given form variable:

  • formVar(formname, varname):  Produces the value of a given variable within a given form.
  • currentFormVar(varname): Produces the value of a given variable within the current form, which is the one in which the selected node is. The parameter varname is optional, and if it is ommitted, the current node will be used (in this case it must be a form variable itself).

Functions to fetch all variables of a form:

This can be done by the kssSubmitForm action parameter. This must be a parameter with the name kssSubmitForm and a value of one of the followings:

  • form(formname):  Produces the values of all the variables in a given form.
  • currentForm(): Produces the values of all the variables in the form that contains the current node.

  • <string>: equals to form(<string>).

These providers cannot be used for normal parameters (the old usage is deprecated).

Fetching content

  • nodeAttr(attrname [, recurseParent]): Produces the value of a given html attribute of the selected node. The optional second parameter is by default false. If set to true, it tries to recursively acquire the attribute from parent nodes as well.
  • kssAttr(attrname [, recurseParent]): Produces the value of a given kss attribute of the selected node. The optional second parameter is by default false. If set to true, it tries to recursively acquire the attribute from parent nodes as well. The kss attribute may be encoded in the page as a namespace attribute in the form of kssattr:key="value" (only in case of real xhtml iow not for Plone) or in a class emulation mode appended at the end of the existing class attribute as class="... kssattr-key1-value1 kssattr-key2-value2 ... kssattr-keyN-valueN"
  • nodeContent(recursive): Produces the textual content of the node. Newlines are converted to spaces. If the parameter is false (default), then only the direct text nodes are considered, if the parameter is true, texts are fetched from the whole subtree.

Miscellaneous

  • stateVar(varname): Procudes the value of a state variable, that is, the same that can be set via the setStateVar command.
  • pass(attrname): To be described elsewhere. It is only used in advanced cases with specially developed stateful event plugins.
  • currentFormVarFromKssAttr(attrname [, recurseParent]): experimental, the two methods cascaded.

Action parameters

There are special parameters that are associated with an action itself. They all start with kss  and consequently normal parameters cannot have a name starting with this prefix.

For action-server:

  • kssUrl: can specify a different url then what would be the page base url and the name of the action concatenated after it. For example, views containing a @@ in the url can be called this way.
  • kssSubmitForm: submits an entire form directly onto the request. (Described in more details above.)

For action-client and the default action:

  • kssSelector: changes the scope of execution.