Starterkit: demo content - old bug is back since some time

Please look at https://github.com/getkirby/starterkit/pull/42:
Wrong date field used for projects #42
in file \site\templates\project.php (demo site of starterkit)

[Edit:]
This error is back since some versions, I don’t know why this is changed back, but this is unimportant.
Now Starterkit has only one branch at Github.

1 Like

What exactly is the issue here? The date field issue has been and is currently fixed.

Sorry, not in the zip-download files.

Please look in the file \site\templates\project.php

      <li><b>Year:</b> <time datetime="<?php echo $page->date('c') ?>"><?php echo $page->date('Y', 'year') ?></time></li>

instead of

      <li><b>Year:</b> <time datetime="<?php echo $page->year('c') ?>"><?php echo $page->year('Y') ?></time></li>

Oh, you are right. I thought that the code that is there right now is the fixed version, but it is the broken one.

I have created a pull request.

@lukasbestle:
Thank you very much.

This is not for me, but I think, new users of Kirby need good and correct demo content to understand Kirby.

@lukasbestle:
I am sorry to tell you that https://github.com/getkirby/starterkit/blob/lukasbestle/fix-project-date/site/templates/project.php is wrong.

You need to change like:

-      <li><b>Year:</b> <time datetime="<?php echo $page->date('c') ?>"><?php echo $page->date('Y', 'year') ?></time></li>
+      <li><b>Year:</b> <time datetime="<?php echo $page->year('c') ?>"><?php echo $page->year('Y') ?></time></li>

The used field in the blueprint is year.
$page->date('c', 'year') and $page->date('Y', 'year') do not function as desired and threrefore are wrong
And so we need the code above.
Hint: I use XAMPP on Win10 64bit with PHP/5.4.27.

@anon77445132: You are right, but the reason is not that the field is called year instead of date, but that is does not contain a date of the format yyyy-mm-dd. See the docs

1 Like

Thanks @texnixe, I did not know this yet!

@all:
May be the documentation on this subject (date field: contents, needed PHP code with Kirby default options for not normal order of the three date parts, formats with other languages than English, the date.handlers and its respective PHP code, …) should be improved / be detailed.
The problem at the moment is for me, that the docu is separated at many links, but I do not know one place, where I can find the compendium.

This is no criticism of the documentary but please be understood only as a suggestion!
Look e.g. at the old forum with the articles from @bastianallgeier.

The param in the function code $page->year('c') you posted actually does not do anything at all. It is simply ignored.

I have pushed a fix for my fix (haha) to the PR. Thanks for reporting. :slightly_smiling:

1 Like

[Edit:]
This shows no error:

<time datetime="<?php echo $page->year('c') ?>">

shows

<time datetime=“2013”>

if the field contents is “2013”

[Edit 2:]
I could be:

<time datetime="<?php echo $page->year() ?>">

Yes, it does not show an error, but it does not make sense, because “year” is not a date field. Year is a text field that just contains a string “2013”. However, even it it were a text field with a date like “2014-09-09”, $page->year('c')would work.

1 Like

@texnixe and @lukasbestle:

Yes thanks,

<li><b>Year:</b> <time><?php echo $page->year() ?></time></li>

shows, what is needed without any conversion :slightly_smiling:

but without any

 datetime="2013"

Would not work I guess.

As @texnixe and I said, the 'c' does not do anything at all there. You get the same output without it.

1 Like

Summary:

Yes, your new code works and I think, it is ok and very much butter than the old!

Thank you very much !