Welcome, Guest. Please Login
Tinderbox
  News:
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).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Creating a list in the text area (Read 2531 times)
Stephen Hay
Full Member
*
Offline



Posts: 61
Wellington NZ
Creating a list in the text area
Aug 23rd, 2014, 8:14pm
 
Hello,

I have a parent note with 25 children and some grandchildren and I would like to create a note that has for its text a list of the following attributes for all these notes

the $Name of the note
the $PageTitle of the note
the $Description of the note

I don't want aliases included.

I would then like to be able to export this to Excel in three columns $Name, $PageTitle, $Description so that I can check the coherence across the entire set.

Could someone help me with this please?

Many thanks,
Stephen
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Creating a list in the text area
Reply #1 - Aug 24th, 2014, 3:27am
 
First the export bit, for which you'll use two templates in 'envelope and letter' form. The first exports the starting container and the second is called recursively to include each descendant.

If you don't know how to set up export templates I suggest adding any of the built-in ones before proceeding. You own't use the latter but it will set up the necessary prototype/containers for you.

In the following code examples, where you see '{tab}' you should replace it in your actual template code with a Tab character.

Make an template 'Tab-delim wrapper' in the Templates container. Give it this code:
Code:
Name{tab}Page Title{tab}Description
^children("Tab-delim item")^ 


What does this do? It exports a set of 2 tab separated column headers. Then, it tells Tinderbox to add the contents of all the note's children using the template "Tab-delim item". Children only? Yes - the next template solves the extra descendants.

Make an template 'Tab-delim item'. Give it this code:
Code:
^if($IsAlias==false)^^value($Name)^{tab}^value($PageTitle)^{tab}^value($Description)^^if($ChildCount)^
^children("Tab-delim item")^^endIf^^endIf^
 


N.B. a line return after the closing ^endIf^. The template first tests the note being exported is not an alias - if it is nothing happens. If the note isn't an alias, a line is added to the export with the note's $Name, $PageTitle and $Description values separated by tabs. The template then checks to see if the note has children. If it does, each of these is included using the same template. By this method, the export of the starting container adds all descendants.

In HTML inspector, you want to give the container an export extension of '.txt' instead of the default '.html'.

If you don't want to export the whole document, skip the last step. Set up the templates, select the source container for your export then switch its text pane to 'HTML'. Use Cmd+A and Cmd+C to select all the export 'code' (your tab-delim data) and copy it. Open TextEdit, make the new document plain text, and paste in the 'code' from the clipboard. Save the file with a '.txt' extension and you're ready to import the file to Excel Make. Or, you could select a new Excel worksheet, select A1 and the paste the data direct from the clipboard.
Back to top
 
« Last Edit: Aug 24th, 2014, 3:28am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Creating a list in the text area
Reply #2 - Aug 24th, 2014, 3:44am
 
Add a String attribute $ItemDetails to your document. Add a prototype "pItem" to your document. Set all descendants of your container of the 25 notes to use the new prototype. Give the prototype this $Rule:

$ItemDetails = $Name + "\n" + $PageTitle + "\n"  + $Description + "\n"

The "\n" bits simple tell TB to add a line return. Now in the main container set this $Rule:

$Text = collect(descendants,$ItemDetails).format("\n")

The container's text will now be a list of successive sets of lines of Name/Page title/Description with a blank line before the next set.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Stephen Hay
Full Member
*
Offline



Posts: 61
Wellington NZ
Re: Creating a list in the text area
Reply #3 - Aug 24th, 2014, 5:53am
 
Where would I be without you...! Many, many thanks...

As the children already use a prototype, I presume I can just add the Rule to the current Prototypes?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Creating a list in the text area
Reply #4 - Aug 24th, 2014, 7:41am
 
Add to an existing prototype's $Rule? Yes, absolutely.
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