Help - Search - Members - Calendar
Full Version: Saving Entries In Date-Based Folders
Movable Type Community Forum > Additional Resources > Tips and Tricks
guygizmo
Hi,

I've seen some MT sites where instead of having all entries saved under one folder (e.g. /archives) and each entry has it's unique ID number as the filename (e.g. 000001.php) they've somehow customized MT to save each entry into a different folder according to date (e.g. /2002/12/) and the filename it uses is the first few words of the entry's title. For example, if the entry's title was "Where Are You" it would save the file as "where_are_y.html" or something like that.

Basically, the archiving system MT uses at SixApart.com

How did they do that? I would love to archive my entries in that manner and do away with all references to an unique ID number.
jayant
This is done using "Archive File Template". See the manual, they have what you want as the example smile.gif
urbandyke
Go to blog configuration and then to Archiving. I use the following code in the Archive File Template area, but it of course can be customized to your liking:

CODE
individual/<$MTArchiveDate format="%Y/%m/"$><$MTEntryID pad="1"$>-<$MTEntryTitle dirify="1"$>.html
monthly/<$MTArchiveDate format="%Y/%B.html"$>
category/<$MTArchiveCategory dirify="1"$>.html


That gives me the following for my archives:
individual/2002/02/titleofmypost.html
monthly/2002/02.html
category/nameofmycategory.html

I hope this is what you were asking, otherwise, please specify..
Nortis
This looks quite nice… but?

When I change to this form of archiving. Does MT just create new files in that archive form, ore do MT clean up after the old archive method? (so I don’t have old archives hanging around in my server).

And is there any other catch with changing the archive to this?


Anyway… I’m properly just being paranoid about screwing the whole archive up. ;)
medic119
you need to clean up behind youself.  All the old archives are still there.

When I went to this method of archiving, I deleted all my old archives first, so I wouldn't accidentally delete the wrong ones.


No particular catches.  The MT systems handles this quite nicely.
urbandyke
if you're worried, just export your entries.. so you can import them again, if they get messed up..
bmk
Yeah, deleting the .html files isn't going to hurt anything because you can regenerate them at any time.

(But you should do exports anyway!)
joeszilagyi
Ooh, thank you for this nifty code. I just tried it on my dev blog and the real one, and it worked like a peach!

Thank you!  biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.