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

    I want to make sure that the users that will modify the content of my website won’t screw things up if they forget to put the good template at the good place. The way my website is built, all the document inside a given directory have the same template while everything else has another template. I would like to build a plugin that will set the good template to a document each time it’s saved. Can you give me some hints or cue on how to do it? I already asked for something like this, but I only got some ugly workaround like : ’tell your users what they have to do’.

    Also, I’m modifying the newspublisher snippet so it do exactly what I need him to do. The thing now is that I really have to know two things : how can I create a directory with ’some content’ inside (create a parent document) from script, and how can I put a form with a RTF editor that will send it’s content through the script ?

    I hope i was clear!

    thanks a lot inadvance!

    Bye,
    blaise
      Blaise Bernier

      www.medialdesign.com - Solutions for small business, hosting, design and more!
    • NewsPublisher has an optional argument &template=`templatename` which will tell it what template to use.

      As far as doing this from the backend, you’d need a plugin similar to the TemplateSwitcher plugin, using a different System Event (OnDocFormSave, maybe?) it would check for the document’s Parent and change the template as required.
        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
        • 11413
        • 203 Posts
        Quote from: sottwell at Nov 28, 2005, 05:57 PM

        NewsPublisher has an optional argument &template=`templatename` which will tell it what template to use.

        Ok this is nice.. Also the thing I want is to be able to publish to a given directory. It’s for an online newspaper and I want each issue to be stored in an independant folder. What I thought about is to create a kind of newspublisher clone where you enter the text for the front page of the publication, and then, when you are in the publication itself, there is an other news publisher thing that will let you add articles to the issue... would it work??

        For the template thing, i’ll look at it, but if i can use the newspublisher it will be fine.

        thanks again,
        Blaise
          Blaise Bernier

          www.medialdesign.com - Solutions for small business, hosting, design and more!
        • NewsPublisher also has an optional argument, &footertpl=`chunkname`, which it will put at the end of the documents it creates. Put a call to NewsPublisher in a chunk and use it as the footertpl for your "master" NewsPublisher. Then when you go to the documents it created, they will have the form for creating new documents (if you’re logged in correctly, of course).

          Take a look at the argument list in the beginning of the snippet code. It’s really quite powerful.
            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
            • 11413
            • 203 Posts
            Ok... i’m working on it... sadly, there is no usage example in the snipet or anywhere else... I’m writing about it while i’m testing it. To be sure : to have RTF fields for the comments, I just enter a name for the &rtcontent field and that’s all??

            thanks a lot for your patience, help and quickness (the other reply was pretty fast :p)

            bye,

            Blaise
              Blaise Bernier

              www.medialdesign.com - Solutions for small business, hosting, design and more!
            • This may be of some help.

              http://modxcms.com/blog-publish.html
                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
                • 11413
                • 203 Posts
                Yeah, thanks... It helps a little bit, but i’m affraid that i’m doing only copy paste : there is no explanations about the effect of each thing you have to do there.

                I don’t understand how the chunk with the form template will change the template for the publication form and i’m not sure how it really works with the template variable too... sorry if i’m a little bit dumb, but following a reciepe don’t tell me why it tastes good smiley

                So... here are a few more questions about the form’s chunk :

                1) <input name="NewsPublisherForm" type="hidden" value="on" /> -> What is the use of this line

                2) <form name="NewsPublisher" method="post" action="[~[*id*]~]"> what will the action define exactly?

                3) <label for="content">Content:[*blogContent*]</label> -> What will make my TV send the good information? where is it defined that the TV called ’blogContent’ will defint the content?


                Thanks a lot about thatand again, sorry for the trouble, i’m learning :p

                bye,

                Blaise
                  Blaise Bernier

                  www.medialdesign.com - Solutions for small business, hosting, design and more!
                  • 11413
                  • 203 Posts

                  3) <label for="content">Content:[*blogContent*]</label> -> What will make my TV send the good information? where is it defined that the TV called ’blogContent’ will defint the content?

                  Ok... sorry for this one I found it in the newspublisher declaration smiley
                    Blaise Bernier

                    www.medialdesign.com - Solutions for small business, hosting, design and more!
                  • 1. Lets the NewsPublisher snippet know that this is the postback; the form has been filled out and the page has been reloaded with the POST data available. It’s a good way to make sure you don’t get spurious POST data from some other form.

                    // get postback status
                    $isPostBack = isset($_POST['NewsPublisherForm']) ? true:false;
                    ...
                    switch ($isPostBack) {
                      case true:	// process post back
                    ...
                      default:	// display news form
                    ...
                    


                    2. The [~xx~] tags makes MODx generate a link for the document given; the [*id*] tag returns this document’s id. So the action is simply re-loading the same page, with the POST data (including the NewsPublisherForm value of "on").
                      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
                      • 11413
                      • 203 Posts
                      Ok! Now i got it! a few more questions and i think i’m gonna love that snippet!

                      If I want the users to be able to remove articles... how can I?

                      and how can I define my own set of buttons with FCK editor? I have defined two TV, one for the summary of the article and one for its content. Currently, both editors only have bold, underline, italic and a link button. It’s perfect for the summary, but I would like to have more options for the content. How can I defint a special set of buttons ?

                      thanks in advance,

                      Blaise
                        Blaise Bernier

                        www.medialdesign.com - Solutions for small business, hosting, design and more!