Is this a problem in the web context too, or just in the other context?The problem occurs in the web context too. The <base/> tag is set correctly.
//$controller = $this->modx->getOption('request_controller',null,'index.php'); //$goToUrl = $controller . '?id=' . $postId;
$css = $this->assetsUrl . 'components/newspublisher/css/' . $this->props['cssfile'];
[[!NpEditThisButton?id=`[[+id]]` &np_id=`1`]]
$css = $this->assetsUrl . 'components/newspublisher/css/' . $this->props['cssfile'];
$css = $this->assetsUrl . 'css/' . $this->props['cssfile'];
<?php
/**
* Modified version of NpEditThisButton of the Newspublisher extra (Copyright 2011 Bob Ray),
* with an additional parameter for specifying the ID of the target resource to be edited
* (e.g. for use with getResources).
* The button can be styled by its CSS class (np_edit_this_button)
* example: [[!NpEditThisButton?id=`5` &np_id=`2`]]
*
* @property $npId (int) - ID of newspublisher page (set automatically on first run).
* @property $id (int) - ID of resource to be edited
* @property $noShow - Comma-separated list of IDs of documents
* on which the button should not be displayed. Defaults to
* home page, and NewsPublisher page.
* @property $buttonCaption (optional -- not actually a parameter) -
* Caption for edit button.
* Defaults to np_edit language string or "Edit" if empty.
* @property $language (optional) - Language to use for error messages.
* @property $debug (optional) - Displays the button on all pages with
* either the $buttonCaption, or a message explaining why it
* would not be shown.
*
*/
$language = $modx->getOption('language', $scriptProperties, null);
$resource = empty($scriptProperties['id']) ? $modx->resource : $modx->getObject('modResource', $id);
$language = $language ? $language . ':' : '';
$modx->lexicon->load($language . 'newspublisher:button');
/* Caption for edit button */
$debug = $modx->getOption('debug', $scriptProperties, false);
$buttonCaption = $modx->lexicon('np_edit');
$buttonCaption = empty($buttonCaption) ? 'np_edit' : $buttonCaption;
/* value will be unchanged if there are no errors */
$value = $buttonCaption;
$npId = $modx->getOption('np_id', $scriptProperties, '');
/* set the np_id property to the ID of the NewsPublisher page
* on first run if possible, error message if not */
if (empty($npId)) {
$npObj = $modx->getObject('modResource', array('pagetitle' => 'NewsPublisher'));
$success = true;
if ($npObj) {
$npId = $npObj->get('id');
$npObj = $modx->getObject('modSnippet', array('name' => 'NpEditThisButton'));
if ($npObj) {
$props = array(
array(
'name' => 'np_id',
'desc' => 'np_id_desc',
'type' => 'numberfield',
'options' => '',
'value' => $npId,
'lexicon' => 'newspublisher:button',
),);
if ($npObj->setProperties($props, true)) {
$npObj->save();
unset($npObj);
} else {
$success = false;
}
} else {
$success = false;
}
} else {
$success = false;
}
/* Failed - turn on debug to error message will display in button */
if (!$success) {
$value = $modx->lexicon('np_no_np_id');
$debug = true;
}
}
$modx->setPlaceholder('np_id', $npId);
if ($resource == null) {
$value = 'No resource of ID '.$scriptProperties['id'];
$id = '0';
} else {
$id = $resource->get('id');
/* check permissions on current page */
if (!$modx->hasPermission('edit_document')) {
$value = $modx->lexicon('np_no_edit_document_permission');
}
if (!$modx->hasPermission('save_document')) {
$value = $modx->lexicon('np_no_context_save_document_permission');
}
if (!$resource->checkPolicy('save')) {
$value = $modx->lexicon('np_no_resource_save_document_permission');
}
/* Don't show on the the home page */
if ($id == $modx->getOption('site_start')) {
$value = $modx->lexicon('np_no_edit_home_page');
}
/* Don't show if current page is in the noShow list */
$noShow = $modx->getOption('noShow', $scriptProperties, '');
if (empty($noShow)) {
$noShow = $npId . ',' . $modx->getOption('site_start');
}
$hidden = explode(',', $noShow);
$hidden[] = $npId;
if (in_array($id, $hidden)) {
$value = 'In noShow list';
}
}
/* create and return the form */
$output = '<form action="[[~[[+np_id]]]]" method="post" class="np_button_form">';
$output .= "\n" . '<input type = "hidden" name="np_existing" value="true" />';
$output .= "\n" . '<input type = "hidden" name="np_doc_id" value="' . $id . '"/>';
$output .= "\n" . '<input type="submit" class = "np_edit_this_button" name="submit" value="' . $value . '"/>';
$output .= "\n" . '</form>';
/* Not OK -- don't show button unless debug is on */
if (($value != $buttonCaption) && !$debug) {
$output = '';
}
return $output;

I did the getObject() call for knowing if there is any resource with this ID and otherwise displaying an error message button if debug=`1`. But I don’t know if this is the best method. It might also have a performance impact, especially if there are multiple buttons per page...
I admit that this might be a very uncommon case...
