We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19534
    • 183 Posts
    Hey!

    I’m new to Modx and have a best practice question:

    I’m using Modx with a complex template (not designed by myself with lots of div, css classes etc).

    For example a simple paragraph with a headline looks like this:

    <div class="headblock"><h1>Title lorem ipsum</h1></div>
    <div class="headblock2"><h2>Sub Title Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris id eros in velit ornare porta.</h2></div>
    
    <div class="level">
    	<p>
    		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
    	</p>
    </div>
    


    I know all the divs seem to be unnecessary, but I have to implement this template and I’m not allowed to change it sad

    When an editor wants to write new content, I don’t want him to have to write all the divs and css classes by himself. He should be able to create a new paragraph by providing only the real content (e.g headline1 (text), headline2(text), text(richtext)).

    How would you realize this in Modx-conform way?
      Add-On to easily manage your multilingual sites: Babel
      • 33976 ☆ A M B ☆
      • 571 Posts
      Hi mikrobi,

      I would do the following
      <h1>[[*pagetitle]]</h1>
      <h2>[[*longtitle]]</h2>
      <p>[[*content]]</p>


      Hope it helps
        • 19534
        • 183 Posts
        Hey Romain!

        Thanks for your reply. Your answer doesn’t help. Maybe I was not concrete enough.

        A page will contain more than one of these paragraph blocks. A page will look like this:

        <div class="headblock"><h1>Title block1</h1></div>
        <div class="headblock2"><h2>Subtitle Block1</h2></div>
        
        <div class="level">
        	<p>
        		Textblock1
        	</p>
        </div>
        
        <div class="headblock"><h1>Title block2</h1></div>
        <div class="headblock2"><h2>Subtitle Block2</h2></div>
        
        <div class="level">
        	<p>
        		Textblock2
        	</p>
        </div>
        
        <div class="headblock"><h1>Title block3</h1></div>
        <div class="headblock2"><h2>Subtitle Block3</h2></div>
        
        <div class="level">
        	<p>
        		Textblock3
        	</p>
        </div>
        


        (I know h2 and h3 should be used but I’m not allowed to change the template) wink

        This block is only an example out of several others. An editor should be able to add a paragraph/block to a page by saying "I want to add a block of type XY". Then he should be able to insert the real content (without the divs and classes). The content should then be generated automatically with the help of templates I will code for the editors.

        Hope this makes my problem easier to understand...
          Add-On to easily manage your multilingual sites: Babel
          • 1169
          • 312 Posts
          I think the best would be to use Template Variables TV’s for short.

          Keep your template.

          Create TV’s for all your Blocks of type text

          Attach TV’s to template.

          Put TV "placeholders" in Template HTML.

          Editors can now place Content in TV’s on Resource.



          You could use your existing titles as TV Names.
          <div class="headblock"><h1>Title block1</h1></div>

          TV Name:- Title block1

          Syntax is different for Evo and Revo

          Evo
          <div class="headblock"><h1>[*Title block1*]</h1></div>


          Revo
          <div class="headblock"><h1>[[*Title block1]]</h1></div>


          Hope this helps.

          Welcome to MODx
            DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
            • 33976 ☆ A M B ☆
            • 571 Posts
            Ok, got it now.

            As allanb wrote, if the number of pattern is fixed for each page (let’s say a page will have 3 times this pattern), then i would create Template Variables (h1-one, h2-one, p-one, h1-two, h2-two…).
            If not, i would define a container and a ditto/getResources call to grab children’s pagetitle, longtitle and content.
            I guess there is another way to define a custom Template Variable style, and dynamicly add some more entries. For Evo you could have a look at http://modxcms.com/forums/index.php/topic,49153.0.html. Something should be doable that way for Revo too (http://modxcms.com/forums/index.php/topic,52539.0.html might be a start).