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
HTML export only as include (Read 3686 times)
Pat Maddox
Full Member
*
Offline



Posts: 66

HTML export only as include
Feb 11th, 2016, 1:18pm
 
I came across the tbref for HTML export only as include and thought it would do what I want, but I'm not having any luck...

I have a TB doc with the following structure (each line is a note):

Code:
* Articles
** 2016
*** first article
*** second article
** 2015
*** another article
*** yet another article
 



I want my Articles page to render a heading for each year, and then link to the articles from that year.

The article note body includes:

Code:
^children(/Templates/year)^
 



and my year template is:

Code:
^setRoot(/)^## ^title^

^childLinks("", "* ", "\n", "\n")^
 



With default settings, everything works – BUT Tinderbox exports an HTML file for each year, which I don't want. The year notes are simply a way to organize my articles, and should show up in the article list but should not have their own HTML files.

I've unchecked $HTMLDisableChildren on the articles note, and now it doesn't export my articles (which are children of the year notes).

I've checked HTMLDontExport on the year notes, and now the year and its articles don't show up in the articles list.

I don't see any boxes in the top left corner of the HTML view that I can check or uncheck. It's just the HTML output.

I want my articles page to render a heading for each contained year note, with each year rendering links to its articles. I want the articles to have their own pages, and the years NOT to have their own pages.

What do I do?
Back to top
 
 
  IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: HTML export only as include
Reply #1 - Feb 11th, 2016, 1:39pm
 
Okay I figured it out. I made an empty template that has nothing in the note body. All my notes are $HTMLDontExport = false and $HTMLExportChildren = true. Then for the year container notes I set their HTMLExportTemplate to /templates/blank and because of that Tinderbox doesn't export an HTML file for them.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: HTML export only as include
Reply #2 - Feb 11th, 2016, 2:16pm
 
Edit - corrected references to using a recusring template

Before going to specifics, bear in mind that the default assumption when exporting a TBX to HTML (and assuming at least one template is defined in the doc!) is that every note will export as a discrete page in a set of folders mirroring the TBX's outline. Any departure from that may involve a bit of planning.

Your problem arises because you're using a template which needs to evaluate the grandchild data (which you want) in the context of a child which you don't!). At the same time you don't want outline depth 2 notes (year containers) to export any HTML but you do want their children to report pages.

When you set the 'year' container to not export, the individual articles still export OK as per-page files. The root 'Articles' page also exports but without the included content (i.e. via ^children^). This is because it has no children that export and thus no context within which to evaluate the ^childLinks^ to grand-child notes.

All is not lost. There is a simple trick to resolve this. We know the year containers must export a page for the cascade to work. It is also the case that if the result of a template is nothing, no page is generated. Thus we add a new template 'blank', with no code at all (including deleting the HTML comment if using the built-in template prototype). We leave the year container notes exporting (the 'export' box remains ticked in the Inspector). Now all works - even if the year notes have text, etc. This is because, when run through the 'blank' template there is no output. At the same time, because the year notes export the recursing template works.

The above doesn't use any new feature and should be fine in v6.x. Disclosure: I'm using the latest beta but in this context it equates to v6.4.0.
Back to top
 
« Last Edit: Feb 11th, 2016, 3:11pm by Mark Anderson »  

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



Posts: 66

Re: HTML export only as include
Reply #3 - Feb 11th, 2016, 2:24pm
 
I'm not using a recursing template... but in any case, yes, a blank export template does the trick Smiley
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: HTML export only as include
Reply #4 - Feb 11th, 2016, 3:06pm
 
Indeed, you're not, I'll amend my last post.

Edit: done! For clarity the code actually tested for my original post was as described now.
Back to top
 
« Last Edit: Feb 11th, 2016, 3:12pm by Mark Anderson »  

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



Posts: 66

Re: HTML export only as include
Reply #5 - Feb 15th, 2016, 1:09pm
 
here's something weird... if I set a prototype (because I want to give these settings to multiple notes) then it exports the template with a file content of "\n" (a single newline character) even though the template is blank.

edit: my ExportCommand was printing out the newline. I've changed these directories to not have an ExportCommand anymore, and it doesn't create files.

But I have other notes that need to run through an ExportCommand and not generate a file (they're page sections). I think that's probably a bug that I'll email to support...
Back to top
 
« Last Edit: Feb 15th, 2016, 1:29pm by Pat Maddox »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: HTML export only as include
Reply #6 - Feb 15th, 2016, 1:23pm
 
Is the template really blank? It might contain a line return that is being exported. The blank concept above assumes $Text is completely empty. In my tests nothing was created, even though the year containers deliberately had test text. Given the latter, stray non-printing characters in the template seem a plausible cause. It might be something else but I'd check there first.
Back to top
 
 

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



Posts: 66

Re: HTML export only as include
Reply #7 - Feb 15th, 2016, 1:30pm
 
yeah it's really blank. I edited my post... I think Tinderbox is creating a file if there's an ExportCommand, even if the ExportCommand doesn't return anything (aka a 0-byte string).
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: HTML export only as include
Reply #8 - Feb 15th, 2016, 3:05pm
 
Your analysis makes sense. As there's no defined behaviour for this, it's currently an edge case though I'd agree with you that it makes sense that the command not run if there is no template output - to avoid just this sort of unforseeable byproduct.

I don't know if you're using prototypes, but it would make sense in this context (though you may need to reset some attributes currently manually assigned per note). Thus you'd have a prototype for 'year' notes with a the blank template and no export command, a different one for articles with the command, etc.
Back to top
 
 

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



Posts: 66

Re: HTML export only as include
Reply #9 - Feb 15th, 2016, 3:15pm
 
ah cool. Yeah I have a prototype that was setting the blank template... but I had to override the HTMLExportCommand too.

This still works because the HTML gets included into the main page, and that whole thing gets run through the HTMLExportCommand.

Thanks for the suggestion!

And in retrospect, it's blatantly obvious that when I have a blank HTMLExportTemplate, I don't need to run it through the command anyway...

p.s. I only post all this stuff because Tinderbox is getting more and more central to my workflow... Smiley  99% of the stuff I do works great and Tinderbox is the only tool that could do it - it's the 1% that I need help with!
Back to top
 
« Last Edit: Feb 15th, 2016, 3:17pm by Pat Maddox »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: HTML export only as include
Reply #10 - Feb 15th, 2016, 4:19pm
 
Glad to hear you're getting traction. The deeper you delve into Tinderbox workflows, the greater the degree of 'some assembly required'. However, most of the stuff to figure out doesn't change, so when done you can have some really complex processes that 'just work' (...even if it seems unlikely en route). It took me a while to really get prototypes; now I use them whenever I can as they're such time savers.
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