Numbers being stripped from folder names

I’m setting up my first Kirby environment and I’m having a strange problem.

I’ve set up a folder called 1-words, and inside I want to put in dated articles so, as a test, I put in the following subfolders:

  • 20151207-lorem-ipsum-dolor-sit-amet
  • 20151208-consectetuer-adipsicing

So far so good but, when I refresh my home page, the date strings get removed from the folder names, making them invisible, like this:

  • -lorem-ipsum-dolor-sit-amet
  • -consectetuer-adipsicing

It does this with just a single digit number, and it does it if I’m not even referencing those folders in my code. But if definitely happens when I hit Cmd-R in my browser.

Your help would be gratefully received. I’m on Mac OS X (El Cap), PHP 5.5.30.

Not quite sure I understand your problem correctly, but are your blueprint settings correct? Do you manually assign those folder names? Pls checkout yesterday’s thread which I think might be the same issue: Kirby overwrites dates in blog article titles for chronological ordering

Yeah, thanks. Seems there’s a chunk of stuff I didn’t do because I didn’t RTFM :wink:

It works now. Thanks for your help.

EDIT: it worked in that it automatically suffixed the folder name with the correct date, but it’s then deleting that suffix when I refresh the home page. I can’t think what I’ve (not) done that would cause that to happen.

Here’s a video that shows what’s happening (forgive a lack of commentary - the washing machine is on :wink:

https://dl.dropboxusercontent.com/u/71603976/Kirby.mp4

This looks a bit weird. Could you pls. post the blueprint of the parent page of the page you have created and the words.php blueprint?

Hm. Generally the Kirby core shouldn’t ever modify pages if you don’t tell it to do so. Since the issue appears when reloading the frontend home page, that’s very weird. Does it also happen with the starterkit?

It doesn’t seem to happen with the starter kit.

Here’s the blueprint for the list page:

`<?php if(!defined('KIRBY')) exit ?>

 title: Article list
pages:
  template: words
  num: date
files: false
fields:
  title:
    label: Title
    type:  text
  text:
    label: Text
    type:  textarea`

…and for the Words template:

`<?php if(!defined('KIRBY')) exit ?>

title: Words
pages:
  num:
    mode: date
    field: added
  sortable: true
files:
  sortable: true
fields:
  date:
    label: Date
    type: date
    default: today
    override: true
  title:
    label: Title
    type:  text
  text:
    label: Text
    type:  textarea
  tags:
    label: Tags
    type:  tags`

Hope this helps.

The thing that struck me is the fact that when you change visibility, you get a list of numbers instead just the question if you want to change the visibility. With date based numbering there is no possibility to choose the position of the number, as this happens automatically by date.

Therefore, pls. check that the filename of the list page blueprint is the same as the name of the list page text file, i.e. if the text fiel is called “list.txt” the blueprint must be called “list.php” for the stuff to work.

Also since the automatic renaming happens on the frontend, the blueprints don’t matter there, which is very strange. Are you using the page write methods (create(), update() and so on) anywhere in your templates?

Not to my knowledge. As I’m a n00b, I’m basing my code on Starterkit.

Have you checked the filenames?

Yeah. Here’re the two folders for you to see:

OK, I think I know where the problem was. I started again from scratch, set up my blueprints properly, then imported my original templates back in a bit at a time. Looks like I was trying to do a sortBy() on my pages, which was changing the folder names.

I need to find an alternative way to display the latest-dated article.

Thanks for your help Texnixe and Lucasbestle.

Hm…
Could you please post the code you had? Maybe that helps to find a bug in Kirby and also to find a solution for what you want to achieve.

You can sort your articles with $articles->sortBy('date', 'desc'), that should work and not generate an error.

And if you want to get the latest article only, you can use this:

$articles->sortBy('date', 'desc')->first();

(read: Sort in descending order (latest is first), return first item)