Welcome, Guest. Please Login
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
Pages: 1
Send Topic Print
Exporting tables of attribute values (Read 1599 times)
Mark Anderson
YaBB Administrator

User - not staff!

Posts: 5689
Southsea, UK
Exporting tables of attribute values
Jan 09th, 2015, 3:53am
This got asked about eslewhere and perhaps merits a pointer or two. I'll use as an example, this aTbRef page describing the $Color system attribute. At the top of the page is a table of data about the attribute and in this case all stored in user attributes - though system attributes work just the same in this context.

Not all aTbRef pages need this table, only those describing TB system attributes, so the main export template has a conditional section of code like this:


The include code is this:

<div id="attributetable">
	<div id="attributetableleft" style="display:inline-block;">
		<p class="attributetabletext"><b>Attribute Data Type:</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Default Value:</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Group:</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Purpose:</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Inherited from Preferences?</b>&nbsp;&nbsp;&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Read-Only?</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Intrinsic?</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute First Added:</b>&nbsp;</p>
		<p class="attributetabletext"><b>Attribute Altered:</b>&nbsp;</p>
	<div id="attributetableright" style="display:inline-block;">
		<p class="attributetabletext">&nbsp;^value($AttributeDataType)^ &nbsp; [^linkTo(^value($AttributeDataType.capitalize()+" Attributes")^,^value("other "+$AttributeDataType+"-type attributes")^)^]</p>
		<p class="attributetabletext">&nbsp;^value($AttributeDefault)^</p>
		<p class="attributetabletext">&nbsp;^value($AttributeGroup)^ &nbsp; [^linkTo(^value($AttributeGroup+" Attributes")^,^value("other "+$AttributeGroup+" Group attributes")^)^]</p>
		<p class="attributetabletext">&nbsp;^value($AttributePurpose)^</p>
		<p class="attributetabletext">&nbsp;^if(^equal(^value($AttributeInheritsPrefs)^,true)^)^Yes^else^No^endif^</p>
		<p class="attributetabletext">&nbsp;^if(^equal(^value($AttributeReadOnly)^,true)^)^Yes^else^No^endif^</p>
		<p class="attributetabletext">&nbsp;^if(^equal(^value($AttributeIntrinsic)^,true)^)^Yes^else^No^endif^</p>
		<p class="attributetabletext">&nbsp;^value($CodeFirstAdded)^</p>
		<p class="attributetabletext">&nbsp;^value($CodeAltered.format(", "))^</p>

The 'table' is in fact two HTML <div> elements, but if you're not up to speed on current HTML you could use old-scholl <table> elements instead. Some points to note:
  • The first column - the captions - are hard coded. There's no export mechanism to, for example, say 'give me a formatted list of all the key Attributes'. sure, you could read $KeyAttributes and use each but as  difference attributes need different value handling, it's not easy to just index through the KA list and build the table contents on the fly.
  • For cross referencing and explorative learning, the data type and group values link to pages listing attributes of a similar type or group.
  • Boolean true/false values have to be translated into a more human-readable form like Yes or No.
  • Lists like the versions in which an attribute are altered are output as a comma+space formatted listing (in the example page cited this isn't seen as there is only one list item).
  • Minimal HTML is used as the id and class CSS identifiers are used to allow the browser to do most of the layout via CSS.
Note the difference here, compared to $Text and ^text^ export. In the latter TB does all the heavy lift and in all cases except the most complex needs little further user intervention. By contrast, if you wish to draw directly on attribute values, user or system, you generally need to do more manual coding. The latter isn't complex, but TB simply can't guess what every individual user will want.

If you know the sort of output you want (and any transforms you need to make to the source attribute values) but don't know how to effect that, just ask.
Back to top

Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print