Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-06-24 12:11:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,792
Website

Re: Bibliography management

Destry wrote #323962:

that works, but only when a Title value exists. If not, Txp outputs a single quotation mark even if the field is empty.

Uhhh, shouldn’t you put the opening quotation mark inside the conditional (<txp:evaluate>)?

<txp:evaluate test="link_name">&#x2018<txp:link_name escape="tidy, textile" />&#x2019, </txp:evaluate>

EDIT: too slow, and I forgot about wraptag’s superpowers! Do what etc suggests.

Last edited by Bloke (2020-06-24 12:13:01)


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

#12 2020-06-24 12:20:01

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

Re: Bibliography management

etc wrote #323963:

Why do you put the opening mark outside evaluate?

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

But, this, wraptag="&#x2018<+>&#x2019, ", does help me finally understand at least one way <+> can be used. Thanks. ;)

However, I still have the problem of not being able to save a link without something in the Title field, and as I was saying above, I won’t always need a title value, only on a conditional basis.

Last edited by Destry (2020-06-24 12:22:03)

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,473
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: 9,792
Website

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,473
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: 3,940
Website

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,473
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: 3,946
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 the multiple fields branch already pre-compiled. If you want to try it out, you can, but please, please, please 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.


TXP Builders – finely-crafted code, design and txp

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 3,940
Website

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: 8,297
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB