boboldehampsink / auditlog

DEPRECATED - Audit Log Plugin for Craft CMS
MIT License
39 stars 14 forks source link

Support for field types #3

Closed timkelty closed 9 years ago

timkelty commented 10 years ago

Bob,

Do you have a plan for how to support more field types?

It appears right now only simple text fields are supported (even richtext changes aren't showing for me).

boboldehampsink commented 10 years ago

Yes, this will be coming in the next update. The plugin is far from finished, so far its just a quick plugin put up for fast use and getting feedback.

Met vriendelijke groet,

Bob Olde Hampsink

http://www.itmundi.nl/ iet • moen • die Twents digitaal productiehuis Albergen (HQ) Zandhuisweg 2 7665 SH Albergen Tel. 0546 535000Enschede (The Gallery) Hengelosestraat 500 7521 AN Enschede Kennispark Twente Correcties en/of aanpassingen op uw bestaande website kunt u mailen naar support@itmundi.nl

2014-10-08 19:43 GMT+02:00 Tim Kelty notifications@github.com:

Bob,

Do you have a plan for how to support more field types?

It appears right now only simple text fields are supported (even richtext changes aren't showing for me).

— Reply to this email directly or view it on GitHub https://github.com/boboldehampsink/auditlog/issues/3.

timkelty commented 10 years ago

Yep, I figured!

I made a branch that at least added support for Rich Text fields, and just dumps an array out for other types: https://github.com/timkelty/auditlog/tree/features/fieldtype-handling

I see you already have support for Entries field types. I didn't do anything with Matrix types. They get caught in the instanceof ElementCriteriaModel condition but don't implode quite as nicely.

timkelty commented 10 years ago

Not sure exactly what should be accounted for or not, but after upgrading to 2.2, I'm still getting lots of template errors on the {{ attribute.before }}

Object of class Craft\ElementCriteriaModel could not be converted to string - Matrix Array to string conversion - Rich Text Object of class Craft\SmartMap_AddressModel could not be converted to string - 3rd party field type

boboldehampsink commented 10 years ago

Yeah, they are not supported YET. I've made preparations for easier fieldtype supporting, but haven't tested any matrix or custom fields yet.

Met vriendelijke groet,

Bob Olde Hampsink

http://www.itmundi.nl/ iet • moen • die Twents digitaal productiehuis Albergen (HQ) Zandhuisweg 2 7665 SH Albergen Tel. 0546 535000Enschede (The Gallery) Hengelosestraat 500 7521 AN Enschede Kennispark Twente Correcties en/of aanpassingen op uw bestaande website kunt u mailen naar support@itmundi.nl

2014-10-21 20:50 GMT+02:00 Tim Kelty notifications@github.com:

Not sure exactly what should be accounted for or not, but after upgrading to 2.2, I'm still getting lots of template errors on the {{ attribute.before }}

Object of class Craft\ElementCriteriaModel could not be converted to string

  • Matrix Array to string conversion - Rich Text Object of class Craft\SmartMap_AddressModel could not be converted to string - 3rd party field type

— Reply to this email directly or view it on GitHub https://github.com/boboldehampsink/auditlog/issues/3#issuecomment-59978097 .

timkelty commented 10 years ago

Yep, I just saw your big switch for that. Maybe it would be a good idea to return an empty string if a matching parser isn't found to avoid template errors?

timkelty commented 10 years ago

One way to do this is to pass $entry->getContent()->getAttribute($handle) instead of $entry->$handle, and then remove the ->find() on the $data in parseFieldData

boboldehampsink commented 10 years ago

Doesn’t that only get content attributes, and not standard element attributes, like id, slug etc.

Met vriendelijke groet,

Bob Olde Hampsink

http://www.itmundi.nl/

iet • moen • die Twents digitaal productiehuis

Albergen (HQ) Zandhuisweg 2 7665 SH Albergen Tel. 0546 535000 Enschede (The Gallery) Hengelosestraat 500 7521 AN Enschede Kennispark Twente

Correcties en/of aanpassingen op uw bestaande website kunt u mailen naar support@itmundi.nl mailto:support@itmundi.nl

On 21 Oct 2014, at 21:07, Tim Kelty notifications@github.com wrote:

One way to do this is to pass $entry->getContent()->getAttribute($handle) instead of $entry->$handle, and then remove the ->find() on the $data in parseFieldData

— Reply to this email directly or view it on GitHub https://github.com/boboldehampsink/auditlog/issues/3#issuecomment-59980942.

timkelty commented 10 years ago

I think that's correct, but at that point, aren't you already just looping through content fields? https://github.com/timkelty/auditlog/blob/master/services/AuditLog_EntryService.php#L147

boboldehampsink commented 10 years ago

Mmm yeah lol, will look into it.

Met vriendelijke groet,

Bob Olde Hampsink

http://www.itmundi.nl/

iet • moen • die Twents digitaal productiehuis

Albergen (HQ) Zandhuisweg 2 7665 SH Albergen Tel. 0546 535000 Enschede (The Gallery) Hengelosestraat 500 7521 AN Enschede Kennispark Twente

Correcties en/of aanpassingen op uw bestaande website kunt u mailen naar support@itmundi.nl mailto:support@itmundi.nl

On 22 Oct 2014, at 15:42, Tim Kelty notifications@github.com wrote:

I think that's correct, but at that point, aren't you already just looping through content fields? https://github.com/timkelty/auditlog/blob/master/services/AuditLog_EntryService.php#L147 https://github.com/timkelty/auditlog/blob/master/services/AuditLog_EntryService.php#L147 — Reply to this email directly or view it on GitHub https://github.com/boboldehampsink/auditlog/issues/3#issuecomment-60086019.

boboldehampsink commented 10 years ago

I've added a method that parses objects to string, that should be ok for almost all fields. Could you download 0.2.5 and verify?

boboldehampsink commented 9 years ago

Version 0.2.6 has even better parsing, does this work for you?

timkelty commented 9 years ago

I'll try today! - sorry missed your comment earlier about 0.2.5!

timkelty commented 9 years ago

Tried it out, works great! Thanks for the improvements.