Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Category custom fields
Hi, now I’ve got an idea for a plugin I’m going to try… actually I’ve had it for a while. Article custom fields based on the category. Not sure if you get what I mean straight off the bat so here goes.
Lets say we’ve got two categories.. called.. oh, um Textpattern and Textdrive. Now, what I was thinking of was to make an extension that would allow to create any number of custom fields and assign them to, in this example, those two nice categories. So we’ll make the custom fields: Rating, Users and Version.
Now heres the fun part, this plugin should let you assign the custom fields to categories. So we can assign Rating and Users to Textdrive, as well as Textpattern, but we’ll only assign Version to Textpattern.
Now for even more fun. On the write tab, when we go to advanced preferences by where the custom fields are…we should only see the custom fields based on the category. So if were writing an article in Textpattern category we’d see all the fields, but if we were using the Textdrive category, we’d only see Rating and Users…if you follow, nod your head! good!
So far I can see one setback, you’d have to select the categories before you go over to the custom fields part…I usually select the categories when I’m about to save, but it really shouldn’t be a problem anyway. And then we should be able to use tags to get at whats in those custom fields, standard stuff.
But I don’t know where to begin, well I know where obviously.. Textpattern lol..I know a need some tables..may have to add somemore fields to existing Textpattern tables.. but if anyone wants to help, offer pointers etc it’d be nice :). I haven’t started it yet, or else I’dve linked to the existing plugin code. Definitely going to need help on the admin plugin part.
Thanks alot if you’ve gotten to reading this far down lol. So if you want to help or give a hint, just reply or give me an e-mail at marioparris@gmail.com
Offline
Re: Category custom fields
Well, I’m not savvy enough with the guts of TXP to offer any help, but I can offer some encouragement! I have always felt for the sake of the average user that TXP should work this way by default, to help with more context-sensitive field setups (like e-commerce) etc…
If you can pull this off you are a Golden God!
The ability to make it Section sensitive would probably help too…
( ok, I shutup now and go and learn some PHP ;p )
Last edited by bizartist (2005-08-16 18:53:01)
After enduring years of Art School, mild mannered Owen Waring noticed some unusual changes… the constant bombardment of criticism, it seems, had altered his DNA. Half pixel pusher, half programmer, he had become…. THE BIZARTIST
Offline
Re: Category custom fields
I’ve taken a whack at it today and poked around in the TXP db. The existing custom fields are stored in the prefs table, and the values are stored along with the rest of the article data, so there goes my idea of piggy backing off the existing txp structure, or maybe I’m wrong I don’t know…
And then theres the matter of actually saving the content in custom fields when the article is saved. I’m going to have to find a way to hook on to the article save function without modifying the txp code :s… Takin a break from the comp for a while, I’ll have a go at it again later today
Last edited by marz (2005-08-18 14:33:34)
Offline
Re: Category custom fields
I might have not completely understood what you were proposing but.
You need something to maintain the category -> custom field relationship. You could either extend the current category table or create a new table to store this relationship. You could probably just store the custom fields in a new column as an array in the category table.
In the Write tab you would then need some DOM magic to display or hide the appropriate custom fields depending on what category the user chooses. You could probably hide them by defaults and only make them show up once a category has been selected.
The custom field inputs use the name of the custom field and are in a paragraph so they would be fairly easy to manipulate with the DOM. You would use the data in the relationship table to drive the javascript, probably by just creating a hash of arrays holding the custom field names with the category ID as the key . Attach an onchange event to the category drop downs which would change the display of the custom fields. You could attach an onsubmit event to the form to remove entries in custom fields not appropriate to this category.
It seems that custom field saving is taken care of already since they all get saved no matter what with the article. You could then write a tag that would hook into the relationship table to output the appropriate custom fields on the public side. like <txp:category_custom_fields />
And of course then you need the interface to create the relationships. Not the easiest task but it definitely seems doable.
Shoving is the answer – pusher robot
Offline
Re: Category custom fields
Thanks hakjoon, what you’re proposing is a bit different than the way I was going to do it and seems easier :o) . I did some rough sketches of how I want the plugin to work, and I’m going go with extending the current category table.
I’ll start developing the plugin this coming Monday hopefully since this weekend is my birthday :o) and its all planned out lol. So next week will see more substantial posts on the progress
Last edited by marz (2005-08-19 02:34:32)
Offline
Re: Category custom fields
Just thought I’d do a little cheerleading…
If this works I will literally go find a greasmonkey script or something and change your forum title to “Golden God” on my firefox install.
;)
After enduring years of Art School, mild mannered Owen Waring noticed some unusual changes… the constant bombardment of criticism, it seems, had altered his DNA. Half pixel pusher, half programmer, he had become…. THE BIZARTIST
Offline
Re: Category custom fields
bizartist lol, don’t worship me yet
I’ve just started coding it up… decided to just try manipulating the existing custom fields. I’ll probably add support for adding your own custom fields in a future version. Going away for a week and soon as I get back, classes start, so development will be at snail pace, or hopefully quicker if I can get a free or half day into my course timetable
Offline
Re: Category custom fields
If that’s where you’re looking to start, you might want to take a peak at waz_admin_hide_fields (which is currently broken I think) as a jumping off point. Adding more custom fields to the mix is a definite must for e-commerce applications, but context sensitive display of the existing custom fields is a good beginning
After enduring years of Art School, mild mannered Owen Waring noticed some unusual changes… the constant bombardment of criticism, it seems, had altered his DNA. Half pixel pusher, half programmer, he had become…. THE BIZARTIST
Offline
#9 2006-07-09 20:13:38
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Category custom fields
This is something I could definitely use. Too bad this post is almost a year old :(
Offline
Pages: 1