We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3677
    • 130 Posts
    I am cleaning up html code for a site and ran into this issue.
    If I have indented code with tabs so that it looks organized, and I insert the [*content*] tag, then I run into indent problems. I think I have the same issue when inserting chunks as well.

    Ex: In template I am trying to indent like this:

    <body>
        <div id="container">
            <div id="page">
                [*content*]
            </div>
        </div>
    </body>


    When I insert the [*content*] tag, I want it to stay indented inside the page div so it looks neat. What happens is that the line breaks in my document content cause the source code to shift back to the beginning of the line.

    ex...Document content (Not using any Rich editor):
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec velit eget augue sodales cursus. Cras quis dui. Quisque eget ipsum ullamcorper arcu convallis venenatis. Cras orci sem, vulputate id, sollicitudin in, fermentum bibendum, magna. Sed volutpat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam metus orci, auctor nec, pellentesque sed, pretium vitae, augue. Nunc commodo vehicula tortor. Integer auctor sem ut tellus. Phasellus sodales, arcu ac gravida accumsan, nibh nisi tincidunt tellus, vel blandit est nisi sit amet risus. Sed laoreet mattis libero. Proin sit amet felis. </p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum viverra elit. Donec et sapien. Duis massa. Sed id neque. Morbi sit amet eros sed diam suscipit elementum. Curabitur dapibus nisl. Donec tincidunt urna non elit. Sed eros nunc, mattis id, mattis varius, scelerisque vel, nulla. Nunc et nibh eu diam luctus tincidunt. Donec non orci non nisl tempor luctus. Proin pellentesque, nisi vitae tristique auctor, libero nunc faucibus leo, nec semper mi velit sit amet leo. Donec justo odio, tincidunt a, placerat convallis, hendrerit in, sem. Donec vestibulum ante eget nibh. </p>

    The code is inserted where the [*content*] tag is and flows as desired right until the second <p>. At that point it loses all indents and starts back at the beginning of the next line.

    How can I fix it? I assume that if i remove all line breaks in the document content it would render like I want but then I would have a jumbled paragraph mess to decipher when looking at the document content window.
      • 3677
      • 130 Posts
      Bump...

      I thought this would be easy for someone. Surely lots of people are particular about how the source code looks and would know how to do this.
      Maybe I didn’t explain it well? Any help?

      Thanks in advance,
      -Brian
        • 3677
        • 130 Posts
        Thanks for the suggestions.

        I’m not using tinyMCE at all, I’ve disabled it. I am editing my code in Jedit (plain text editor) and then copy/pasting it into the Modx Document (No editor enabled).
        As far as the templates...I’m not following how that will help.

        -Brian
          • 3749
          • 24,544 Posts
          bmilton: Are you talking about how the code looks in your browser when you do "view source"?

          If so, the browser is doing the formatting and there’s not much you can do about it other than surrounding things with <pre> tags </pre>.

          Maybe we’re misunderstanding your problem.
            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
            • 3677
            • 130 Posts
            Yeah, I think maybe you are misunderstanding what I’m wanting to do. You’re right, I am talking about how the code looks when clicking on "view source" in the browser. I was hoping that I could format things such that it would look neat to someone else who just checked out the source from the browser.

            Could you tell me more about the tags?

            Thanks,

            -Brian

              • 7231
              • 4,205 Posts
              I think that if you include the whitespace it will render the way you want.

              <div>
                  <p>hello</p>
              </div>


              This in a chunk will render flush to the left. in other words it will not follow the structure of the document up to that point:

              <body>
                  <div> 
                      <div>
              <div>
                  <p>hello</p>
              </div>
                      </div>
                  </div>
              </body>


              So if you want it to flow correctly you will need to add the spaces in the chunk:

                          <div>
                              <p>hello</p>
                          </div>


              And it should then render:

              <body>
                  <div> 
                      <div>
                          <div>
                              <p>hello</p>
                          </div>
                      </div>
                  </div>
              </body>


              Maybe some snippet trim the white space, not sure. otherwise this should work.

              Oh, and this won’t help with the content field. That one is tough.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 3749
                • 24,544 Posts
                Quote from: bmilton at Mar 13, 2009, 01:31 PM

                Yeah, I think maybe you are misunderstanding what I’m wanting to do. You’re right, I am talking about how the code looks when clicking on "view source" in the browser. I was hoping that I could format things such that it would look neat to someone else who just checked out the source from the browser.

                Could you tell me more about the tags?

                Thanks,

                -Brian

                On second thought, <pre> isn’t going to help (and will change the font of the paragraphs).

                I’m afraid I can’t think of any easy way to do what you want (indent the whole [*content*] output in View Source). MODx has no way of knowing where the browser will be putting the line breaks because it depends on the size of the browser window. In theory, you could write a plugin that would break paragraph into lines of a fixed maximum length with a newline at the end of each and spaces inserted at the beginning for indentation. The plugin would do its work when the doc was a saved, but how would the plugin know how deeply to indent the content and what would happen in the future when you wanted to edit the document?

                Probably the best solution is to put a "view source" link on each page which links to a another page where the content is the original code of the first page enclosed in <pre></pre> tags.
                  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
                  • 20413
                  • 2,877 Posts
                  Check this ---> http://en.wikipedia.org/wiki/Whitespace_(programming_language)

                  But "It was released on 1 April 2003 (April Fool’s Day)" wink
                    @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
                    • 3749
                    • 24,544 Posts
                    Quote from: mrhaw at Mar 13, 2009, 02:40 PM

                    Check this ---> http://en.wikipedia.org/wiki/Whitespace_(programming_language)

                    But "It was released on 1 April 2003 (April Fool’s Day)" wink

                    LOL. cool
                      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
                      • 25551 ☆ A M B ☆
                      • 1,231 Posts
                      Hmmm related article for that wiki...

                      http://en.wikipedia.org/wiki/Brainfuck
                        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                        AugmentBLU - MODX Partner

                        BLUcart - MODX Revolution E-Commerce & Shopping Cart