We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3071
    • 99 Posts
    I’m a bit of a novice so excuse me! I have worked out how to replace pieces of my html code with these lines of code [*example*] so that I can hook them up to the back end text editors and stuff, which is great. Just a little unclear how to make everything truly dynamic. This is my code for a div that contains an image and also some text:

    <div class="testimage"><a href="http://www.test.com/this-is-a-test"><img src="/images/imagetest.jpg" style="border-style: none" alt="test image"/></a></div>
    <div class="testcontent"> Test copy test copy etc etc..For more information on this <a href="http://www.test.com/test-click">click here</a> </div>
    </div>


    Now I have managed to change this and hook it up to the CMS like this:

    <div class="testimage"><a href="http://www.test.com/this-is-a-test">[*thisistheimage*]</a></div>
    <div class="testcontent">[*testcopy*]</div>
    </div>


    This also works fine but I don’t know how to create the href dynamically so that the image is clickable, of course it is clickable now but this is not dynamic, how do I hook some kind of box up on the CMS so that I can choose the HREF link while publishing a page?

    Also, does anyone know how I can replace my menu links with these [*test*] commands so that I can use the CMS to specify the anchor text on the liink and also the href? Any help would be greatfully appreciated, I have very little knowledge of PHP but am sure that there is a way to do the things I need to do!

      • 20413
      • 2,877 Posts
      If linking MODx documents:

      Inside documents, tv’s and chunks:
      <a href="[~1~]">[*picture01*]</a>

      [~1~] is static docID #1 to be parsed regardless of FURL is on/off.

      <a href="[~[*id*]~]">[*picture01*]</a>

      [~[*id*]~] is the current docID to be parsed regardless of FURL is on/off.

      <a href="[~[*parent*]~]">[*picture01*]</a>

      [~[*parent*]~] is the current PARENT docID to be parsed regardless of FURL is on/off.

      http://svn.modxcms.com/docs/display/MODx096/Document-Specific+Resource+Fields

      Inside Snippets TPL’s (chunks or config-files)
      <a href="[~[+id+]~]">[*picture01*]</a>

      [~[+id+]~] is the dynamic docID to be parsed regardless of FURL is on/off. //edited
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 10449
        • 956 Posts
        this page is a bit misleading:
        http://svn.modxcms.com/docs/display/MODx096/Document-Specific+Resource+Fields

        They are accessed with [content-field-name] tags.

        Those fields are in fact accessed with [*fieldname*] tags. And if you’re using those fields inside a template-chunk for Ditto, you’ll use placeholder-syntax: [+foo+] instead of [*foo*].
          • 3071
          • 99 Posts
          Thanks for replies but as I say I’m a novice so they are not easy to understand!
            • 3749
            • 24,544 Posts
            Quote from: benchesters at Jul 05, 2009, 06:32 AM

            Thanks for replies but as I say I’m a novice so they are not easy to understand!

            I’m not clear on what you’re trying to do. but maybe this will help. If you just want to be able to set both the href and the image source while editing a document, one easy way to do it is with two template variables one for the url and the other for the image path. You could use a drop-down output type or radio buttons for the TVs. Or you could use an image TV that would let you browse to the image you want.

            Then your html would look like this:

            <a href="[*my_url_tv*]"><img src="[*my_image_tv*]" style="border-style: none" alt="test image"></a>


            If you really want dynamic entries that are calculated on-the-fly as the page is rendered, you’ll need a snippet but it sounds like you may not. And we can’t help you with a snippet until you tell us how you want the urls and images to be selected by the snippet.

            BTW, if all this is for a menu, you should consider using the Wayfinder snippet to generate the menu, in which case you’d take a somewhat different approach. Wayfinder will create the dynamic URLs automatically and they will always be correct regardless of what changes you make to the site.
              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