Jump to content

Show parent in text field


jacmaes
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...