Jump to content

AtkTagAttribute: Difference between revisions

From NusaATK
Harrie (talk | contribs)
No edit summary
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{attribute}}
= Description =
= Description =
The tag attribute allows users to assign tags (tags as in 'keywords' and 'tagcloud') to records of an atkNode. The inputfield is probably familiair: there is a textfield where you can type several tags (comma seperated) and a list of already used keywords above it. In fact, this attribute should be a relation, because in the database the tagAttribute is just like a m2m relation with a different way of entering the values.
The tag attribute allows users to assign tags (tags as in 'keywords' and 'tagcloud') to records of an atkNode. The inputfield is probably familiair: there is a textfield where you can type several tags (comma seperated) and a list of already used keywords above it. In fact, this attribute should be a relation, because in the database the tagAttribute is just like a m2m relation with a different way of entering the values.
Line 39: Line 41:
* '''Flags''' ''Flag'' (optional)
* '''Flags''' ''Flag'' (optional)


The common [atkNode] flags.
The common [[Attribute_Flags]].


= Examples =
= Examples =
We have the following nodes:
'''customers'''  (Owner node, the original node you wanted to add the atkTagAttribute to)
*''id'' (PK)
*name
*address
*city
*phone
'''customers_tags'''    (Intermediate node, linking the owner node with the destination node)
*''customers'' (PK)      (Note that this field '''has''' to have the same name and type as the databasetable of the ownernode)
*''tags'' (PK)          (Must be called tags, same type as the primary key field in the destinationnode)
'''tags'''  (Destination node, containing all tags available)
*''id'' (PK)
*tagname
To make the atkTagAttribute work, now add the following line to the constructor of the owner node:
  $this->add(new atkTagAttribute("myowntagattribute","modulename.tags","tagname","modulename.customers_tags"));
Replace 'modulename' with the name of your module. Oh and don't forget to add the useattrib('atktagattribute') above your node.

Latest revision as of 17:26, 19 December 2007

Attribute: atkTagAttribute

API docs | Flags

List of other attributes

File:AtkTagAttribute.png
atkTagAttribute screenshot

Description

The tag attribute allows users to assign tags (tags as in 'keywords' and 'tagcloud') to records of an atkNode. The inputfield is probably familiair: there is a textfield where you can type several tags (comma seperated) and a list of already used keywords above it. In fact, this attribute should be a relation, because in the database the tagAttribute is just like a m2m relation with a different way of entering the values.

Parameters

  • Name String

The name of the attribute, can be anything you like. This name will be displayed to the user, but has no effect on the behaviour of the attribute.


  • Destination String

The name of the destinationnode in the format "module.node", so this is NOT the in-between node but the target node containing our tags.


  • Destinationfield String

The name of the field in the destinationnode containing the tag names.


  • Link String

The name of the intermediate node, linking our owner- and destinationnode together.


  • Mode Flag (optional)

Indicates the behaviour of the atkTagAttribute when the tag entered already exists. Can have one of the following values:

When the tag entered already exists, ....

    • TA_ADD (default): ...add the tag.
    • TA_ERROR: ...trigger an error.
    • TA_IGNORE: ...ignore tag.


  • Flags Flag (optional)

The common Attribute_Flags.

Examples

We have the following nodes:

customers (Owner node, the original node you wanted to add the atkTagAttribute to)

  • id (PK)
  • name
  • address
  • city
  • phone

customers_tags (Intermediate node, linking the owner node with the destination node)

  • customers (PK) (Note that this field has to have the same name and type as the databasetable of the ownernode)
  • tags (PK) (Must be called tags, same type as the primary key field in the destinationnode)

tags (Destination node, containing all tags available)

  • id (PK)
  • tagname

To make the atkTagAttribute work, now add the following line to the constructor of the owner node:

 $this->add(new atkTagAttribute("myowntagattribute","modulename.tags","tagname","modulename.customers_tags"));

Replace 'modulename' with the name of your module. Oh and don't forget to add the useattrib('atktagattribute') above your node.