Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2020-06-24 12:29:04

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

Re: Bibliography management

Destry wrote #323965:

I still have the problem of not being able to save a link without something in the Title field

Which makes me realize I did do it once (save it when empty), but now I can’t seem to. Txp won’t let me anymore. Odd.

I’ll try a different link and see if I can repeat it.

Nope. Can’t repeat. Maybe I never did it to begin with. Have to put in dummy values, I guess, and not use the Title field.

Last edited by Destry (2020-06-24 12:44:29)

Offline

#14 2020-06-24 12:45:08

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

Re: Bibliography management

Destry wrote #323965:

Because I don’t know WTF I’m doing in tag voodoo.

Happens to us all :)

At its most basic level, evaluate wraps stuff you want to be conditional so it acts as a universal <txp:if_something>...</txp:if_something> tag. It’s just that you put ‘something’ in as the value of the test attribute. i.e. the name of the tag you want to test for “does it return anything”.

So you could make, I dunno, an ‘if_body’ tag equivalent like this:

<txp:article>
   <txp:evaluate test="body">
      <p>Here come da hot body.</p>
      <txp:body escape="trim" />
      <p>Hope you enjoyed it.</p>
   </txp:evaluate>
</txp:article>

And all the stuff inside the evaluate ‘conditional’, including the paragraphs, would only be output if the body contained some text (after it had been trimmed via the escape attribute to remove surrounding newlines and whatever).

I still have the problem of not being able to save a link without something in the Title field

Yeah, the link name is a required field. Does it work if you use a space or nbsp; or something? I think you can use the same name for many links so that might work. You can then just escape="trim" before you output and then test it to ensure that your evaluate/wraptag skips these ‘empty’ entries.


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

#15 2020-06-24 13:11:23

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

Re: Bibliography management

Thanks for the explanation.

Bloke wrote #323967:

At its most basic level, evaluate wraps stuff you want to be conditional so it acts as a universal <txp:if_something>...</txp:if_something> tag.

That would be a good sentence in the opening para of the evaluate tag doc. It doesn’t come through as is.

Does it work if you use a space or nbsp; or something? I think you can use the same name for many links so that might work. You can then just escape="trim".

Nice hack. It does work. Except the surrounding single quotation marks from the evaluation still output.

Looks like for now I’ll have to put both titles and source names in the Description, until I can figure a few more extra free-use fields. Shame to waste a core field like that, though.

Last edited by Destry (2020-06-24 13:13:13)

Offline

#16 2020-06-24 13:24:54

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

Re: Bibliography management

Bloke wrote #323967:

Yeah, the link name is a required field.

Any reason why?

Offline

#17 2020-06-24 13:40:02

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

Re: Bibliography management

I didn’t expect this to work, but I’m glad to find it does since I’m guessing the use of wraptag="" would not work in a plugin tag. ;)

<txp:evaluate test="jcr_link_custom"><txp:jcr_link_custom />, </txp:evaluate>

Now I need to make some more of those plugin fields.

Offline

#18 2020-06-24 13:42:43

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Bibliography management

Destry wrote #323962:

Making me think an extension of the jcr_link_custom plugin might be worthwhile, but I could explore that on a more personalized basis if JCR didn’t mind me calling the result dry_bib ;) Otherwise, an extension of jcr_link_custom for an additional 3 to 5 generic free-use fields could be handy.

I did actually update it yesterday to the 5 custom field variant but I haven’t had the chance to test it out yet, because I need to build a little test case for it. – you can find it in on GitHub. If you want to try it out, you can, but make a backup of your DB first, because it attempts to migrate from the previous custom_field setup on enabling the plugin. Also, I’m not as skilled as most plugin authors, though it borrows heavily on a plugin template that Robert (wet) made.

You can set up to five custom fields in the Admin › prefs with a name of your choosing (works much like the regular custom fields). Those you don’t set, don’t show. If you want, you can also give them a display name for the links tab by specifying your own language strings for them (see the docs).

It also includes a jcr_if_custom_field tag, including checking against a value, and the plugin can use the newer 4.7/4.8 escape and wraptag tags.

BTW I: If you already have some data you think I could test against, maybe we can get there more quickly? Mail me if you think we might get there more quickly that way.

BTW II: the earlier single custom field variant did have the tag registry already in it, so I’m not quite sure why you saw the error.

EDIT: updated GitHub links.


TXP Builders – finely-crafted code, design and txp

Offline

#19 2020-06-24 13:43:25

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

Re: Bibliography management

Destry wrote #323970:

I’m guessing the use of wraptag="" would not work in a plugin tag. ;)

It would, unless the plugin treats wraptag in its own way.

Offline

#20 2020-06-24 13:48:18

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

Re: Bibliography management

Destry wrote #323962:

And that works, but only when a Title value exists. If not, Txp outputs a single quotation mark even if the field is empty. I’m guessing it’s because it is a required field that is being negotiated in the snippet, but I’m not sure what can be done, if anything.

using a variable solves that.


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

Offline

#21 2020-06-24 14:06:33

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

Re: Bibliography management

etc wrote #323969:

Any reason why?

Dunno. Presumably because the ‘essential’ default form that handles <txp:linklist/> uses it? Nothing to stop us outputting “undefined” I guess like we do with files.


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

#22 2020-06-24 14:13:36

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

Re: Bibliography management

Destry wrote #323968:

That would be a good sentence in the opening para of the evaluate tag doc. It doesn’t come through as is.

Will do.

Nice hack. It does work. Except the surrounding single quotation marks from the evaluation still output.

Even when both quotes are inside the evaluate? Or in the wraptag?


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

#23 2020-06-24 14:37:23

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

Re: Bibliography management

Bloke wrote #323976:

Even when both quotes are inside the evaluate? Or in the wraptag?

I was using this in the field, &nbsp;, and this in the form:

<txp:linklist wraptag="ol" class="biblio" break="li">
<txp:evaluate test="jcr_link_custom"><txp:jcr_link_custom />, </txp:evaluate>
<txp:link_name wraptag="&#x2018<+>&#x2019, " escape="trim" />
<txp:link_description escape="tidy, textile" />, 
<txp:link_url wraptag="<+>, " />
accessed <txp:link_date wraptag="<+>." />
</txp:linklist>

Was outputting ‘ ’ for link_name.

I’ve moved on to putting the titles back in the Description, though, and would rather not backpedal again just for that hack unless a patch shortly emerges for this…

Nothing to stop us outputting “undefined” I guess like we do with files.

I guess then the next Txp update wouldn’t break the patch?

Last edited by Destry (2020-06-24 14:38:24)

Offline

#24 2020-06-24 14:46:25

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

Re: Bibliography management

Dammit, sorry. <txp:link_name> doesn’t use global escape, so trim doesn’t work. Oleg: Is it easy to retrofit without breaking backwards compatibilty in 4.8.2?


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

Board footer

Powered by FluxBB