chrizz Posted May 13, 2019 Share Posted May 13, 2019 I was wondering if there's a PW-way to store a WireArray permanently in a field and restore the WireArray whenever needed. Currently I can only think of (un)serialize or getArray() and then storing the array as JSON. It there's no better way - fine. If there is something more PW-related, I'd be happy if you share it ? Thanks! Link to comment Share on other sites More sharing options...
elabx Posted May 13, 2019 Share Posted May 13, 2019 What about $cache? I don't think it saves WireArrays but it can handle normal arrays and PageArrays if that works. https://processwire.com/api/ref/wire-cache/save/ Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 15, 2019 Share Posted May 15, 2019 For any kind of non-php based storage (a.k.a. any long lived one) you need to serialize the data somehow. The simplest and most dangerous is php's serialize, json is an option or implementing a custom fieldtype, which is probably the most work depending on what you're actually storing in the wirearray. On 5/13/2019 at 10:30 PM, elabx said: … but it can handle normal arrays and PageArrays if that works. Afaik it handles PageArrays by only storing the page ids and recreating the PageArray on load. 1 Link to comment Share on other sites More sharing options...
chrizz Posted May 15, 2019 Author Share Posted May 15, 2019 thanks for your input. I think serializing is the way to go for now. The closest pw-way would be probably to create new templates holding all the data, but for now this would be overkill ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now