Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#661 2010-01-25 17:30:48
Re: glz_custom_fields
le Fantastique!
Offline
#662 2010-01-26 00:54:24
Re: glz_custom_fields
Hi Gerhard,
Just noticed some empty fields in the type
column in your new release, when using smd_prefalizer
. Stef asked me to refer you to this post to help resolve the error messages that are appearing.
Cheers!
“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower
Offline
#663 2010-01-27 12:14:34
- mlarino
- Member
- Registered: 2007-06-29
- Posts: 367
Re: glz_custom_fields
Hi, my left column is full of custom fields, and its really really long, specially when I have a long list of checkboxes.
I wanted to make one of my custome fields (the list of checkboxes) a toggle, just like the other togles in the write tab.
Any clue where can I start looking? I am a little lost here.
Thanks!
Offline
#664 2010-01-27 13:39:09
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: glz_custom_fields
mlarino wrote:
Any clue where can I start looking? I am a little lost here.
If you have a basic jquery knowledge you can easily accomplish this using “bot_write_tab_customize”. Here is a similar case
Offline
#665 2010-01-27 22:12:41
Re: glz_custom_fields
I have successfully used this plugin in to add a specific date and time for events. I didn’t want to use the publishing fields, mainly so I could keep all of the fields relating to article content to the custom fields.
Now I’m struggling to actually use the data. For example, how can I use article_custom to get a list of articles with the custom field match today’s date? Or how can I get a list of articles with the custom fields after today’s date?
Offline
#666 2010-01-29 02:13:51
Re: glz_custom_fields
Hi Gerhard,
I’ve upgraded to your latest release, and I’m still having the same problem I alluded to in a previous post.
I’ve tried deleting the custom field entirely, and then creating a new one of type select
, but I’m getting the output: customfieldname0
where “customfieldname” is the name of my custom field. The database fields are correct, and the pages render correctly. It’s only in the custom field
and write
tabs that the output is incorrect.
“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower
Offline
#667 2010-01-30 09:00:01
Re: glz_custom_fields
aslsw66 wrote:
Now I’m struggling to actually use the data. For example, how can I use article_custom to get a list of articles with the custom field match today’s date? Or how can I get a list of articles with the custom fields after today’s date?
Let me introduce the super awesome smd_if . I’m mentioning it here (bottom headline), on the glz_custom_fields wiki. This is an example where my-date is the custom field and I want all articles which are after today’s date:
<txp:smd_if field="my-date" operator="gt" value="30/01/2010">
<txp:permlink><txp:title /></txp:permlink>
</txp:smd_if>
smd_if is very powerful, refer to plugin’s help for more examples (passing date variable from PHP etc.). As a tip, you need to make sure the date variablle has the same formatting as your custom field’s date format. For the above example, you would want something like:
date('%d/%m/%Y')
Offline
#668 2010-01-30 09:04:34
Re: glz_custom_fields
speeke wrote:
I’ve upgraded to your latest release, and I’m still having the same problem I alluded to in a previous post.
Hmmm, I cannot reproduce this issue. Can you e-mail me a login so that I can take a look?
Offline
#669 2010-01-30 18:11:23
Re: glz_custom_fields
This date comparison is failing for me. I have set up a custom date field (custom field 2 is called “date”) and there is only one article with an entry of “24/01/2010” in this field.
If I use the “equals to” operator, I get nothing:
<txp:smd_if field="date" operator="eq" value="24/01/2010">
If use the “greater than” operator on any value, I get the article returned eg:
<txp:smd_if field="date" operator="gt" value="25/01/2010">
I assume that this is because the custom field’s value is stored as text only, and a comparison operator will try to use the ascii value of the text.
I guess I will have to start playing around with setting the variables to their true types first.
Offline
#670 2010-01-30 21:40:20
Re: glz_custom_fields
gerhard wrote:
Hmmm, I cannot reproduce this issue. Can you e-mail me a login so that I can take a look?
I think I’ve just found the source of the problem. For some reason, the plugin doesn’t like a custom field name
that includes the word “range”. For example, my custom field that’s having this problem is called country_range
and contains values such as: a-b
, c-e
, and so on. If I change the name to anything that doesn’t include the word “range”, all is well.
On a separate matter, I’ve changed the type
preference for all glz_custom_f
events in the txp_prefs
table from 10
to 2
(as per Stef’s suggestion), and all appears to working well. I still see one entry in Admin > Basic Preferences: glz_custom_f
field = migrated
value = 1
. I assume this may be hidden with a value of 2 also?
Last edited by speeke (2010-01-30 21:59:34)
“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower
Offline
#671 2010-01-31 10:22:54
Re: glz_custom_fields
aslsw66 wrote:
I assume that this is because the custom field’s value is stored as text only, and a comparison operator will try to use the ascii value of the text.
Perhaps yes. If they’re both text, a date comparison will probably fail because, for example, 24/01/10 is “greater than” 01/02/10. The best thing to do for date comparisons is to convert them both to a known format; the easiest being the UNIX timestamp. If you happen to have smd_calendar installed you can use smd_cal_now to reformat the custom field to a timestamp (format="%s"
).
For the value
attribute you might have to resort to PHP: value='<txp:php>echo strtotime("24/10/2010")</txp:php>
’
Hope that helps.
Last edited by Bloke (2010-01-31 10:40:14)
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
#672 2010-01-31 12:02:29
Re: glz_custom_fields
I finally figured this out using the following:
<txp:variable name="thisday" value='<txp:php> echo date("d/m/Y");</txp:php>' />
<txp:variable name="hasarticle" value='<txp:article_custom date=''<txp:variable name="thisday" />'' form="today_list" />' />
<txp:if_variable name="hasarticle" value="">
... and then display some content depending on the value
But, after all of that, I realised that this will continue to cause some problems as I try to get article lists based on sorting a custom date field. Is it possible to format the date as a timestamp before it is entered into the database, so that this sort of sorting is supported?
Otherwise, I might have to resort to use the article date (ie. posting in the future). If I can rearrange the admin fields to make the date more obvious and also add a date picker it will be neater. But I do have a fundamental issue with using the article date for a different purpose (ie. the date of an event relates to the content, not the article itself).
Offline