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

    I’d like to insert a box with changing content somewhere in the content section.

    It shall always look the same, but it can be at different places (anywhere in the content area).

    Thus I have
    1. some html with CSS references to start the box
    2. changing box content
    3. some html with CSS references to end the box

    How do I achieve this?

    Should I use 2 chunks (box-start, box-end) and put the box content in between? Or something like a snippet and the box content as parameters for the snippet?

    Cheers, Frisco
      • 7231
      • 4,205 Posts
      Where will the content be coming from? If it from other documents then use Ditto for this so you can define the display in the tpl.
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 10190
        • 187 Posts
        The content will come from the content editor typing it manually in - there’s nothing done automatically like import from feeds, ditto etc.

        It would be possible to have another box, i.e. a generated tag cloud - but this would be another topic.

        For now, I need something which can be handled manually by the content editor and which is placable anywhere in the content.

        Cheers, Frisco
          • 7231
          • 4,205 Posts
          Is this on a per-page basis or a global box? If it is in a per-page then you can use a TV (Template Variable) as the place to add/edit the text. Then you can either simply use:

          <div id="myBox">
          [*name-of-TV*]
          </div>
          directly in your template.

          If you want the contents of the box to carry over to child pages, set the default value to @INHERIT. @INHERIT is a binding that will cause the TV to inherit it’s value from the first parent that has a set value.
            [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]
            • 10190
            • 187 Posts
            I was thinking about using TVs, but I don’t like the idea because the content editor has to put in html (<div ...) manually.

            For me the purpose of using a CMS is to let people add content without the necessity of knowing html, css or such.

            I use TVs only for content which is always at the same place, so I can put the call to the TV in the template (hence the name Template Var wink ). For example, I have articles which always have a picture to the left, same size and position - this is done by a template var which is referenced in the template, so the editor only has to put in the picture in the TVs form field.

            What I need is something which can be used of someone without knowledge of html/css but which can be used everywhere in the articles text, i.e.:

            Lorem ipsum
            [[optional_box?"some lines of box content here"]]
            dolor sit amet ...

            This would not be as userfriendly as I like it, but at least the editor wouldn’t have to know html/css.

            Would it be possible to put the starting and ending html (div...) inside the TV, to hide it from the editor? So that he would fill in only the box’s content in the TVs form field and reference it for example by
            [*optional-box*]
            and the TV would output the starting html, then the box content from the editor, then the ending html? Maybe by the use of chunks inside the TV?

            Cheers, Frisco
              • 4041
              • 788 Posts
              This post may be of interest to you in this case, but only if you use tinymce editor. You can use predefined templates made by you which can then be added anywhere inside the content area by a simple click of a button by the content author smiley

              http://modxcms.com/forums/index.php/topic,30069.msg182569.html#msg182569
                xforum
                http://frsbuilders.net (under construction) forum for evolution
                • 10190
                • 187 Posts
                Thanks, it’s nice to have a possibility to customize TinyMCE.

                I did now two chunks and use them like this in the editor:

                {{start-content-box}}Das ist der Inhalt der Box!{{end-content-box}}

                That works, and I could use that row for a button in TinyMCE with a text like "put your text here".

                That should do it for the moment, if I need something with generated content like a tag cloud I have to think of something else (snippet?), but this is nothing which matters for me now.

                Cheers, Frisco