We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    I can't find what tag Revo uses for Weblink and Symlinks.

    I need to create a custom output modifier that will display a resources in custom TPLs based on whether it's a regular resource, weblink or symlink.

    http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/commonly-used-template-tags
    Doesn't list those tags, so I'm curious how MODX `knows` what kind of resource/element that the weblink is.

    This question has been answered by ultrasef. See the first response.

    [ed. note: ultrasef last edited this post 12 years, 6 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The tags aren't any different. Internal processing checks the resource's contentType.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36632
        • 202 Posts
        Are you saying that MODX doesn't distinguish between Resource, Symlink and Weblink?

        Content type as I know them are listed here:
        http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/content-types

        So if I were to add a new content type, that kinda defeats the purpose of the Context Menu that allows me to create a Resource, static doc, weblink or symlink.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          That is two completely different things. Content type is the HTTP mime type, and determines the naming extension for the purpose of generating URLs and other HTTP header information, and also for handling the streaming of files associated with static resources with a binary content type.

          The MODX resource types are for internal MODX processing.

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
          • discuss.answer
            • 36632
            • 202 Posts
            So in essence MODX doesn't distinguish between Document, Weblink and Symlink? I find it rather strange that Weblink and Symlink don't have tags to manipulate, like [[*weblink]]

            EDIT: The Weblink tag is actually [[+content]]

            I created a TV called resType so I can have a `hook` so to speak. Then I created a simple conditional:
            [[+resType:is=`Weblink`:then=`[[!getResources@Weblink?parents=`[[*id]]`]]`:else=`[[!getResources@Regular?parents=`[[*id]]`]]`]]

            Weblink TPL:
            <section id="[[+alias]]">
            <h1><a href="[[+weblink]]">[[+pagetitle]]</a></h1>
            <p><a href="[[+weblink]]">[[+description]]</a></p>
            </section>
            <hr />
            The above TPL doesn't work of course because there's no MODX tag available for it, or if there is I haven't found in the rtfm subdomain.

            Here's the actual output from the Weblink TPL from above:
            <section id="the-toxins-that-threaten-our-brains">
            <h1>The Toxins That Threaten Our Brains</h1>
            http://www.theatlantic.com/features/archive/2014/03/the-toxins-that-threaten-our-brains/284466/
            </section>
            <hr />

            Very interesting that MODX `knows` to place the Weblink field right there REGARDLESS of the tags! It ignores the entire "<p><a href="[[+weblink]]">[[+description]]</a></p>" line and sticks the Weblink right there.

            So where would I find out how MODX does that so I can control the output, to make it it functional?

            Thank you Susan! [ed. note: ultrasef last edited this post 12 years, 6 months ago.]
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It uses the database field class_key - modDocument, modWebLink, modSymLink, modStaticResource. So do the listing snippets like Wayfinder.

              The URLs are handled differently depending on your choice of how to handle the links - use the weblink or symlink resource ID to make the URL, or use the target (what's in the content) to make the URL. So a weblink to http://google.com can have a URL of http://domain.com/go-to-google.html, or a URL of http://google.com. And static resources are completely removed from the normal output if their content type is marked as binary, and they are given HTTP headers for streaming their target file.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org