We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29635
    • 361 Posts
    Hi all.
    Using @FILE bindings a bit more due to having a few developers and needing to keep things in source control. Wondering if anybody’s ever come up against @FILE bindings not being @INHERITed. If so, any solutions?

    If not, anybody have any thoughts? In the @INHERIT code, it basically skips values if they start with the "@", which makes sense if it’s skipping up the tree past another @INHERIT, but wouldn’t it be useful to not skip other bindings like @FILE (or others, though for what we’re doing only @FILE would matter)?

    On the one hand, I’m assuming there’s a good reason it’s checking just for @ and not @INHERIT, but on the other hand, this is the document parser we’re talking about wink (I’ll be glad to start exploring Revo once we have more time.)
      Need MODx Ecommerce? Try FoxyCart!
      • 29635
      • 361 Posts
      Replying to myself. Changing:
                          if ((string) $tv['value'] !== '' && $tv['value'] { 0 } != '@') {

      to
                          if ((string) $tv['value'] !== '' && !preg_match('%^@INHERIT%', $tv['value'])) {

      seems to do the trick. I’ve only done very quick testing at this point, but ... Just remembers that a lot of people hate regex, and it’s not as fast, so this seems to work too:
                          if ((string) $tv['value'] !== '' && (strpos($tv['value'], '@INHERIT') === false)) {


      Thoughts on that? Anybody see any reasons this would be problematic?

      Second update: While I was in there I thought it’d be nice if @INHERIT allowed something like:
      @INHERIT
      Some extra code to add to the inheritance 
      

      I have it mostly working (with the @FILE bindings too), but I’ll test that more before I share it, since it’s late and I don’t want to look like an idiot wink It does seem to work though, except that the anything extra after the @INHERIT won’t be passed on to descendants. So just the @INHERIT block actually inherits, not any extra stuff.

      I’d love some feedback though. Like I said, it’s late and maybe I’m missing an obvious problem.
        Need MODx Ecommerce? Try FoxyCart!
        • 25663 MODX Staff
        • 12,272 Posts
        Cool. Off to JIRA for you Mr. Florio.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 29635
          • 361 Posts
          http://svn.modxcms.com/jira/browse/MODX-1568
          In case anybody wants that patch before it makes it into the core. Isn’t quite @INHERITPLUS or @INHERIT+ (ticket here), but close. See the ticket for notes on the limitations of extending the inheritance.
            Need MODx Ecommerce? Try FoxyCart!