-
-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve elements to allow file and inline bindings #14490
base: 3.x
Are you sure you want to change the base?
Conversation
Thanks @bezumkin for ideas from pdoTools::_loadElement()
I'll need to look at this more closely later, but it looks like this would allow syntax like In 3.x, the |
Disabled this. |
Updated description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo (temlplates) in this path: core/elements/temlplates/.gitignore
Done. |
@mvoevodskiy Thank you for putting in the great work! I think your PR should be rebased because of the big PR that has been merged earlier where all classes where refactored which is causing merge conflicts. Would be great to see this PR merged 👍 |
@mvoevodskiy Any thoughts? Would be great to see this PR merged :) |
Well, I can guarantee that it wont get accepted it if it is not rebased ;) I personally am not 100% sold, but not 100% against either. Probably leaning slightly in favour, but not enough yet to smash that green button. This is one of those things that I don't use often myself, so more user feedback and testers indicating it works the way they'd want it to work would need to bump my confidence in this PR. IMO, this is the type of thing a MAB decision would be useful on to determine consensus, just to make sure it's well considered and people have had a chance to poke holes (so they can be plugged) before it goes to implementation. Code-wise it looks okay. Seems closely related to the automatic static elements introduced in 2.7 which had the same problem of neither Jason nor myself having much plans of using it. :P |
@Mark-H What's not to like about this pull request? We talked with all website makers and this is what everybody needs in their workflow. I think it would be a great improvement enabling MODX developers to work file based. |
You've talked with all the site builders, and everybody wants this in their workflow, really? I know Sterc is all about this sort of things in your workflows, but please don't extrapolate that to the entire community. The fact that I personally don't expect to use this makes your bold claim false ;) I'm not saying that I don't like this PR. All PRs are awesome because they're an opportunity to make MODX better. This one, too. When it comes to new features, I consider it my responsibility as integrator to think ahead and try to determine if it's something that fits MODX strategically. Is a proposal something that will still benefit MODX in 5 years or will we regret having added it (and committing to maintaining it) in the same way everyone hates on ExtJS? What may be unintended side effects, or potential maintenance issues in the future? Is it really something that should be in core, or is it more of a responsibility for extras? Is it the right way to solve a certain problem/use case or can we do better? I suggested it would be a good idea to get wider community consensus on (e.g. MAB) to make a fair decision on wether it's something we want to do and commit to or not. I'll happily put such a strategic decision over my personal preferences. For many PRs I'm comfortable making a decision myself, but for this one I'm unsure as it's just not a part of my typical workflow, unlike other people. Just to state this (again), that does not mean I'm against this PR, it means I'm undecided. That's a very big difference. Often if I'm undecided (and low on the SSOGAF), I just let a PR sit until others discuss it and reach a consensus, but in this case @Ibochkarev specifically asked for my thoughts, and the PR has been open for a while without much discussion about the feature so I figured I'd at least try to address the question for as much as I have made up my mind about it. |
This pull request has been mentioned on MODX Community. There might be relevant details there: https://community.modx.com/t/allowing-file-and-inline-bindings-for-chunks-and-snippets-14490/1496/1 |
I've opened a topic in the MAB board: https://community.modx.com/t/allowing-file-and-inline-bindings-for-chunks-and-snippets-14490/1496.. and apparently @rthrash is a bot now that automatically cross-posts, that's cool :P |
NewsPublisher uses {} tags in the Resource content field to allow it to work with allow_tags_in_post set to false. Standard tags are converted to ]] on load and {{ tags are converted to ]] on save. I don't think the PR creates a problem for NP, but I'm not sure. |
To make a well-argued decision I would like to gather some more pro's and con's.
If you can not create chunks and snippets why would it be good to provide method(s) to bypass this?
How does this file based workflow look like? What are other possible solutions for this problem? In recent projects it would have made my life as a developer easier if I could have used I'm not in favor of the |
I thought about this and try to add some of our thoughts to this.
The reason to bypass it is from a performance-standpoint. So at the start we used Static Elements, so we were finally able to work in our favorite IDE (phpstorm). Then we came to the conclusion that pdoTools/Fenom had a way of using static elements by bypassing the database, which made it perform better. We did some serious benchmarking on this for large websites and pdoTools/Fenom was way faster. So it's not like we're killing chunks/templates/snippets, it's just that they are not in the elements-tree in MODX in our projects, but in an elements folder in the MODX-filesystem.
Exactly the same as you would do with the current Static Elements in MODX, but just without the database entries which reference to your actual static files.
It's a tough call. I'm not entirely sure about where to draw the line. If we protect our users from using this, because we're afraid they will get hacked... I dunno. Can we allow people to make custom snippets? Because they could evaluate user-generated-input there as well. We could disable it by default and have big ass warning message popup to never include user generated content in there. Or we can have the @file to only include text and not other MODX placeholders or code... |
Thanks @gpsietzema for sharing hour thoughts! |
This is now past the feature/breaking change cut-off for alpha1 so pushing further. Shame there's not been discussion from the other MAB members about it. |
This is great PR for working with Git. This is in the kernel of pdotools that many use for phpstorm and Git |
Guys, are there any progress on this PR? Can we add this improvement? |
What does it do?
Added bindings @code, @inline, @file bindings with elements: snippets, chunk. This available for templates and plugins, but it's not callable as "$modx->getChunk() " / "$modx->runSnippet()".
Also, this bindings available in resource content or templates body and other parsible places.
Why is it needed?
This ability do simplier site development because you can not create chunks and snippets in database in all cases.
Also, fixed bug with static elements: now correctly check static file modofication time and if it's more than cache file, cache file will be rewrited.
Small fix PHP notice in modmediasource.class.php.
How works
@FILE
binding@FILE
binding creates temporary static element (chunk, snippet, template). Then static element works as usual.You can use 2 system settings:
If you leave blank both settongs, specify full path for
@FILE
binding from site root.If you fill static_elements_basepath setting, path for
@FILE
binding should be relative from path in setting.How works
@INLINE
for chunksYou can use MODX tags in inline chunks with both:
[[ ... ]]
or{{ ... }}
{{ ... }}
need to support MODX tags in inline chunk when it specified at other chunk or template.Examples
Files
chunks/example.tpl:
snippets/example.php:
PHP
chunks:
snippets:
HTML
chunks:
snippets:
Related issue(s)/PR(s)
#14201
Thanks to @bezumkin
Thanks to @bezumkin and his pdoTools. A part of logic for creating dynamic elements taken from
pdoTools::_loadElement()
.