In my previous post, MODX (at) Bindings, @EVAL I took a look at MODx Bindings and I promised a series of posts on each of the five types of data source bindings available to all template variables.
I thought it was really interesting that this week in my comments section for Create a Dynamic CSS File in MODx the topic of @INHERIT came up.
As it states on the MODx SVN:
The @INHERIT binding will automatically find the value of the parent Resource and use that as its value. If the parent Resource also has @INHERIT, it will look at that parent’s parent’s value, and so forth. If it ends up at the root and no value has been specified, the value will be 0.
Example
I am currently building a site that has different header images depending on which section of the site you are located. To make this happen I created a text Template Variable (TV) and set the Default Value to @INHERIT. Next, a TV call is placed in the appropriate location of my HTML [*myTV*]. I then set a different image pathway into the TV of each of the first level container documents. At this stage of the game each of my site sections now possesses a unique header image which is being inherited from the ultimate parent of each section.
Now, let’s say I want a solitary header image on my Directions page which is located deep in my Contact Us section. I just go down to that page and it’s TV and enter the new pathway to my Directions image. Now, this page will have it’s own, unique header image.
The function of this binding is pretty straightforward, but it can be very useful. What I have found is that it tends to offer a straightforward approach for meeting design requirements that would otherwise require more complex solutions.



