We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21496
    • 225 Posts
    Hi all - I’m new to this forum and MODx. I’m used to Textpattern and have some experience with ExpressionEngine, but right now I’m stuck with the following problem:

    I have a page with two content areas. One div is the main content, and there’s a sidebar which contains an image which is different on every page. I would like the user to be able to change the image, and I would like to use a single template for all those documents. How can I let the user select that picture?

    I’ll run into a similar problem with another project, where I have several text blocks on the page. So how can additional content areas be created so they are accessible for editing?
      René
      • 11975
      • 2,542 Posts
      Hi,

      Create a new TV (type:image | widget:image) named for instance myImage
      Attach this TV to your template.

      Then add in your template where you’d like to display the img [*myImage*]
      If you wish to have the ability to edit with QuickEdit from the front end [*#myImage*]


      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 21496
        • 225 Posts
        Thanks ... that starts to look like a solution! But there’s the next question coming with that: is there a way for the user to specify the alternate text for the pics? And the widget produces empty class and style attributes. I don’t need to assign any styles or classes in this case - so how can I get rid of them? And is there a way that height and width are calculated?
          René
          • 11975
          • 2,542 Posts
          If you wish to control more accurately the output, do not select any widget.
          That way the tv output will be reduced to the image path.

          Otherwise you’ll have to change the code in manager/includes/tmplvars.format.inc.php from line 33 to 59 to add the getimagesize
          function

          http://www.php.net/getimagesize


          :-)

            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 21496
            • 225 Posts
            Quote from: heliotrope at Jan 28, 2007, 05:16 PM

            If you wish to control more accurately the output, do not select any widget.
            That way the tv output will be reduced to the image path.

            Okay - merci!

            That means, if I want to have the alt attribute specified, I need to use a construct like this in my template:

            <img  src="[*#sideImage*]" alt="[*#sideImgAlt*]" /> 


            Now that works, but doesn’t look like a very robust solution. What if the user forgets to insert an image or deletes it? I’ll end up with a broken img tag. Not good. Is there no out of the box solution for this?

            Another question:

            I was checking the Copadel page from you sig. Since I learn best from examples, I would be interested to know how you did those three boxes Collecte, Conditonnement and Expédition. With the knowledge I have right now, I would try to do that with a TV for the image, and a TV for the text, multiplied with 3, since there are three boxes. Is that how this has to be approached in MODx? Just asking before I reinvent the wheel ... smiley
              René
              • 25663 MODX Staff
              • 12,272 Posts
              Set a default for your image to be a standardized placeholder image. Also, I would not recommend using the [*# structure in those TV calls. Those are for Quickedit, and it doesn’t work so well for inline image source editing. You can however still access them through the QE menu.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 11975
                • 2,542 Posts
                It’s a bit late here in France so I could not explain how I deal with the copadel webiste but about your fisrt question
                have a look at the PHx plugi, it allows condtionnal statement

                [+phx:if=`[*sideImage*]`:is=``:then=``:else=`<img src="[*#sideImage*]" alt="[*#sideImgAlt*]" />`+]

                hope that helps.


                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 21496
                  • 225 Posts
                  Thank you - I’ll look into those things tomorrow, since it’s also late here in Switzerland ... bonne nuit!
                    René