We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42970
    • 27 Posts
    Hello,

    I am new to MODx revo and I really like. I like to write my own HTML/CSS/JS so I think that MODx revo rocks !

    But I have a question.

    Is there a way to add contents to a page without changing the current one?

    For example, I have a simple Chunk with 3 TVs: Title, Text and Image. I put that Chunk in a template and it runs just fine.

    And now I want to use the same Chunk with those 3 TVs and to put that chunk before the last one.

    In template I have :

    <div class="articles">
        [[$chunk_name]]
    </div>


    And is it possible to have like :

    <div class="articles">
        <h2>title1</h2><p>text1</p><img src="image1" alt/>
        <h2>title2</h2><p>text2</p><img src="image2" alt/>
        <h2>title3</h2><p>text3</p><img src="image3" alt/>
    </div>


    But for user to use the same fields for TVs.

    Thank you for the help. [ed. note: vucko2405 last edited this post 13 years, 6 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That's a job for MIGx TVs. Instead of a chunk, use a MIGx TV. It will allow you to have as many of such rows or blocks as you want for a given page.

      The sample used in the MIGx documentation is exactly what you are doing, so you can just copy/paste the sample code from the "backend usage" and "frontend usage" sections. http://rtfm.modx.com/display/ADDON/MIGX

      I almost always simply copy/paste that code, then modify it for my own purposes. The JSON syntax becomes familiar after a while.
        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
        • 42970
        • 27 Posts
        Thanks for the reply.

        I ran into some trouble. I completed 3/4 steps of your link and now I'm stuck at frontend-usage. Where do I need to put the code written in the link. I tried putting all of the codes in document/template/chunk and it isn't working. It shows me a blank page or an error.

        Fatal error: Call to a member function getSource() on a non-object in /x/y/public_html/z/core/cache/includes/elements/modsnippet/2.include.cache.php on line 122

        What am I doing wrong ?

        Thank you

        NOTE: I attached my steps of what did I do. [ed. note: vucko2405 last edited this post 13 years, 7 months ago.]
          • 42562
          • 1,145 Posts
          So everything went fine, the migxTv allowed you to input text and image.

          What is your final call?
          Place this in the very document that has the migxTV input (whether in the document's Content, Sidebar chunk or TV area). This can only appear once, or work, that is, when this page is in view.
          <ul>
            [[!getImageList? 
              &tvname=`migxTV` 
              &tpl=`myMIGXchunkTPL`]] //I usually avoid the @CODE:<li> stuff
          </ul>

          If you want the call to be independent from the document, and be called from anywhichever place (template, another resource...) - note that the content of the migxTV can only be edited from the document that owns it (I think this is correct)
          <ul>
            [[!getImageList? 
              &docid=`45`  //the id of the document which has the migxTV input
              &tvname=`migxTV` 
              &tpl=`myMIGXchunkTPL`]] //I usually avoid the @CODE:<li> stuff
          </ul>
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 42970
            • 27 Posts
            I placed

            <ul>
              [[!getImageList? 
                &tvname=`migxTV` 
                &tpl=`migx`]] // chunk name [b]migx[/b]
            </ul>


            In my migx document content and put the name of my chunk migx but the chunk is empty because I don't know what to put in the HTML part so it shows a blank page.

            <html>
            <body>
            </body>
            </html>
            


            Can you help pls ?
              • 42562
              • 1,145 Posts
              Ah, I see!

              The chunk will contain the [[+placeholders]], that is, the representatives of the data you input in the migxTV.
              For example, in this code you used
              {"caption":"Info", "fields": [
              {"field":"title","caption":"Title"},
              {"field":"description","caption":"Description","inputTV":"richtextTV"}

              When you enter data in the TV, the data goes into two fields, "title" and "description" (note the exact spelling and case).
              To display the data, each field would have to be called out using its respective placeholder
              "name" would be called using [[+name]]
              "description" would be called using [[+description]]
              "image" would be called using [[+image]]
              &tpl=`migx`]]

              The above chunk, then, would contain
              [[+name]] [[+description]]

              Of course you would have to add some HTML / CSS to produce what you want.

              So, in your case, the chunk, migx, might look something like this:
              <h2>[[+name]]</h2>
              <p>[[+description]]</p>
              <img src="[[+image]]" alt="[[+name]]" /><br /><br />
              And this would replace your
                  <h2>title1</h2><p>text1</p><img src="image1" alt/>
                  <h2>title2</h2><p>text2</p><img src="image2" alt/>
                  <h2>title3</h2><p>text3</p><img src="image3" alt/>
              
              and finally, in the document
              <div class="articles">
              [[!getImageList? 
                  &tvname=`migxTV` 
                  &tpl=`migx`]] 
              </div>
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 42970
                • 27 Posts
                @donshakespeare,

                I followed you instuctions and I put

                <div class="articles">
                [[!getImageList? 
                    &tvname=`migxTV` 
                    &tpl=`migx`]] 
                </div>
                


                In my documents content and it didn't work so I put the code in my templates content (the one which the document uses) and it works now so thank you very much for your help.

                Cheers
                  • 42562
                  • 1,145 Posts
                  I am glad you got it working.
                  It should work in that particular document's content.
                  Perhaps need to disable TinyMCE or the WYSIWYG editor, if any...
                  To call it from another document, use the &docid=`2` feature, where the number represents the id of the original document with the TV
                    TinymceWrapper: Complete back/frontend content solution.
                    Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                    5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                    • 42970
                    • 27 Posts
                    Is it wrong that I have TinyMCE installed?

                    It is writen in the offical documentation to install the add-on.

                    http://rtfm.modx.com/display/ADDON/MIGX.Backend-Usage

                    This documentation page assumes that you have the add-on TinyMCE installed.

                      • 42562
                      • 1,145 Posts
                      No it is not wrong. It is needed if you are going to use a richtextTV.
                      Don't uninstall it, just disable it (if it is indeed the culprit) in the settings of that particular document (in settings / RichText)

                      So I meant that sometimes the WYSIWYG often tampers with the code you paste in; replacing the & with strange characters and discombobulating simple code with useless <p></p> tags and formatting.
                        TinymceWrapper: Complete back/frontend content solution.
                        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.