ludovicchabant/PieCrust — Issue #7: Possibility to use post_url without some placeholders
Author: tomaz
Created: 2011-10-25 09:02:03+00:00
State: open

Docs state that `post_url` must use all placeholders, but I'd like to keep post URLs in format `%year%/%month%/%slug%` - without day. This would make my PieCrust site compatible with existing WordPress site, so stuff like cross references and transferring comments to disqus would work (I think they require same URL).

If I remove %day% from post_url, I get this error when loading post page:

Notice: Undefined index: day in _piecrust/src/PieCrust/IO/YearFileSystem.php on line 78
Notice: Undefined index: day in _piecrust/src/PieCrust/Util/UriParser.php on line 113

I *think* I understand what's going on, tried few attempts but didn't figure it out fully yet. Have fixed UriParser which seems to work using optional components and reverting to 0 for those not present. From what I see, the issue is within `UriParser::tryParsePostUri` when it asks file system `getPath`, passing it insufficient data (i.e. day missing).

So from what I understand, the code should actually go ahead and try figure out the path with missing components. This could either be done by brute force - searching file system, or using additional array keys while parsing posts in `getPostFiles` in `FileSystem` subclass - my question is the info returned from `getPostFiles` persistent throughout app lifetime - is it the same info passed to `UriParser::parseUri` eventually? Probably path to source markdown file is required at this point as it's not yet been rendered?

Any suggestions?