Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-09-17 13:25:05

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

A dynamic piece of text conditional to Textile endnotes

I’m thinking I might like to be pretentious and add a ‘Fin’ to the ends of my articles automatically, old storybook or film noir style. But if there are endnotes, which there often are but not always, the Fin should come before the endnotes section.

I can add the desired text string to the main article form, but then if endnotes are used on the article, the string is added at end of endnotes, which is not desirable. Because Textile endnotes are added to the end of the article body, I don’t know how to make this a conditional thing that can work automatically.

Sure, I could try to remember to add the text manually in the body in the desired position (and even if I forget it’s not a big deal), but as I was thinking about this (and couldn’t figure it), I’ve become curious if there is even way.

Offline

#2 2018-09-17 13:34:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: A dynamic piece of text conditional to Textile endnotes

With a line of JavaScript or two you could target the class of the endnotes section and inject the text just above it in its own <p> tag or something. Not sure if there’s anything more elegant offhand.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2018-09-17 13:40:48

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: A dynamic piece of text conditional to Textile endnotes

That makes sense from the endnotes side, I guess, but what if an article doesn’t use endnotes? How might I make that conditional?

Offline

#4 2018-09-17 13:41:59

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: A dynamic piece of text conditional to Textile endnotes

Don’t stress about this silly situation. It’s just a puzzle for puzzle lovers. ;)

I will add the string manually for now. It only works well on long-form pieces anyway.

Offline

#5 2018-09-17 13:49:01

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: A dynamic piece of text conditional to Textile endnotes

A bit intrusive, but you could create a form called, say, backlinks, like

<p>THAT'S ALL FOLKS!</p>
<txp:yield />

and use it in the body of the article to output the footnotes:

<txp::backlinks>

notelist:¶.

note#0. One

note#1. Two

</txp::backlinks>

Offline

#6 2018-09-17 14:34:40

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: A dynamic piece of text conditional to Textile endnotes

Wow, that’s a little trippy. O_o

So that’s essentially a Txp way of doing what Bloke was just suggesting. It still doesn’t address if there are no endnotes (i.e. a conditional factor), but forget that. This method you show has me curious about something different now…

Your method as shown wouldn’t work for me exactly as shown because I use other elements above/below my endnotes markup:

  <txp:hide> EVERYTHING BELOW HERE IS ENDNOTES. DON'T MESS IT UP </txp:hide>
  <section class="endnotes">
  <hr>

  <h1>Endnotes</h1>

  [Endnotes markup here]

  </section>

I use the wrapping section to target all my complex styling for notes

But your idea makes me realize how much cleaner the bottom of my articles would be if I put this in a form called endnotes:

  <p class="fin">Fin
  <section class="endnotes">
  <hr>

  <h1>Endnotes</h1>
  <txp:yield />

And then only this would need to go in the article body:

  <txp::endnotes>

notelist(endnotes):‡.

note#book. First Last, 'Title of piece', __Name or Title of Source__ (City: Publisher, YYYY) page number(s). %(annotation)[Author comments here]%

note#blogpost. First Last, ‘Title of blog post, Blog Name blog, dd Month yyyy, full url.

  </txp::endnotes>
  </section>

A nice replace of all multiple leading lines for just one.

There’s just that stray closing </section> tag, which is unfortunate but not a deal breaker.

Offline

#7 2018-09-17 14:39:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: A dynamic piece of text conditional to Textile endnotes

You can put the closing </section> in your Form below the <txp:yield /> tag.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2018-09-17 14:41:27

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: A dynamic piece of text conditional to Textile endnotes

Haha… Nice! Done deal.

Thanks guys. I’m starting to finally understand the yield tag. ;)

Offline

#9 2018-09-17 15:09:11

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: A dynamic piece of text conditional to Textile endnotes

Destry wrote #314095:

It still doesn’t address if there are no endnotes (i.e. a conditional factor)

You could append <p class="fin">Fin</p> (I prefer them closed) also after <txp:body /> of your article form, and hide it if there are endnotes:

p.fin ~ p.fin {display: none}

Offline

#10 2018-09-18 01:54:18

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: A dynamic piece of text conditional to Textile endnotes

etc wrote #314098:

You could append <p class="fin">Fin</p> (I prefer them closed) also after <txp:body /> of your article form, and hide it if there are endnotes:

p.fin ~ p.fin {display: none}...

Or being TXP-ish, yu could use a custom field, a simple set of radios (name: has_endnotes, value yes/no, then wrap your <p class="fin">Fin</p> in a <txp:if custom_field />@ block. You need the remember to toggle the state of the custom field as appropriate, though.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#11 2018-09-18 09:52:53

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: A dynamic piece of text conditional to Textile endnotes

phiw13 wrote #314100:

. . . could use a custom field, a simple set of radios (name: has_endnotes, value yes/no, then wrap your <p class="fin">Fin</p> in a <txp:if custom_field />@ block. You need the remember to toggle the state of the custom field as appropriate, though.

This is exactly how I was trying to think about it originally, as a yes/no custom field. But I couldn’t muster it. :{

Can you elaborate on the radio buttons? Another plugin is needed?

At any rate, I think I’m happy at this point with what’s achieved so far. After further reflection, it might be good to decide on an article by article basis for articles sans endnotes whether I want to use the finito or not, and add it manually if so. That gives allowance for the occasional shorter articles that don’t need such a thing. Much longer pieces, typified by having endnotes, would always get one though, so it’s nice having it there in that case and easily dropped from all of them if I ever want to do that.

Offline

#12 2018-09-18 10:47:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: A dynamic piece of text conditional to Textile endnotes

Destry wrote #314104:

This is exactly how I was trying to think about it originally, as a yes/no custom field. But I couldn’t muster it. :{

Can you elaborate on the radio buttons? Another plugin is needed?

At any rate, I think I’m happy at this point with what’s achieved so far. After further reflection, it might be good to decide on an article by article basis for articles sans endnotes whether I want to use the finito or not, and add it manually if so. That gives allowance for the occasional shorter articles that don’t need such a thing. Much longer pieces, typified by having endnotes, would always get one though, so it’s nice having it there in that case and easily dropped from all of them if I ever want to do that.

This is the no plugin version…

Create a custom filed and name it fin. The custom field will/should appear in the write tab.
Depending on weather you call the articles from a form or a page add.

<txp:article>
<txp:body />
<txp:if_custom_field name="fin">
<p><i>Fin</i></p>
</txp:if_custom_field>
</txp:article>

The above will execute only if the fin custom field is populated, no matter what you populate it with.

> Edited to add that there might be a more efficient way using the new evaluate tag… but I’m yet to experiment with it.

Last edited by colak (2018-09-18 11:44:54)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB