Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#649 2010-01-25 05:45:21

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: glz_custom_fields

speeke wrote:

No, it’s very clear. I just didn’t see it this time round, and now feel a little stupid :| Thnx!

No no, if you haven’t spotted it first time, it wasn’t obvious enough. Code is poetry and this issue that you had points to a bad “rhyme”, so I’m going to improve it : ).

Alessandro, you’re welcome, waiting for your feedback!

Last edited by gerhard (2010-01-25 19:48:03)

Offline

#650 2010-01-25 17:30:48

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: glz_custom_fields

le Fantastique!

Offline

#651 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

#652 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

#653 2010-01-27 22:12:41

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

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

#654 2010-01-30 09:00:01

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

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

#655 2010-01-30 09:04:34

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

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

#656 2010-01-30 18:11:23

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

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

#657 2010-01-31 10:22:54

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

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

#658 2010-01-31 12:02:29

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

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

#659 2010-01-31 12:11:36

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

Re: glz_custom_fields

aslsw66 wrote:

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).

Are you using smd_calendar? That overcomes the issue by allowing you to specify a custom field (or two) to hold the date of the event, leaving the article’s timestamp alone. When I get round to fixing smd_calendar to allow distinct times as well as dates, this will become even better.

Also it helps with “how can I use article_custom to get a list of articles with the custom field match today’s date?” by employing smd_article_event which is very much like article_custom but can filter using your custom fields, among other things.


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

#660 2010-01-31 13:23:16

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: glz_custom_fields

Are you allowed to “plug” your own plugin in another author’s support thread?!

OK, you’ve got me – I will have a play with the calendar. I take it this means I can use glz_custom_fields to populate the fields, and smd_calendar to use them at the front-end.

I do need to insert times for events, but don’t really need to sort on times – it would be nice for presentation purposes, but we don’t often get more than one event on a day.

Watch out for my questions over on the smd_calendar thread…

Offline

Board footer

Powered by FluxBB