We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9342
    • 50 Posts
    Is there anyway to use Tagger with Newspublisher? Right now I'm only be able to call the list of the tag to show in Newspublisher form, but I don't know how to assign the tag to the new post.

    <div class="newspublisher">
    <h2 id="newspublisherHeader">[[%np_main_header]]</h2>
    [[!+np.error_header:ifnotempty=`<h3>[[!+np.error_header]]</h3>`]]
    [[!+np.errors_presubmit:ifnotempty=`[[!+np.errors_presubmit]]`]]
    [[!+np.errors_submit:ifnotempty=`[[!+np.errors_submit]]`]]
    [[!+np.errors:ifnotempty=`[[!+np.errors]]`]]
    <form id="newspublisherForm" action="[[~[[*id]]]]" method="post">
    <input name="hidSubmit" type="hidden" id="hidSubmit" value="true" />
    <select name="category" value="[[+tag]]">
    [[TaggerGetTags? &showUnused=`1` &rowTpl=`tag-option` &groups=`classified`]]
    </select>
    [[+npx.insert]]
    <span class = "buttons">
    <input class="submit button" type="submit" name="Submit" value="Submit" />
    <input type="button" class="cancel button" name="Cancel" value="Cancel" onclick="window.location = '[[+np.cancel_url]]' " />
    </span>
    [[+np.post_stuff]]
    </form>
    </div>
      • 3749
      • 24,544 Posts
      I've never used Tagger, so I'm not sure how much help I can be, but if Tagger uses a TV to store the tags, you could try adding that TV to the &show property in the NewsPublisher tag and see what you get.

        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
        • 9342
        • 50 Posts
        Thank you Bob,

        The problem is that Tagger does not use TV to store the tags. I'm not so sure that the lexicon "tagger.tag.assigned_resources_to" is the one that will be the one that I'll will use in the "value" property.
          • 3749
          • 24,544 Posts
          I'm afraid it isn't going to work. The tagger plugin looks for the tags to be set as resource fields during OnDocFormSave. That event will fire when NP saves a resource, but the fields that would contain the Tagger values won't be set as resource 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
            • 9342
            • 50 Posts
            Thank you for looking at it, Bob. Do you have any idea how to show a drop-down list from the pre-defined tag?
              • 3749
              • 24,544 Posts
              Sorry, I don't know enough about Tagger to suggest anything.

              It occurred to me that if you can get the regular Tagger UI to appear on the NP page, you could write some JavaScript and a processor that you call with Ajax to update the Tagger data via an "Update Tags" button. You'd have to understand Tagger much better than I do to accomplish it, though.
                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
                • 9342
                • 50 Posts
                Thank you anyway Bob.
                  • 29661
                  • 116 Posts
                  You will have to create your own snippet to generate select with tags and than hook the saving into NP.

                  If NP doesn't have any kind of hook (for example like FormIT has), that it's probably not going to work very well. You would have to do AJAX save, when you change tag in the select, but this can be done only on update, because it needs resource's ID.
                    --
                    John
                    @theboxer
                    • 3749
                    • 24,544 Posts
                    The current version of NP has no hooks, but it calls the resource create and update processors on every successful save, so a plugin attached to OnBeforeDocFormSave or OnDocFormSave would execute.

                    I believe the $_POST variables would be available there, though I'm not sure. If not, $_SESSION variables would.
                      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
                      • 29661
                      • 116 Posts
                      In that case, if you create a field with name "'tagger-GROUP_ID" and it will contain valid value, it should be linked by Tagger plugin with a resource.
                        --
                        John
                        @theboxer