jacmaes Posted May 12, 2015 Share Posted May 12, 2015 I have a rather unusual need. I need to have two fields in my template that show the parent and grandparent of the actual page in a plain (readonly) text field. Let me explain. My tree is as such: - State - City - Point of Interest At runtime, it's easy to retrieve the city and state of the point of interest with $page->parent and $page->parent->parent respectively. But what I'd like to have two fields that show the actual output of those queries directly in the editor. For example: City: Hoboken, State: New Jersey. The main reason is that I'm trying to output these two fields in JSON (using Christian's WebServiceTemplate) so that an app developer can grab these results without making two extra calls to the database. A hook would probably do it, but I don't know how to achieve it. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 12, 2015 Share Posted May 12, 2015 Not as unusual of an need: https://processwire.com/talk/topic/9879-fieldtypereference/ Edit: If you need the whole page instead of a field you'd just need to adjust the module by removing the whole "get a field" part. 2 Link to comment Share on other sites More sharing options...
jacmaes Posted May 12, 2015 Author Share Posted May 12, 2015 Nice Benjamin! Great timing (you posted your module last night). Works great, it's exactly what I needed. 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