We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35549
    • 24 Posts
    Hi,
    I am currently trying to set up newspublisher in a non-standard contexts (see tutorial: http://rtfm.modx.com/display/revolution20/Creating+a+Subdomain+from+a+Folder+using+Virtual+Hosts. To make Tinymce work, this page was a big help: http://silentworks.co.uk/blog/development/manage-multiple-domains-with-modx-revolution.html.
    But now I’m stuck with creating new resources. For some strange reason, they remain "hidden". They appear when searching for them, and they have the right parent, but they do not appear anywhere in the resource tree or in a getResources output. I have to set the parent manually in the backend, before they appear. Editing existing resources works, although the landing page is somehow strange (no css)

    I’m using the latest version (1.1.0-pl1) with Revo 2.1.1-pl Standard. The newspublisher call is:
    [[!NewsPublisher?
    &show=`pagetitle,alias,introtext,content,publishedon`
    &initrte=`1`
    &rtcontent=`1`
    &template=`25`
    &richtext=`1`
    ]]

    Besides, I have two other questions:
    - The &template parameter seems not to be respected (neither id nor the template name, no error messages), only `parent` works. Am I doing something wrong?
    - Is there any way besides coding to specify "default" values for other fields, e.g. "class_key". I would like to have a way for creating a Weblink easily (although there are problems with this, re-editing might not be possible)...

    Sorry for this long post. I hope, someone can help me with at least some of these questions!

    Cheers
      • 3749
      • 24,544 Posts
      The pages not showing up sounds like a permission issue. You need to give the admin a Context Access ACL entry for the other context with a policy of Administrator. Issues in the front end may also be permission issues. The web context works by default when previewing from the Manager because the admin has permission for it, but you need to create rights to other contexts.

      I can’t duplicate the template problem in the latest version of NP.

      Sorry, there’s no way (short of a plugin) to create default values for the other fields.
        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
        • 35549
        • 24 Posts
        Thank you for your answer!

        In my list of steps (see bug report I filed, https://github.com/BobRay/newspublisher/issues/7) I indeed forgot to adjust the permissions for this context.
        Therefore I now added the following permission for the admin user group:
        context: newcontext, Authority: Super User - 0, Access Policy: Administrator

        I’m not very into the MODx permission system and hope this was right. Additionally I flushed the permissions, and deleted the cache.
        However, after this change, the problem still seems to persist. Also I don’t get any errors as described here http://modxcms.com/forums/index.php/topic,60636.msg353986.html#msg353986.
        Am I still doing something wrong? In this case I apologize for filing an invalid bug report...

        Regards
          • 3749
          • 24,544 Posts
          You need to flush all sessions also to renew your permissions. Let me know if that does it.

          BTW, which version of MODX are you using?
            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
            • 35549
            • 24 Posts
            I’m sorry, flusing all sessions doesn’t do it either.
            I’m using Revo 2.1.1-pl Standard with the latest version of Newspublisher (1.1.0-pl1). The systems: MYSQL 5.0.32, PHP 5.3.3-7 on the server, and MYSQL 5.1.54 and PHP 5.3.5-1 on my local system.

            Regards
            Markus
              • 3749
              • 24,544 Posts
              Could you try this: Create a new page with NewsPublisher and another new page in the Manager. Then look at site_content table in the database with PhpMyAdmin. See if you can find any differences in how the fields are set. Look especially at the context field.
                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
                • 35549
                • 24 Posts
                Thanks a lot for your advice

                I already did such comparisons, where it was possible. As I wrote in the bug report, when trying it from a fresh install, no resource is created at all. If a resource was created in the web context before using Newspublisher, the parent of this resource is "taken" for the other context as well.
                On the server system (which has the permissions set correctly) I find (by looking at the ’site_content’ table) that the parent is correct but the ’context_key’ is set to ’web’ instead of the correct context. The resource can only be made visible by searching for it and manually re-setting its parent. Modifying the database record with phpMyAdmin directly (setting context_key to ’newcontext’) is sufficient to display the resource in the resource tree. Unfortunately I have problems with always reproducing this behaviour locally. Its very strange....
                  • 3749
                  • 24,544 Posts
                  I’m still not entirely clear on what you’re experiencing, though I suspect there is a bug with setting the context field.

                  In the case where no page is created -- Is it the case that:

                  1. You see the NP form
                  2. Can fill it in and submit it
                  3. No page appears in the DB
                  4. There’s no error message - either from NP or in the MODX Error log
                  5. You can’t fix this by setting permissions

                  Thanks for helping me track this down.

                  [Update:] See if this eliminates any of the problems:

                  Add the last line of this code to the section of code at around line 1120 of newspublisher.class.php:

                              $fields['published'] = isset($_POST['published'])? $_POST['published']: $this->published;
                              $fields['hidemenu'] = isset($_POST['hidemenu'])? $_POST['hidemenu']: $this->hidemenu;
                              $fields['template'] = isset ($_POST['template']) ? $_POST['template'] : $this->template;
                              $fields['parent'] = isset ($_POST['parent']) ? $_POST['parent'] : $this->parentId;
                              $fields['searchable'] = isset ($_POST['searchable']) ? $_POST['searchable'] : $this->searchable;
                              $fields['cacheable'] = isset ($_POST['cacheable']) ? $_POST['cacheable'] : $this->cacheable;
                              $fields['richtext'] = isset ($_POST['richtext']) ? $_POST['richtext'] : $this->richtext;
                              $fields['createdby'] = $this->modx->user->get('id');
                              $fields['content']  = $this->header . $fields['content'] . $this->footer;
                              $fields['context_key'] = $this->modx->context->get('key');  /* Add just this Line */  
                  


                  I would have thought that the Create processor would add that automatically, but maybe not.
                    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
                    • 35549
                    • 24 Posts
                    Thanks a lot for your comment, BobRay. This simple line fixed the issue for me grin (confirmed by undoing again)
                    Regarding the problems where no resource was created at all: I think that a missing ’site_url’ context setting in the "fresh" MODx install was causing them. When having site_url set, the only problem (which is now fixed) was the false context_key setting. So forget about all this. I’m sorry for the confusion...

                    I also looked at the template setting problem I described earlier.
                    Changing the following line of /core/components/newspublisher/classes/newspublisher.class.php
                            } elseif (!empty($this->props->template)) {

                    to
                            } elseif (!empty($this->props['template'])) {

                    works for me to set the template correctly (tested with PHP 5.3.5). I hope, this makes somehow sense. I’m only a beginner with PHP...

                    Now I have another question about a last issue I have with newspublisher: I can’t get the current Newspublisher to redirect to the newly created resource when friendly urls are on. Did I oversee something or is this a bug?

                    Anyway, thanks for this great extension. It’s really useful to me!
                      • 3749
                      • 24,544 Posts
                      Quote from: mschlegel at Jun 11, 2011, 07:40 PM

                      Thanks a lot for your comment, BobRay. This simple line fixed the issue for me grin (confirmed by undoing again)

                      I also looked at the template setting problem I described earlier.
                      Changing the following line of /core/components/newspublisher/classes/newspublisher.class.php
                              } elseif (!empty($this->props->template)) {

                      to
                              } elseif (!empty($this->props['template'])) {

                      works for me to set the template correctly (tested with PHP 5.3.5). I hope, this makes somehow sense. I’m only a beginner with PHP...

                      Better than me in this case. wink

                      Thanks! You identified two bugs and actually fixed the second one (which I’ve been chasing for some time now).


                      Now I have another question about a last issue I have with newspublisher: I can’t get the current Newspublisher to redirect to the newly created resource when friendly urls are on. Did I oversee something or is this a bug?

                      Is this a problem in the web context too, or just in the other context?

                      Be sure you have this in the <head> section of all your templates:

                      <base href="[[!++site_url]]" />


                      Your addition of the site_url setting may fix it once the cache is fully cleared.

                      That said, this has been a problem off and on through several versions (a bug/feature in MODX, I think -- not NP). MODX doesn’t like to forward to new documents because they’re not in the document map yet. I thought I had this fixed, but will check on it if I have time.

                      If it’s still a problem, you should be able to solve it by uncommenting these two lines around line 1231 of newspublisher.class.php:

                      //$controller = $this->modx->getOption('request_controller',null,'index.php');
                      //$goToUrl = $controller . '?id=' . $postId;


                      Let me know.
                        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