We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47562
    • 113 Posts
    Ok, I'm missing something.

    If I follow Bob's nice tutorial page (http://bobsguides.com/newspublisher-tutorial.html), and use this:

       [[!NewsPublisher]]
    

    the form comes up nicely, but with unnecessary fields for the client. So I want to tailor things a bit, and try this:

        [[!NewsPublisher?
            &show=`pagetitle,longtitle,pub_date,summary,content,cp_pr_city,cp_pr_state,cp_pr_country`
            &initrte=`1`
            &initdatepicker=`1`
            &rtcontent=`1`
            &rtsummary=`0`
            &parentid=`18`
            &published=`1`
            &hidemenu=`0`
            &cacheable=`1`
            &searchable=`1`
            &richtext=`1`
            &captions=`content:"Body Copy",introtext:"Summary",pub_date:"Release Date",cp_pr_city:"City",cp_pr_state:"State/Province",cp_pr_country:"Country"`
        ]]

    No go; the result is a set of errors:

    Illegal value for &hidemenu: `0` (you may not have permission for the document or group referred to)
    Illegal value for &cacheable: `1` (you may not have permission for the document or group referred to)
    Illegal value for &searchable: `1` (you may not have permission for the document or group referred to)
    Illegal value for &published: `1` (you may not have permission for the document or group referred to)
    Illegal value for &richtext: `1` (you may not have permission for the document or group referred to)

    Where am I going wrong? And why the apparent introduction of permission issues?

    Thanks for any help...
      • 3749
      • 24,544 Posts
      I think it's a failure to update the docs. wink

      Try adding _default to the ones you're getting the error messages on, like this:
      &hidemenu_default=`0`


      Let me know if that works.
        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
        • 47562
        • 113 Posts

        Thanks for the response, Bob.

        I'm wondering if I'm doing something else completely wrong.

        When I remove the offensive settings being flagged in that first set of errors (the lines setting hidemenu, cacheable, searchable, published, and richtext) and take out my additional TVs, I get the following entirely new set of errors:

        You wanted to display a TV, but this template doesn't have it: `pagetitle
        You wanted to display a TV, but this template doesn't have it: summary
        You wanted to display a TV, but this template doesn't have it: content`

        Again, that's using this call:

        [[!NewsPublisher?
            &show=`pagetitle,longtitle,pub_date,summary,content`
            &initrte=`1`
            &initdatepicker=`1`
            &rtcontent=`1`
            &rtsummary=`0`
            &parentid=`18`
            &captions=`content:"Body Copy",introtext:"Summary",pub_date:"Release Date"`
        ]]


        The template in question seems to be set correctly, so I'm confused... smiley
          • 3749
          • 24,544 Posts
          It's not the template, since those should be available in any case. I can only think of a few possibilities.

          My first guess would be that there's something wrong with the NewsPublisher tag (e.g., using a single quote instead of a back-tick), but if you pasted the tag above, it looks OK to me. Sometimes extraneous invisible characters will get into a tag, so sometimes retyping it and deleting the original will fix things.

          Here are some other ideas:

          1. The page you are trying to edit is connected to a template that doesn't exist.
          2. The document you're editing has the class_key field set to something other than modDocument.
          3. You have a corrupted file in your NewsPublisher install.


          You will probably have to look at the modx_site_content table in the database in PhpMyAdmin to be sure about the first two. Reinstalling NewsPublisher might fix the third -- or uninstalling, removing, re-downloading and reinstalling it as a last resort.
            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
            • 47562
            • 113 Posts
            Ok, I'm trying to approach things step by step.

            Quote from: BobRay

            My first guess would be that there's something wrong with the NewsPublisher tag (e.g., using a single quote instead of a back-tick), but if you pasted the tag above, it looks OK to me. Sometimes extraneous invisible characters will get into a tag, so sometimes retyping it and deleting the original will fix things.

            Just for grins, I re-entered the NewsPublisher tag; no change.

            1. The page you are trying to edit is connected to a template that doesn't exist.

            Checked the modx_site_content table; template has id 6, which is the correct press release template.

            2. The document you're editing has the class_key field set to something other than modDocument.

            Sorry, in which table is "class_key" to be found? (The resource info shown in modx_site_content appears to be complete/correct: type is "document", contentType is "text/html", etc).

            3. You have a corrupted file in your NewsPublisher install.

            Will try re-installing, to see if that will clear things up...

              • 47562
              • 113 Posts
              Re-installed, but no change.

              One thing that bothers me is that based on the error message, the $tvNameOrId getting passed to _displayTv is wonky, at least for the pagetitle and content tvs (note the tick marks in the messages):

              You wanted to display a TV, but this template doesn't have it: `pagetitle
              You wanted to display a TV, but this template doesn't have it: summary
              You wanted to display a TV, but this template doesn't have it: content`

              Still not sure why summary is being flagged, though...

              Thanks again for you help, Bob. [ed. note: pauhana last edited this post 12 years, 3 months ago.]
                • 3749
                • 24,544 Posts
                Doh. I just thought of something obvious. There is no 'summary' field (unless you have a TV with that name). Try changing that to introtext. wink

                That still doesn't explain why the back-ticks are being sent in the $scriptProperties array though. They should never make it past the MODX parser.

                If they are still there in the error message after fixing the 'summary' field, I can give you a workaround, but it suggests a bigger problem. Just for the heck of it, you might try deleting all files in the core/cache directory.
                  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
                  • 47562
                  • 113 Posts
                  Wow, how'd I miss that? I made the change to the captions, but not to the show! (Doh indeed!)

                  Anyway, made the change, wiped the contents of core/cache, and now see:

                  You wanted to display a TV, but this template doesn't have it: `pagetitle
                  You wanted to display a TV, but this template doesn't have it: introtext
                  You wanted to display a TV, but this template doesn't have it: content`

                  So still scratchin' my head.

                  Since you're helping me stew on this, a couple of related questions. (These apply even just using [[!NewsPublisher]]).

                  (1) Is there any way to prevent the pub_date from zeroing out? I was thinking of using that date to refer to the press-release date, so the "pub" in this case has different semantics. (Not a big deal; I can use another tv, but I'm rather lazy...).

                  (2) How do I set the id of the template that gets used for the resulting resource? It's incorrect right now...

                  Thanks for the help!
                    • 3749
                    • 24,544 Posts
                    pub_date is used by MODX to determine when a resource should be published automatically, so it's not a good choice for other uses. publishedon is set automatically by MODX when a resource changes from unpublished to published, but you could possibly use it if the 'published' field will always be set to 1 from the beginning and stay that way. All-in-all, a TV is probably a better option.

                    &template=`12` (where 12 is the ID of the template you want assigned) should work to set the new doc's template, but may be affected by your other problem. You can also use the name of the template, but using the ID will be faster.

                    Here is a workaround for the error messages that might work:

                    In the core\components\newspublisher\model\newspublisher\newspublisher.class.php file, around line 623, change this line:

                     $field = trim($field);


                    to this:

                    $field = trim($field, " `\t\n\r\0");


                    Note the space after that first double quote and the back-tick just after that.

                    I'm still baffled by the problem since the back-ticks should definitely be removed by the MODX parser before they get to NP, and why is introtext failing when it has no back-tick attached. Also, how is pagetitle working, but not the other resource fields? Are you seeing any trouble with other snippets on the site?

                    You might try changing the order of the fields in the &show property to see if that changes the error messages.

                      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
                      • 47562
                      • 113 Posts
                      Ok, there are definitely gremlins at work here.

                      I moved introtext to a different place within the show, and the message regarding introtext went away. Then I moved introtext back to where it was originally, and the message stayed away. A little odd, yes?

                      So the messages are now:
                      You wanted to display a TV, but this template doesn't have it: `pagetitle
                      You wanted to display a TV, but this template doesn't have it: content`

                      Then I added the line to get NP to use my template for the new pages:
                      &template=`6`

                      And I see the new message:
                      Failed to get template: .`6`

                      I didn't ask for ".`6`"!

                      I'm going to try uninstalling, removing, re-downloading and reinstalling NP, but I'm beginning to suspect that there's something wrong with the basic ModX install.