We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9768
    • 13 Posts
    [ModX 2.2.15-pl]

    I have some Document Resources that I want to display as standalone pages and also in jQuery tabs (based on the "case-study" code in the docs under "Loading Pages in the Front-End via AJAX and jQuery Tabs").

    My first attempt was to create a Symlink pointing at the underlying Resource ("original") but with a null Template, and use this in the "tabs" page. This appeared to work on initial testing. However, it turned out that this was because I'd cleared the cache (for other reasons).

    If I view the document in the "tabs" page first, and then the original, all is fine. However, if I view the original first, then when I view it in the "tabs" page it has the Template data from the original. This breaks quite a lot of things.

    I then tried reversing the process, putting the content in the resource under the "tabs" page (with null template) and making the "original" into a Symlink. Now it's the other way round: if I view the "tabs" page first, then when I view the "original" it has no template data; if I view the "original" page first it gets its template and the "tabs" subpage doesn't.

    What seems to be happening is that the first time I retrieve a Symlink, then if the underlying Resource is already cached it will just copy it from the cache, Template and all (and cache the result), whereas if the underlying Resource is not cached then it builds its content and uses the Symlink's Template.

    This is contrary to (my understanding of) the page in the docs "Using Resource Symlinks" where it says "You can add a new template or what ever changes you may want to the symlink".

    I can't tell whether this is a misunderstanding on my part or a bug I should be formally reporting. (If it's a known bug, then I failed to recognise it as such).

    In the short term I'll be duplicating the content or putting it into Chunks (one for each such page - six at the moment, but more to come) but I'd prefer to use Symlinks if at all possible.
      • 4172
      • 5,888 Posts
      didn't test a setup like that with symlinks, so I can't say anything about your issue,

      but you can also use the same resource to get the ajax-content, no need to create a symlink for each resource.

      to get different output in ajax-mode, put a snippet as a wrapper for your template-code and put that template-code into a chunk, which is fetched by your wrapper-snippet.

      Or use just one ajax-resource to get the ajax-content for all other resources.

      If you want to cache the different results, you can use the getCache - snippet.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36816
        • 109 Posts
        Quote from: fjpb at Aug 27, 2014, 05:43 AM
        [ModX 2.2.15-pl]

        If I view the document in the "tabs" page first, and then the original, all is fine. However, if I view the original first, then when I view it in the "tabs" page it has the Template data from the original. This breaks quite a lot of things.


        Superficially, this feels much like this reported issue: https://github.com/modxcms/revolution/issues/7573 although the issue was related to Wayfinder, the cache behavior with symlinks sounds identical.

        It feels related enough, that I wonder if it might be good to add a link to this thread to that issue?
          • 3749
          • 24,544 Posts
          The expected behavior for a Symlink is to always use the template of the Symlink itself, never the template of the page the Symlink points to.

          In most use cases, the two templates are the same, so if it's a bug, it could have gone unnoticed.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 47400
            • 21 Posts
            I'm not doing anything with AJAX so not sure if our situations are that similar. However, I have product pages under a "Hire" section in a site that I'm working on at the moment which serve as the masters. I need the same pages under a "Sales" section with a variant on the template, i.e. it will say "For Sale" rather than "For Hire".

            I was finding that upon visiting the original and then going to the symlink version, it was keeping the template data from the master page. What seems to have fixed it for me is switching off "cacheable" in the symlink's pages settings.

            Hope that helps.