Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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

Online

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

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

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

Online

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

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

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

Online

#25 2020-06-24 14:58:38

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

Re: Bibliography management

Bloke wrote #323978:

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?

It should work, but &nbsp; is not trimmed by PHP trim() function. A space would work, or some other symbol (say _) that you can trim with

<txp:link_name trim="_" ... />

Offline

#26 2020-06-24 15:09:49

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

Re: Bibliography management

etc wrote #323979:

A space would work, or some other symbol (say _) that you can trim with

Noted.

I’ll sit tight for the time being. I’ve plenty of other things to do.

Offline

#27 2020-06-24 15:29:59

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

Re: Bibliography management

Oh yeah, sorry, I misread Destry’s post. Didn’t spot that he was using &nbsp;.

For some reason, I thought we had to pass the tag’s output through txp_escape() to get it to benefit? Cool if we don’t and it works now.

So, Destry, does it work if you use a simple space character as the link_name then escape="trim"? Or use a single underscore or some other character that you don’t use in your regular titles, which you can then remove with trim="YourCharacterHere" prior to it being tested to see if it returns anything.


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

Online

#28 2020-06-24 17:04:47

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

Re: Bibliography management

etc wrote #323969:

Any reason why?

Also, I just checked it out. Presumably if we didn’t have at least one required field on the Edit Link panel, then you could just click Add Link->Save, Add Link->Save, … and it’d create you a bunch of unnamed links with no content and no fields set beyond the datestamp. Is that okay?

If there was a way of making sure that at least one of the fields was set then we might be able to get away with making the Name optional. But how would we display that requirement for good UX? And what if someone edits a link and blanks out all the content then Saves it?

I think for those reasons and for the ‘default plainlinks Form’ thing I mentioned earlier, we elected to have the Name required. Not saying it’s set in stone, but I think that’s the reason.

Now, one could argue that if you’re making a link, then the URL should be required. But I’ve just worked on a site where that’s not the case. I’m using Links for the list of people that contributed financially to the site’s cause, and not all of them have a website.

I made entries for them all, used the Sort value field as the name of an image I uploaded to represent the contributor’s logo, used the Title for their company name and a description to say how they contributed/thanks. But if they didn’t have a website, they were displayed on the front end without a clickable link.

Thus we can’t really stipulate that a link should contain a URL, although most of the time it would so it’s probably cleaner to do that than make the name required. Dunno. I can hack around it if this was changed using the same trick as above to put in a space as the URL then trimming it and checking it.


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

Online

#29 2020-06-24 20:51:22

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,841
Website

Re: Bibliography management

I’ve tested the updated plugin now and it should now work ok (a db backup is always a good idea :-)

You can find the multiple field version here.

When you install it, it adds five new custom fields but only shows the ones you actually give a name in the Admin › Preferences (just like the regular article custom fields). If you install it over the earlier version:

  1. Flick it off and on again and it will copy over the custom field data you had into the first custom_field and delete the old legacy column from the db.
  2. Go to Admin › Preferences › Link custom fields and give the first custom field and field name.

Your existing tag should now work again, but you can use name="your_field_name" to specify it explicitly (it defaults to the first field if no name is given).

You can use the wraptag, escape and default attributes from txp 4.8 and there’s also a conditional field, e.g.:

<txp:jcr_link_custom name="your_field" wraptag=" (<+>)" />

will output a space and then the value in brackets if a value has been specified (where <+> is a placeholder for the contents).

You can also do:

<txp:jcr_if_link_custom name="image_id">
    <txp:image id='<txp:jcr_link_custom name="image_id" />' limit="1" />
<txp:else />
    <txp:link_name />
</txp:jcr_if_link_custom>

which will output an image only if there is one, otherwise the link_name, or

<txp:jcr_if_link_custom name="status" value="new">
    <txp:link_name /> <span>NEW!!</span>
</txp:jcr_if_link_custom>

and so on…


TXP Builders – finely-crafted code, design and txp

Offline

#30 2020-06-24 21:59:28

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

Re: Bibliography management

Bloke wrote #323983:

If there was a way of making sure that at least one of the fields was set then we might be able to get away with making the Name optional. But how would we display that requirement for good UX? And what if someone edits a link and blanks out all the content then Saves it?

This looks handled in link_save() function:

    if ($linkname === '' && $url === '' && $description === '') {
        link_list(array(gTxt('link_empty'), E_ERROR));

        return;
    }

UX-wise, we could add a bit of JS to ensure at least one of these fields is set client-side, but it’s probably an overkill. Who would ever want to create an ‘empty’ link?

Offline

Board footer

Powered by FluxBB