I think I am finding a pecuilar behavior of either regClient.. APIs and/or Articles container folder.
Let me try to elaborate.
Let's say I have a snippet that calls one of those regClient APIs. For the simplicity sake, let's say I have this snippet called addCSSnJS
$modx->regClientCSS($csssrc);
$modx->regClientScript($jssrc);
and, in Summary field of an article, I add the following
[[!addCSSnJS? csssrc=`[[~100]]` & jssrc=`[[~101]]`]]
The individual page works as expected. That is, the target CSS is linked in a resulting HTTP <head> section and the target JavaScript source link is added at the near bottom of <body> section.
In the article container page (where those articles are aggregated) however, something strange happens. when loaded the first time, both Javascript and CSS links are there. However, upon reloading the page (that is, you either click refresh on browser or navigate out and come back to this page) both links are gone from the HTML output.
I thought about this, and concluded adding CSS of each article in the aggregated page is probably not a good idea anyway, unless each article summary requires a same CSS, and in this case, I must have placed this call in a wrong place. So I ended up adding this to Article container's template, like so.
[[!addCSS? src=`[[~100]]`]]
[[+articles]]
[[+paging]]
In this case, the link to the target CSS is robust.
However, in case of on the fly javascript insertion, I am actually creating a dynamic data object for each article. this means javascript source is unique to each article. So the above approach does not work.
Next, I looked at getResources/getPages combo to accomplish the same
Bad news is that it behaved the same at first, but only for regClientCSS. Good news is that regClientscript is working fine.
So I guess I have a work around. do javascript attachment in a snippet that is called from within each resource, and do CSS attachment in paging template with getResources and getPages combination.
But the fact it works at the first loading of the page without any work around bothers me.
Any thoughts?
Edit:
I just moved the code to my public site and found this does not happen on my godaddy shared server.(Linux) Everything works as intended. So I need to look at my test site's setup (IIS 7) and see if anything is corrupted. Sorry for the false alarm.
[ed. note: masakia last edited this post 13 years, 11 months ago.]