Newspublisher question duplicate button

Dear Bob Ray @bobray ,

I have Newspublisher 3.1.0 installed and you told me lately where to change the np-id.

Now I have an additional question because the duplicate button does not work anymore.
Message is: Permission denied. I didnt change anything else on the code by updating from version 2.1. and it worked before
Do you know why this arises?

[[!NewsPublisher?&show=`Kursart,pagetitle,alias,Bundesland,Land,Straße,PLZ,Ort,Beginn,Ende,Kursbeitrag,Bankverbindung,Kursunterlagen,content,Anmelde-E-Mailadresse,kuerzlich_geaendert,published`

&template=15
&initdatepicker=1
&required=Kursart,pagetitle,alias,Bundesland,Land,Straße,PLZ,Ort,Beginn,Ende,Kursbeitrag,Anmelde-E-Mailadresse
&parentid=39
&published=0
&aliastitle=0
&duplicatebutton=1
&deletebutton=1
&confirmdelete=1
&captions=content:Kursbeschreibung*,pagetitle:Leiter/in des Kurses*,alias:Eindeutige Kursnummer (Alias) - zb. Initialen + Nummer*,Bundesland:Angaben zum Kursort*<br/><br/>Bundesland,Anmelde E-Mailadresse: E-Mailadresse* für die Anmeldung der Teilnehmer dieser Veranstaltung,published:Jetzt veröffentlichen<br/><span style="font-size:12px;">Veranstaltung kann auch jetzt erstellt und später über "Bearbeiten" veröffentlicht werden</span>,content:Individuelle Infos Unterrichtende<br/><span style="font-size:12px;">Zusätzliche besondere Kursinfos/Wegbeschreibungen/Links zum Veranstaltungsort/Anmeldelink bei externer Organisation*</span>,kuerzlich_geaendert:Veranstaltung kürzlich geändert<br><span style="font-size:12px;">Bitte nur bei Änderungen im Zeitraum 14 Tage vor Kursbeginn verwenden!</span>
]]

Thanks a lot,
Stefan

I can’t find anything in the update that would have affected permissions. The only thing I can think of is that it should be np_id, not np-id, though I’m not sure that would cause your problem.

See if making sure the allow_modx_tags permission is checked on the NewsPublisherEditor Policy helps.

1 Like

Thanks @bobray!
The ressource_duplicate permission was missing I dont know why - maybe a Modx update changed something. Your hint brought me on the right way.

Thanks again!

I’m glad you got it sorted. Thanks for reporting back. :slight_smile:

HI bobray,
Sorry to bother you.
I have another Newspublisher issue and that is I would like to trim away all unnecessary white space at the beginning and end of the email field before the field is validated and possibly recognized as an invalid email address before it is saved. I wasn’t sure how to get a hold of you, so I linked to this thread here.

I unsure how to attach the code. I have a custom output modifier/snippet, but how can I attach something like that to a field?

Thanks a lot!

As far as I can tell, there is no built-in way to create custom validators for fields in NewsPublisher.

The only possible solutions that I can see are:

  • Adding JS code to the form that does some client-side validation.
  • Creating a custom plugin that runs on OnBeforeDocFormSave and prevents the saving, if there is no valid email-address.
  • Duplicating the snippet “NewsPublisher” and adding some code (around this line) that does the validation. Then using this new snippet instead of the original one.

An output modifier is only useful, if you output information on a page or in a chunk.

You could mention someone with the @-symbol followed by the user name (like you did in the posts above).

1 Like

Thanks again and that you gave me the hint with Javascript. Thats of course the solution onsubmit()

var $obj = $(’#someField’);
$obj.val($.trim($obj.val()); // trim object’s value

I’m pretty sure that NP does fire the OnBeforeDocFormSave and OnDocFormSave events, which is where you would normally do validation on TVs. That would work if you just want to trim the field, but the code would be somewhat tricky because of the way TVs are represented in the document save process.

Your JavaScript is a much better solution, imo.

There’s also the contact form at Bob’s Guides and the NewsPublisher Issues page at GitHub.