OK, das sieht schon mal nicht schlecht aus, weil er rennt zumindest in den redirect und beendet darin. Schiebe das letzte var_dump mal VOR das $this->redirect und prüfe, ob die URL die richtige ist. Das var_dump am Anfang kannst du wieder entfernen.
OK, das sieht schon mal nicht schlecht aus, weil er rennt zumindest in den redirect und beendet darin. Schiebe das letzte var_dump mal VOR das $this->redirect und prüfe, ob die URL die richtige ist. Das var_dump am Anfang kannst du wieder entfernen.
Soeben probiert:
- URL leider immernoch die falsche
- Ausgabe ist leer, d.h. einfach weisse Seite
Also wenn du das so abänderst, ändert sich gar nichts außer einer weißen Seite?
Schalte über die Sicherheitseinstellungen vom BE doch mal bitte die Fehlermeldungen AN.PHP-Code:
class MyClass
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens)
{
if (is_array($_SESSION['avisota_unsubscription'])) {
foreach ($_SESSION['avisota_unsubscription'] as $strMessage)
{
// break on error
if (preg_match('#|error$#', $strMessage))
{
return;
}
}
}
// remove the messages, alternative show this messages on the confirmation page
unset($_SESSION['avisota_unsubscription']);
// everythink is allright, redirect to confirmation page
var_dump($this->generateFrontendUrl($this->getPageDetails(61)->row()));
$this->redirect($this->generateFrontendUrl($this->getPageDetails(61)->row())); // replace X with the page id of the confirmation page
exit;
}
}
habe die Fehlermeldung jetzt mal angeschaltet. Dann kommt folgende Ausgabe, nach dem klick auf kündigen (falsche URL ist es weiterhin).
PHP-Code:
Warning: Missing argument 2 for MyClass::hookAvisotaUnSubscribe(), called in /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php on line 433 and defined in /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php on line 5
#0 /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php(5): __error(2, 'Missing argumen...', '/www/htdocs/w00...', 5, Array)
#1 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(433): MyClass->hookAvisotaUnSubscribe(Array)
#2 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(763): ModuleAvisotaSubscription->unsubscribe(Array)
#3 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleAvisotaSubscription->compile()
#4 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(548): Module->generate()
#5 /www/htdocs/w00ef2fd/system/modules/frontend/ContentModule.php(72): ModuleAvisotaSubscription->generate()
#6 /www/htdocs/w00ef2fd/system/libraries/Controller.php(511): ContentModule->generate()
#7 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(194): Controller->getContentElement('402')
#8 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleArticle->compile()
#9 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(71): Module->generate()
#10 /www/htdocs/w00ef2fd/system/libraries/Controller.php(443): ModuleArticle->generate(false)
#11 /www/htdocs/w00ef2fd/system/libraries/Controller.php(307): Controller->getArticle('59', false, false, 'main')
#12 /www/htdocs/w00ef2fd/system/modules/frontend/PageRegular.php(100): Controller->getFrontendModule('0', 'main')
#13 /www/htdocs/w00ef2fd/index.php(266): PageRegular->generate(Object(DB_Mysql_Result))
#14 /www/htdocs/w00ef2fd/index.php(401): Index->run()
#15 {main}
Fatal error: Call to undefined method MyClass::generateFrontendUrl() in /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php on line 21
Uh ja, wie dämlich von mir
Ändere die Klasse und Methode mal folgend ab:
PHP-Code:
class MyClass extends Controller
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
...
}
}
nun kommt folgender fehler bei falscher url:
PHP-Code:
Fatal error: Call to a member function prepare() on a non-object in /www/htdocs/w00ef2fd/system/libraries/Controller.php on line 595
Dann musst du vor dem $this->generateFrontendUrl noch folgendes einfügen:
PHP-Code:
$this->import('Database');
also so?
damit kommt die fehlemeldungPHP-Code:
$this->redirect($this->import('Database');$this->generateFrontendUrl($this->getPageDetails(61)->row()));
also kann der code so nicht stimmen, oder?PHP-Code:
Parse error: syntax error, unexpected ';' in /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php on line 22
Sry, das war eher so gemeint
PHP-Code:
$this->import('Database');
$this->redirect($this->generateFrontendUrl($this->getPageDetails(61)->row()));
ausgabe bei falscher url:
Code:Fatal error: Call to a member function prepare() on a non-object in /www/htdocs/w00ef2fd/system/libraries/Controller.php on line 595
Hast Du noch weitere Ideen, damit wir das zum Laufen bringen können?
kann es sein dass du VOR dem $this->import('Database') immer noch das var_dump($this->generateFrontendUrl($this->getPageDetails(61)->row())); stehen hast? Ist dann logisch das der Fehler noch kommt
Ok jetzt klappt es. sowohl die weiterleitung auf die richtige url als auch dass kein Fehler kommt.
Jetzt besteht jedoch das problem, dass der Abonnent nicht aus der Verteilerliste ausgetragen wird. er ist immer noch als "Bestätigt" hinterlegt, was ja bedeutet, dass er weiterhin den Newsletter bekommen würde.
Argh, ja stimmt, weil der Hook vor dem löschen getriggert wird.
Folgendes sollte aber funktionieren:
PHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
...
$this->remove_subscription($arrRecipient['email'], $arrRecipient['lists']);
$this->redirect($this->generateFrontendUrl($this->getPageDetails(61)->row()));
}
}
dabei sieht jetzt so aus:
damit kommt dann aber leider wieder eine fehlermeldung:PHP-Code:
<?php
class MyClass extends ModuleAvisotaSubscription
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
if (is_array($_SESSION['avisota_unsubscription'])) {
foreach ($_SESSION['avisota_unsubscription'] as $strMessage)
{
// break on error
if (preg_match('#|error$#', $strMessage))
{
return;
}
}
}
// remove the messages, alternative show this messages on the confirmation page
unset($_SESSION['avisota_unsubscription']);
// everythink is allright, redirect to confirmation page
$this->import('Database');
$this->remove_subscription($arrRecipient['email'], $arrRecipient['lists']);
$this->redirect($this->generateFrontendUrl($this->getPageDetails(61)->row())); // replace X with the page id of the confirmation page
exit;
}
}
?>
PHP-Code:
Recoverable error: Argument 1 passed to ModuleAvisotaSubscription::__construct() must be an instance of Database_Result, none given, called in /www/htdocs/w00ef2fd/system/libraries/System.php on line 176 and defined in /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php on line 56
#0 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(56): __error(4096, 'Argument 1 pass...', '/www/htdocs/w00...', 56, Array)
#1 /www/htdocs/w00ef2fd/system/libraries/System.php(176): ModuleAvisotaSubscription->__construct()
#2 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(432): System->import('MyClass')
#3 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(763): ModuleAvisotaSubscription->unsubscribe(Array)
#4 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleAvisotaSubscription->compile()
#5 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(548): Module->generate()
#6 /www/htdocs/w00ef2fd/system/modules/frontend/ContentModule.php(72): ModuleAvisotaSubscription->generate()
#7 /www/htdocs/w00ef2fd/system/libraries/Controller.php(511): ContentModule->generate()
#8 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(194): Controller->getContentElement('402')
#9 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleArticle->compile()
#10 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(71): Module->generate()
#11 /www/htdocs/w00ef2fd/system/libraries/Controller.php(443): ModuleArticle->generate(false)
#12 /www/htdocs/w00ef2fd/system/libraries/Controller.php(307): Controller->getArticle('59', false, false, 'main')
#13 /www/htdocs/w00ef2fd/system/modules/frontend/PageRegular.php(100): Controller->getFrontendModule('0', 'main')
#14 /www/htdocs/w00ef2fd/index.php(266): PageRegular->generate(Object(DB_Mysql_Result))
#15 /www/htdocs/w00ef2fd/index.php(401): Index->run()
#16 {main}
Warning: Missing argument 1 for ModuleAvisotaSubscription::__construct(), called in /www/htdocs/w00ef2fd/system/libraries/System.php on line 176 and defined in /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php on line 56
#0 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(56): __error(2, 'Missing argumen...', '/www/htdocs/w00...', 56, Array)
#1 /www/htdocs/w00ef2fd/system/libraries/System.php(176): ModuleAvisotaSubscription->__construct()
#2 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(432): System->import('MyClass')
#3 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(763): ModuleAvisotaSubscription->unsubscribe(Array)
#4 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleAvisotaSubscription->compile()
#5 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(548): Module->generate()
#6 /www/htdocs/w00ef2fd/system/modules/frontend/ContentModule.php(72): ModuleAvisotaSubscription->generate()
#7 /www/htdocs/w00ef2fd/system/libraries/Controller.php(511): ContentModule->generate()
#8 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(194): Controller->getContentElement('402')
#9 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleArticle->compile()
#10 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(71): Module->generate()
#11 /www/htdocs/w00ef2fd/system/libraries/Controller.php(443): ModuleArticle->generate(false)
#12 /www/htdocs/w00ef2fd/system/libraries/Controller.php(307): Controller->getArticle('59', false, false, 'main')
#13 /www/htdocs/w00ef2fd/system/modules/frontend/PageRegular.php(100): Controller->getFrontendModule('0', 'main')
#14 /www/htdocs/w00ef2fd/index.php(266): PageRegular->generate(Object(DB_Mysql_Result))
#15 /www/htdocs/w00ef2fd/index.php(401): Index->run()
#16 {main}
Recoverable error: Argument 1 passed to Module::__construct() must be an instance of Database_Result, null given, called in /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php on line 58 and defined in /www/htdocs/w00ef2fd/system/modules/frontend/Module.php on line 73
#0 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(73): __error(4096, 'Argument 1 pass...', '/www/htdocs/w00...', 73, Array)
#1 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(58): Module->__construct(NULL)
#2 /www/htdocs/w00ef2fd/system/libraries/System.php(176): ModuleAvisotaSubscription->__construct()
#3 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(432): System->import('MyClass')
#4 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(763): ModuleAvisotaSubscription->unsubscribe(Array)
#5 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleAvisotaSubscription->compile()
#6 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(548): Module->generate()
#7 /www/htdocs/w00ef2fd/system/modules/frontend/ContentModule.php(72): ModuleAvisotaSubscription->generate()
#8 /www/htdocs/w00ef2fd/system/libraries/Controller.php(511): ContentModule->generate()
#9 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(194): Controller->getContentElement('402')
#10 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleArticle->compile()
#11 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(71): Module->generate()
#12 /www/htdocs/w00ef2fd/system/libraries/Controller.php(443): ModuleArticle->generate(false)
#13 /www/htdocs/w00ef2fd/system/libraries/Controller.php(307): Controller->getArticle('59', false, false, 'main')
#14 /www/htdocs/w00ef2fd/system/modules/frontend/PageRegular.php(100): Controller->getFrontendModule('0', 'main')
#15 /www/htdocs/w00ef2fd/index.php(266): PageRegular->generate(Object(DB_Mysql_Result))
#16 /www/htdocs/w00ef2fd/index.php(401): Index->run()
#17 {main}
Fatal error: Call to a member function row() on a non-object in /www/htdocs/w00ef2fd/system/modules/frontend/Module.php on line 77
Ok, füge am Anfang einfach noch einen Konstruktor ein:
PHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
public function __construct()
{
$this->import('DomainLink');
$this->import('FrontendUser', 'User');
}
...
}
Das funktioniert, aber jetzt wird man wieder auf die falsche seite weitergeleitet...
Noch eine Idee?
Sry, ich war übers WE nur unterwegs, da hab ich nicht in mein Mail Postfach geschaut *g*
Das Problem ist, dass $this->remove_subscription am Ende selbst einen Redirect macht, aber auch das dürfte sich "hacken" lassen
Probiere es mal so:
EDIT: Besser ohne den Aufruf von remove_subscription, weil deinem Modul sonst alle Einstellungen fehlenPHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
...
$this->Environment->request = $this->generateFrontendUrl($this->getPageDetails(61)->row());
}
}
Geändert von tril (24.09.2012 um 07:31 Uhr)
meinst du so wie im code unten? Weiss jett nämlich gerade nicht ob ich die public function löschen muss/soll.
PHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
public function __construct()
{
$this->import('DomainLink');
$this->import('FrontendUser', 'User');
}
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
if (is_array($_SESSION['avisota_unsubscription'])) {
foreach ($_SESSION['avisota_unsubscription'] as $strMessage)
{
// break on error
if (preg_match('#|error$#', $strMessage))
{
return;
}
}
}
// remove the messages, alternative show this messages on the confirmation page
unset($_SESSION['avisota_unsubscription']);
// everythink is allright, redirect to confirmation page
$this->import('Database');
$this->Environment->request = $this->generateFrontendUrl($this->getPageDetails(61)->row()); // replace X with the page id of the confirmation page
exit;
}
}
Fast richtig, nur das exit entfernen
PHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
public function __construct()
{
$this->import('DomainLink');
$this->import('FrontendUser', 'User');
}
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
if (is_array($_SESSION['avisota_unsubscription'])) {
foreach ($_SESSION['avisota_unsubscription'] as $strMessage)
{
// break on error
if (preg_match('#|error$#', $strMessage))
{
return;
}
}
}
// remove the messages, alternative show this messages on the confirmation page
unset($_SESSION['avisota_unsubscription']);
// everythink is allright, redirect to confirmation page
$this->import('Database');
$this->Environment->request = $this->generateFrontendUrl($this->getPageDetails(61)->row()); // replace X with the page id of the confirmation page
}
}
Mit dem Code werde ich aus dem Newsletter ausgetragen. Jedoch stimmt die URL oben nicht als auch wird eine Fehlermeldung ausgegeben anstatt die URL aufgerufen:
PHP-Code:
Runtime notice: Creating default object from empty value in /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php on line 26
#0 /www/htdocs/w00ef2fd/system/modules/AvisotaCustom/MyClass.php(26): __error(2048, 'Creating defaul...', '/www/htdocs/w00...', 26, Array)
#1 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(433): MyClass->hookAvisotaUnSubscribe(Array)
#2 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(763): ModuleAvisotaSubscription->unsubscribe(Array)
#3 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleAvisotaSubscription->compile()
#4 /www/htdocs/w00ef2fd/system/modules/Avisota/ModuleAvisotaSubscription.php(548): Module->generate()
#5 /www/htdocs/w00ef2fd/system/modules/frontend/ContentModule.php(72): ModuleAvisotaSubscription->generate()
#6 /www/htdocs/w00ef2fd/system/libraries/Controller.php(511): ContentModule->generate()
#7 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(194): Controller->getContentElement('402')
#8 /www/htdocs/w00ef2fd/system/modules/frontend/Module.php(140): ModuleArticle->compile()
#9 /www/htdocs/w00ef2fd/system/modules/frontend/ModuleArticle.php(71): Module->generate()
#10 /www/htdocs/w00ef2fd/system/libraries/Controller.php(443): ModuleArticle->generate(false)
#11 /www/htdocs/w00ef2fd/system/libraries/Controller.php(307): Controller->getArticle('59', false, false, 'main')
#12 /www/htdocs/w00ef2fd/system/modules/frontend/PageRegular.php(100): Controller->getFrontendModule('0', 'main')
#13 /www/htdocs/w00ef2fd/index.php(266): PageRegular->generate(Object(DB_Mysql_Result))
#14 /www/htdocs/w00ef2fd/index.php(401): Index->run()
#15 {main}
Ich glaub ich weiß sogar schon was los ist, es gibt kein Environment Objekt ^^
->
PHP-Code:
class MyClass extends ModuleAvisotaSubscription
{
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
...
$this->import('Database');
$this->import('Environment');
$this->Environment->request = $this->generateFrontendUrl($this->getPageDetails(61)->row()); // replace X with the page id of the confirmation page
}
}
Also ich meine wir haben es. Der Code sollte jetzt funktionieren Ich werde das über die kommenden Tage nochmals ein wenig testen, jedoch glaube ich, dass wir jetzt den richtigen Code gefunden haben Daher hier für alle noch kurz die Anleitung wie ihr das auch hinbekommen könnt:
-------------------------------------------------------------------------------------------
1. Weiterleitungsseite für Abmeldung erstellen
Erstelle in der Seitenstruktur eine neue Seite (z.B. erfolgreich abgemeldet) für alle User, die sich vom Newsletter abmelden. Notiere dir von dieser Seite die Page_ID. Diese brauchst Du für Schritt 2.
2. Zwei php-Datei erstellen mit folgendem Inhalt
config.php
MyClass.phpPHP-Code:
<?php
$GLOBALS['TL_HOOKS']['avisotaUnsubscribe'][] = array('MyClass', 'hookAvisotaUnSubscribe');
?>
Hierbei das "X" ersetzen durch die Page_ID deiner gewünschten Weiterleitungsseite beim Abmelden vom Newsletter.PHP-Code:
<?php
class MyClass extends ModuleAvisotaSubscription
{
public function __construct()
{
$this->import('DomainLink');
$this->import('FrontendUser', 'User');
}
function hookAvisotaUnSubscribe($arrRecipient, $arrTokens = false)
{
if (is_array($_SESSION['avisota_unsubscription'])) {
foreach ($_SESSION['avisota_unsubscription'] as $strMessage)
{
// break on error
if (preg_match('#|error$#', $strMessage))
{
return;
}
}
}
// remove the messages, alternative show this messages on the confirmation page
unset($_SESSION['avisota_unsubscription']);
// everythink is allright, redirect to confirmation page
$this->import('Database');
$this->import('Environment');
$this->Environment->request = $this->generateFrontendUrl($this->getPageDetails(X)->row()); // replace X with the page id of the confirmation page
}
}
?>
3. Neue Ordner erstellen für das Modul (die Ordner mit roter Schrift sind neu zu erstellen):
a. /system/modules/ -> AvisotaCustom
b. /system/modules/AvisotaCustom/ -> config
4. erstelle php-Dateien hochladen:
a. Die "MyClass.php" - Datei in den Ordner /system/modules/AvisotaCustom/ laden
c. Die "config.php" - Datei in den Ordner /system/modules/AvisotaCustom/config/ laden
5. Melde Dich via dem Modul "Abonnenten verwalten" vom Newsletter ab (zuvor musst du natürlich angemeldet sein). Dann solltest Du auf die in 1. angelegte Seite weitergeleitet werden (diese vll noch mit Content füllen )!
-------------------------------------------------------------------------------------------
Vielen Dank an tril für die viele Unterstützung und die Geduld. Hoffen wir, dass das Ganze jetzt so funktioniert
VG,
David
Geändert von tril (24.09.2012 um 14:23 Uhr)
Ich habe den Hook $GLOBALS['TL_HOOKS']['avisotaActivateUnSubscribtion'][] = array('MyClass', 'hookAvisotaActivateUnSubscribtion'); mal entfernt, den gibt es nämlich gar nicht und wird auch nicht benötigt
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Lesezeichen