We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Quote from: thekiller237 at Apr 04, 2011, 01:57 AM

    Quote from: BobRay at Apr 03, 2011, 11:22 PM

    Try changing the TV input type to listbox (single-select) or listbox (multiple-select).
    Xaecoder and I are working on the same site. Changing it to use a list-view single select changed the NewsPublisher form field to a select box, which is a step in the right direction. But the only item in the select box is this:
    @SELECT `pagetitle` AS `name`,`id` FROM `modx_site_content` WHERE `parent` IN(22,31) ORDER BY `pagetitle` ASC

    which is the code we are using to generate the options.
    EDIT: Even when using the x==y|a==b format directly, the format is just repeated in the first option of the select box.
    Thanks.

    That should be:

    x==y||a==b


    Are you sure that the CSS file is being found (do a "View Source" in your browser and click on the newspublisher.css link to see if the file comes up).

    Does the @SELECT return the right stuff when you put a TV tag in a regular page?

    It could well be a bug. I don’t think I ever tested the list option with an @ binding TV.
      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
      • 33988
      • 110 Posts
      Quote from: BobRay at Apr 04, 2011, 07:02 PM

      Quote from: thekiller237 at Apr 04, 2011, 01:57 AM

      Quote from: BobRay at Apr 03, 2011, 11:22 PM

      Try changing the TV input type to listbox (single-select) or listbox (multiple-select).
      Xaecoder and I are working on the same site. Changing it to use a list-view single select changed the NewsPublisher form field to a select box, which is a step in the right direction. But the only item in the select box is this:
      @SELECT `pagetitle` AS `name`,`id` FROM `modx_site_content` WHERE `parent` IN(22,31) ORDER BY `pagetitle` ASC

      which is the code we are using to generate the options.
      EDIT: Even when using the x==y|a==b format directly, the format is just repeated in the first option of the select box.
      Thanks.

      That should be:

      x==y||a==b


      Are you sure that the CSS file is being found (do a "View Source" in your browser and click on the newspublisher.css link to see if the file comes up).

      Does the @SELECT return the right stuff when you put a TV tag in a regular page?

      It could well be a bug. I don’t think I ever tested the list option with an @ binding TV.

      x==y||a==b
      is what i actually used, I simply typed it incorrectly in the forum post. It is still simply displaying the raw code in the select box. Also I’m not sure I understand why the CSS would affect this at all.
        Sal Sodano
        President & Co-Founder of SkyToaster
        My Website Salscode.
        • 3749
        • 24,544 Posts
        Quote from: thekiller237 at Apr 05, 2011, 10:44 AM

        I’m not sure I understand why the CSS would affect this at all.
        It shouldn’t really.

        It sounds like a bug in NewsPublisher. I’m afraid I don’t have time to mess with it right now.

        You could try using the simple form (x||y), switching to checkboxes or radio options, or try messing with the code at around line 968 of newspublisher.class.php.
          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
          OK. Version 1.0.7 is available. Hopefully, what you were trying will work now.

          Fixed bug with phantom checkbox
          Handle @ binding input option values with checkboxes, dropdown, radio options and single/multiple lists.
          Handle dropdown TVs
          Fixed bug with == TVs
            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
            • 33988
            • 110 Posts
            Quote from: BobRay at Apr 08, 2011, 10:53 PM

            OK. Version 1.0.7 is available. Hopefully, what you were trying will work now.

            Fixed bug with phantom checkbox
            Handle @ binding input option values with checkboxes, dropdown, radio options and single/multiple lists.
            Handle dropdown TVs
            Fixed bug with == TVs
            You rock! Works like a charm.
              Sal Sodano
              President & Co-Founder of SkyToaster
              My Website Salscode.
              • 1343 ☆ A M B ☆
              • 2,213 Posts
              I have a few questions...

              1. How can I change the titles for default fields? Could we add a second list like &fieldTitles=`` and just match them up? If you are showing title,description,content you would put Page Title, Description, Content in the title box?

              2. How can I allow public addition of pages to a hidden (staging/proofing) resource group?

              3. Can a dropdown list be used to define the parent page? In my example case I have a list of states (and matching list of state containers), how can I allow someone to pick Florida from a dropdown to add a state?

              3b. Can I pass that value via url or something? So if I’m viewing Florida and say, Oh, I want to add a spot click here, and the dropdown would be preselected.

              4. What would it take to add recaptcha?

              Thanks!
                Patrick | Server Wrangler
                About Me: Website | Tweets |  MODX Hosting
                • 3749
                • 24,544 Posts
                1. The default field titles are the same ones used for the fields in the Manager. You might be able to change them with form-customization (probably not). You should be able to edit them in Lexicon Management (though it will affect the Manager as well). I think they’re under core/resource.

                2. I’m not sure, but I think you can give the front-end user permission to save resources in that resource group.

                3. I can’t think of any way to do it directly, but I think you could add a dropdown list TV and write a plugin that would change the parent to that value in OnBeforeDocFormSave. NP is designed to mimic the Create/Edit Resource panel in the Manager so it isn’t really set up to handle extra fields except via TV.

                AL||AZ|| etc.


                or

                Alabama==AL||Arizona==AZ|| etc.


                4. NP doesn’t take any preHooks or postHooks (maybe someday), so you’d have to modify the code. You could probably use the code from FormIt. I think you could also just put the reCaptcha code in the form and write a plugin for OnBeforeDocFormSave that would check the submitted value. You might be able to create a TV that would show the reCaptcha image.
                  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
                  • 40045
                  • 534 Posts
                  Hi,

                  first of all, thanks for this great piece of code (it seems to be =D)!

                  I just tried to install the package for the first time follwing the tutorial at http://www.bobsguides.com/newspublisher-tutorial.html

                  I use 2.1rc4 Traditional & NewsPublisher 1.0.7b1 (could 2.1rc4 may be a problem?)

                  I created the NewsPublisher Resource with the snippet call (for the Form) and I also included the Button Snippet in my main template (for editing existing resources...), so far so good, the Button "edit" appears as expected in the bottom right corner but only as a Text with gray background (see screenshot below)



                  seems mostly unstyled, and the same goes for the Form, it’s just a plain white page with form elements...

                  Now the question (I haven’t found any screenshots of newsPublisher in action): How should it look when working correctly...I couldn’t find the link to the assets/components/newsplubisher/css/newspublisher.css file anywhere, do I have to add it manually?

                  sorry for this dumb question, but I digged through the snippets and class files in core/components/newspublisher and I couldn’t find anything that adds the css to the page [EDIT: it is there, newspublisher.class.php @ line 350]...so what I would appreciate very much are some screenshots of a working example of Newspublisher...is the Form displayed as an overlay over the existing page or does the click on the edit button open a new page (as it is now on my installation)?

                  thanks for any answer!


                  EDIT1: OK, now it’s looking much better...I changed the template of the NewsPublisher Resource from "emtpy" to the main Template and now the css is loaded (not very beautiful but it’s there =D)...but the Edit Button looks still somehow unstyled, or is this just it’s normal look (see the screenshot above)?

                  EDIT 1.1: Added some styling to my normal stylesheet for the Edit-Button:

                  	/* NewsPublisher Edit Button */
                  	input.np_edit_this_button {
                  		background: rgba(255, 255, 255, 0.75);
                  		border: 1px solid #FFFFFF;
                  		-webkit-border-radius: 3px;
                  		-moz-border-radius: 3px;
                  		border-radius: 3px;
                  		box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
                  		-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
                  		-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
                  		padding: 5px;
                  		text-align: center;
                  		width: 100px;
                  	}
                  	input.np_edit_this_button:hover {
                  		background: rgba(255, 255, 255, 1);
                  	}


                  EDIT2: Now that’s what I’m talking about...just touching the surface of this mighty component! What a great piece of code, thank you very much for sharing your work!



                  EDIT3: OK, I have 2 contexts (babel, i18n) in this particular project and NewsPublisher made some problems when redirecting after saving some changes to a resource, it seems to ignore the friendly URL stuff and just puts /index?id=x instead of alias.html...so I digged a bit into it and commented out the 2 last lines of the forward function in the newspublisher.class.php file @ lines 1230 & 1231

                              /* ToDo: The next two lines can probably be removed once makeUrl() and sendRedirect() are updated */
                              //$controller = $this->modx->getOption('request_controller',null,'index.php');
                              //$goToUrl = $controller . '?id=' . $postId;


                  and I also changed lines 1208-1210 to (just changed id to alias)

                              if (empty($postId)) {
                                  $postId = $this->existing? $this->existing : $this->resource->get('alias');
                              }


                  now it works perfectly and redirects to the edited page!
                    • 3749
                    • 24,544 Posts
                    Thanks for reporting on all that and for the kind words. I like your form -- it looks great.

                    makeUrl() wasn’t working reliably there when I created the last release, but obviously it is now. I’m glad you found that fix. The NewsPublisher page is supposed to get the default template (and it usually does). I still haven’t figured out why it sometimes installs with no template (feel free to play with the build.transport.php file at GitHub and fix that for me too 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
                      • 3749
                      • 24,544 Posts
                      BTW, your change to line 1209 ( adding ’alias’) will have no effect at all when editing existing resources (it won’t execute), but I think it will break things if you try to use NewsPublisher to create a new resource. You might want to revert 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