I’m trying to parse resources with Templates, Chunks, Snippets, TV’s, I&O filters and all in the backend. I’m getting stuck on the I&O filter parsing with a simple link generation [[~[[*id]]]]. It gets the [[~23]] but when it goes into the context specific settings it fails, since the manager context and culture have been loaded.
Anybody got an idea how I can accomplish this? This is part of an extensive newsletter component with many, many features. To put it simple, this is the biggest feature which all other features are built on.
Thanks in advance!
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.
-
MODX Staff
- 730 Posts
I would start by experimenting with $modx->switchContext() and see what happens (then switch back to mgr context after processing). It could get interesting if there are permissions involved on the resources/elements you’re processing

Another technique would be to grab the output of a Resource "externally" by grabbing it through cURL. You’d only be seeing the Resource with Anonymous permissions of course.
I’m sure there’s some other/better advice lurking out there!
switchContext might be a great solution. Rights aren’t really that important with the newsletters, unless you’re mailing to a group that has been restricted by access controls (which will also be a feature). The basic idea is to get it working and I’ll take it from there.
cURL would do the same as a anonymous user, so that’s kinda the same IF swichContext works.
I’m gonna give it all a go in the morning! Thanks Mike!
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.
-
☆ A M B ☆
- 3,141 Posts
Hehe, thanks but I already got that part working. Using process from modResource and processElementTags from modParser.
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.
-
☆ A M B ☆
- 3,141 Posts
So what does modResource::process do? Just process cached element tags, and then running processElementTags on it will also process anything uncached, or?
Sorry for hijacking this thread a bit, but it’d be interesting to learn how you are dealing with this
It simply processes the current resource. It builts it, as far as I can tell, using the resource and thus parses placeholders from TV’s as well, but as far as that goes, nothing more. There is another function, processElementTags, which takes up all the special tags like ~ and *. I’m gonna try the switchContext today, hopefuly that works. cuRL is a good alternative, but overkill for what I am trying to do. If I am correct, my problem is simply context based.
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.
Meh, switchContext doesn’t do anything. It currently stops at checking the policy for the loaded context. Strangely, ’load’ is not avaiable in the mgr context?
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.
-
MODX Staff
- 10,725 Posts
As I have said before, you cannot just parse a Resource with a single API call in MODX. MODX processing is a fairly complex request/response cycle with various activities beyond just calling modResource->process(). modRequest and modResponse abstract and implement these activities. Loading the right context is essential, but that is just the beginning of the whole cycle.
I totally get that that’s only the beginning. I have got it working now somewhat, trying to extend functionality to see if I come across some more landmines. ;-)
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.