[Radiant] Working through an Extension
Mohit Sindhwani
tech at onghu.com
Sat Aug 4 11:27:36 CDT 2007
Thanks Sean.
>> Basically, I have an after_save filter that gets called when you try
>> to save the page. All I need to figure out now is how to get the
>> page ID of the record that was just saved, and more importantly, the
>> parameters that were entered into the partial added to the new and
>> edit page.
>>
> You're on the right track.
That's good to know. :)
> It's easiest if the model is associated with Page, then you can just
> push the new objects into the association collection and not worry
> about the page id. Otherwise, it's available via self.id inside that
> callback. Add an attr_accessor with some variable-name that you check
> in the after_save callback... it'll just be a hash with the attributes
> passed into the form, which you can pass on to your associated model.
Ah, the attr_accessor - I just noticed that that was the part I had
commented out from your extension. I think once I put that in, I should
probably be able to get the string that my user entered.
>> If I understand it correctly, the PageAttachments uses AJAX for
>> uploading files to a temporary location and then saves them in the
>> after_save filter by iterating through an array that is populated
>> with the names of the files that were uploaded. I don't need
>> something that complex (and I'd prefer not to use AJAX), so I'm
>> wondering how to access the text field! (Let's say I have a text
>> field called 'property' that I would like to add). I know that this
>> may be a Rails issue (rather than specific to Radiant), but I'm
>> hoping someone can point me in the correct direction with this.
> PageAttachments uses the magic of attachment_fu to do the file
> handling. There's no Ajax, but there's some client-side Javascript to
> add and remove elements from the page.
I just looked at the JS files and assumed it was Ajax - my bad.
> Let me know if there's anything else I can do to help!
Teach me to fish! :) The ability to add extensions is useful - I'd like
to learn. But, seriously, thanks for pointing me in the correct
direction. I'm sure I'll probably (that sounds strange) come back with
a few more questions in the next few days (hours?). I think it's time
to get a copy of 'Ruby for Rails' and read up on meta-programing :)
Cheers,
Mohit.
8/5/2007 | 12:25 AM.
More information about the Radiant
mailing list