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

    Using Revo 2.1.3 and Newspublisher 1.2.1 (the fork that allows TV file and image variables on the front end).

    Have a page that we use for an array of Template variables we use throughout the site. We want these to be editable through Newspublisher. We can get the list of variables up perfectly fine, as with other pages, but when we attempt to submit we get the following error:

    Missing field: pagetitle
    Missing field: content.
    


    Except we don't want them to be able to change that. When we add them and say they are read only they can still change them, though then we can save the document. But when we save it, one TV (NpID) is changed (we use to designate which edit document to use to edit the page) and then we can't edit it anymore. Here is our call:

    [[!NewsPublisher?
    &initrte=`0`
    &rtcontent=`0`
    &initdatepicker=`1`
    &show=`principal_info_address,principal_info_application,principal_info_city,principal_info_company,principal_info_country,principal_info_email,principal_info_facebook,principal_info_fax,principal_info_fullname,principal_info_googlemap,principal_info_linkedin,principal_info_phone,principal_info_state,principal_info_tollfree,principal_info_twitter,principal_info_twitterID,principal_info_zip`
    &readonly=`pagetitle,content,NpID`
    &parentid=`[[doclookup? &alias=`administration/principal-information.html`]]`
    &template=`Principal Info`
    ]]
    


    Do you have to include pagetitle and content? If so, can you show them without being editable? Also, is there anyway to prevent the document from changing the NpID variable?
      • 3749
      • 24,544 Posts
      It looks like you're pushing the limits of what NewsPublisher will do. wink


      One definite cause of your trouble is that you have no &required property. When that property is missing, it defaults to 'pagetitle,content', which are not in your &show property. That's why it's reporting them as missing.

      You don't have to include the pagetitle or content for existing documents. For new documents, you need the pagetitle but not (I think) the content.

      All fields in the &readonly property should also be in the &show property. I don't know why you would want to have read-only fields that are not shown in the form.

      Also, readonly doesn't work with 'option' items that will display as lists, checkboxes, or radio options. The only way to make them read-only would be with some custom JavaScript.

      I'm not sure why NpID would be altered, but I think it's because you've marked it read-only and are not showing it.
        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
        • 7045
        • 225 Posts
        I hope I am not hijacking this thread, as I think this is related. I am hoping Bob has an answer for this one.

        I have NewsPublisher setup with title and content, but my client doesn't want the title field showing. Is there a way to maybe auto-generate a title and then have the field be hidden? I hope that made sense.
          • 3749
          • 24,544 Posts
          I can't think of any reasonable way to do that without hacking the NP code. Every new resource must have a pagetitle. I can't think of any reason why your client wouldn't want to set it or would want a bogus, auto-generated one.

          I guess it could be done with a plugin attached to OnWebPagePrerender or OnParseDocument, but I'd put some serious effort into talking the client out of it. wink
            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
          • The &readonly was an attempt to make the pagetitle, content, and NpID, not editable when I did include them in the show property. I've eliminated the $readonly now.

            I added &required=`principal_info_fullname`

            So now we can save the document successfully with the changes to the template variables we want them to be able to change.

            However, our NpID template variable is still being changed back to the first item in the list (it's a drop down list).

            For now we are including it but we used CSS to hide it:

            fieldset#np-NpID-container {
            display: none;
            }

            • So is it also safe to conclude that if you are editing an existing document, it's best to show all the available fields so that when you submit the changes existing template variables that you wouldn't normally show are not changed?

              For example, we had an image TV that we didn't want the client to be able to change so we didn't include it in the list of shown fields but upon saving the document, the image TV was emptied out rather than retaining it's value. So we included it in the show list and hid it via css.
                • 3749
                • 24,544 Posts
                TVs that are not in the &show parameter shouldn't be changed. If you don't include the NpID TV in &show or &require, it shouldn't change. Let me know if that's not the case.

                Does that TV have a default value?

                  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
                • Thanks.

                  No the TV does not have a default value (there is another that does and that always remains).

                  Yes, the TVs that are not shown, that are not in the show list, do get wiped.

                  For example:

                  We have a press release template and tied to it (and to many of our templates for that matter) are some SEO variables such as seodescription.

                  Client needs the SEO person to control that and they do so in the back end.

                  But for other people, they may need to edit that page in the front end but have no access to the SEO variables.

                  We have this to designate what the Edit button in NewsPublisher should do:

                  [[!NpEditThisButton? &np_id=`[[doclookup? &alias=`edit/edit-[[*NpId]].html`]]`]]


                  Where doclookup gets the ID via alias (since we have 60 contexts we have a lot of unique IDs so we go by alias within each context).

                  So when we are editing an existing press release page it has a NpID of press. When a user clicks edit they are directed to the document with the alias edit/edit-press.html. Under each context we have a series of these documents to handle the various types of documents to edit (as many have different tvs).

                  So the edit-press.html document has this call:

                  [[!NewsPublisher?
                  &initrte=`1`
                  &rtcontent=`1`
                  &initdatepicker=`1`
                  &show=`pagetitle,longtitle,pub_date,introtext,published,pressauthor,content,pressquote,pdfdownload`
                  &parentid=`[[doclookup? &alias=`press/`]]`
                  &template=`Press Principal`
                  ]]


                  We can edit the page wonderfully but when we do submit it, the seo variables are cleared. So for example, seodescription will now be blank whereas before it had content. The NpID stays intact in this instance because we've set it to inherit the value set in the Press Index document (ie. a page that lists press releases like a blog). So we've done that for the other document we were having trouble with previously.

                  To add new press releases users can click on an Add Press Release link:

                  <p><a href="edit/edit-press.html">Add New Press Entry</a></p>


                  This works wonderfully as well in regard to generating a new document under the Press index page and filling it with content. But again, if someone goes into the backend and does some SEO work and then this document is edited from the front end, those variables are wiped clean.


                    • 3749
                    • 24,544 Posts
                    That's an ingenious setup. Do you have a 'web' context, and does the problem happen there as well? I'm wondering if it has something to do with the multiple contexts.

                    I'm at a loss to imagine how it could happen at all. If the TVs are not in any of the properties, NP doesn't even know they exist and saving a resource has no effect on its TVs, since they are stored in a different table. The only thing that would wipe them would be changing the resource's template, and it doesn't appear that you're doing that.

                    Is the template changing when you edit the resource in the front end?
                      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
                      • 3749
                      • 24,544 Posts
                      Ah . . . I think I've found it. If I'm right, it's a bug in the resource update processor.

                      http://bugs.modx.com/issues/5965 [ed. note: BobRay last edited this post 12 years, 6 months ago.]
                        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