We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30195
    • 10 Posts
    I am new to modx, so please forgive me if I sound like a newbie, ’cause I am! tongue

    I’ll be using modx to put a magazine online. (I already put them online, but in a fairly static (although database driven) way.

    Each month I update their homepage, and put 3 featured articles online.

    The articles have several pictures with captions. (the number of images always varies)

    So, tell me if I did this right.

    I created several new template variables.

    image1
    caption1

    image2
    caption2

    and so on... these variables are accessible to my template.

    First of all... is this the best way to do it, or should I simply use the TinyMice editor to upload pics?

    Secondly, if this is ok, how would I display the image/captions, WITHIN the content (not the template) conditionally? (i.e.... if the image exists... display it, otherwise display nothing?)

    I would like to do this...

    here is some text, and more text...

    if image1 exists, display image1
    if caption1 exists, display caption1

    here is some text, and more text... etc.

    I read in an earlier post about using [[Condimage1]] but I can’t seem to get that to work within the content of a page, so I am assuming that only works in the template.

    Sorry this is so long winded... I would appreciate any help on this!

    Thanks!




      • 29181
      • 480 Posts
      You should look into phX which sounds like just what you need, I used it recently on a project for generating thumbnails for case studies, the user uploads a thumbnail and a normal sized image (normally via Manage Files or the resources manager) and then points a TV to it in the page setup.

      The template then contains this PHX snippet:

      [+phx:if=`[*thumb1*]`:isnot=``:then=`<div class="thb_holder"><a onclick="changeImage(’[*thumb1*]’)" href="#"><img src="[*thumb1*]" class="thumb"></a></div>`+]

      (which displays a larger version of the image when clicked)

      Hope thats what you are after.

      Taff
        Adrian Lawley: www.adrianlawley.com
        • 30195
        • 10 Posts
        Quote from: Taff at May 03, 2008, 06:17 AM

        You should look into phX which sounds like just what you need, I used it recently on a project for generating thumbnails for case studies, the user uploads a thumbnail and a normal sized image (normally via Manage Files or the resources manager) and then points a TV to it in the page setup.

        The template then contains this PHX snippet:

        [+phx:if=`[*thumb1*]`:isnot=``:then=`<div class="thb_holder"><a onclick="changeImage(’[*thumb1*]’)" href="#"><img src="[*thumb1*]" class="thumb"></a></div>`+]

        (which displays a larger version of the image when clicked)

        Hope thats what you are after.

        Taff

        Thanks! Maybe it is.... I’ve installed it and will see... how would I add the image to the document content (and not the template)?


          • 29181
          • 480 Posts
          I would probably create a chunk called (let’s say for this example) image1 and paste the PHX conditional in there.

          Wherever you want that to appear in the content simply throw in a {{image1}} and it should work.

          An alternative would of course to paste the code directly in the content...but that is (IMO) only a short term solution. As soon as a client gets in there something is going to get changed or their FCK editor is going to rewrite the HTML entities (unless you have that disabled, which I didnt know was possible until I spoke to stefan about the editor in xt:commerce, so I presume its an option in MODx too )

          Not only that, the first option keeps your template cleaner and means you can make the same call in different templates.

          All the best,
          Adrian


            Adrian Lawley: www.adrianlawley.com