Script: creating categories of GM entries (PHP)
In its current form, Greymatter (which I use on domesticat.net) cannot file entries into categories, because there is no such variable. The most common workaround is to post under different author names.
However, there isn’t an easy way to sort entries into a list based off of these categories. In fact, when I recently created poetry and recipe pages for cat.net, I had to update the list of entries manually when I added a new entry in that section.When it comes to maintaining domesticat (or geek-chick.net for that matter) my mantra is, “Automation GOOD!” I’d discussed with friends the possibility of creating a “code snippets” page and a “movies” page, but I truly wasn’t interested in doing such a thing if I had to maintain all these pages manually. I am not a coder. If I’m anything, I’m a writer. I want to write, and let the back-end code post, archive, and sort my work.
While looking at Heather’s site, smattering.org, I realized that she was probably manually adding a new line to the list of Friday Five links every time Friday rolled around. I sat there for a few minutes and thought…well, why don’t we just pull all this stuff from the gm-entrylist file and automate it? I hate thinking about this sort of thing, and I’m sure everyone else does too.
The nice thing about this script is that it’s pretty easy to modify; I commented it heavily. You can search for any text string that might show up. So, you could search for posts by a particular author, with a particular text string in the subject, or for just extended (or regular!) entries.
Format the output any way you like. On the recipes and poetry pages, each matching response is dished out in the form of a list item, but you could also make each hit an option in a dropdown list. (This method would be good if you expect to have a lot of results but don’t have a lot of space; it’s how I do my archives page.)
There is a very, very interesting possibility inherent in this script. With a small amount of re-coding, it could be set up to automatically create an “On This Date” script: providing links to entries that you wrote on the same day in previous years. Since date-of-post information is included in the entrylist file, this is completely feasible.
I might just have to do that. I’ve always thought that would be a neat thing to have, but I didn’t want to have to go through the mess of coding such a thing by hand every time I made a post.
If you’re interested in acquiring such a beastie, add a comment to this post and I’ll keep it in mind.
To use the script, download the categories.zip file and get the text file out of it. Edit it to suit your site; there are plenty of comments in there to give you some guidance. I’ve currently got this code pasted into my recipes and poetry pages, but I’d think that you could also call it through an include() function.
Maybe I should create that “code snippets” page after all….
- ‹ previous
- 446 of 1673
- next ›


Post new comment