Page 1 of 1

Automatic subject in e-mail form

Posted: Fri 28. Sep 2007, 18:45
by tester
Hi!

I would like to set up an e-mail form with some reference to the article from which it was sent.

Imagine a store with different products all presented in their own articles.

I want the customers to be able to fill out a form with inquiries of the specific products.

Is it possible to put this form in the template and maybe with some {RT} to get the article reference or do I have to manually set up a form for every new procuct and hard code the article reference?

Any ideas

thanx :D
tester

Posted: Tue 2. Oct 2007, 10:20
by tester
Hi!

No ideas?

Well this is what I've figured out myself - please tell me if its wrong or even stupid to do so!

I'm not using keywords on this site so if I put the product name or reference ID in the keyword for the article I can set up a link like this in the template:

Code: Select all

<div id="infoicon">
<a href="info.php?name=[PHP]print $GLOBALS["content"]["all_keywords"];[/PHP]" target="_blank">Info</a>
</div>
info.php is a php-script with an E-mail form set up to catch the variable "name" in the subject..

This way there is only need for one form for all the articles.

I would like to use the internal content part "form" of phpwcms but haven't been able to figure out how to make this form accept variables in the subject fild of an E-mail.

Any ideas? :D
tester

Posted: Sun 7. Oct 2007, 09:18
by Oliver Georgi
it's not possible by default - but with little PHP in frontend render and hidden field with default value it is working. But only for phpwcms which supports subjects based on field value.

Oliver

Posted: Sun 7. Oct 2007, 13:55
by tester
Hi!

Sorry but I don't understand :)
with default value it is working. But only for phpwcms which supports subjects based on field value.
Best regards
tester

here is the solution

Posted: Sun 7. Oct 2007, 18:12
by markus s
ok - if you want the name of the artikel in the mail subject,
to identify your contact forms you need a new .php file in your frontend render.

german:
ich hatte das problem, dass ich mehrere "CP artikel" hatte in denen sich alle ein kontaktformular
befindet. (für kursanmeldung) nun brauche ich, nachdem sich ein kunde über das kontaktforumlar
angemeldet hat, die info zu diesem kurs ohne, dass dies der kunde extra eintragen muss. und so gehts

1.
make in your contact form a "hidden field" with name "mailsubject".
Image
type in the field "Value":

Code: Select all

[%GLOBAL_FORM_SUBJECT%]
and save this.
2.
choose in the top ob the form under "subject" the "Form: mailsubject"
Image
3.
make a file at your editor with the following content:

Code: Select all

<?php
$content['all'] = str_replace('[%GLOBAL_FORM_SUBJECT%]', trim('your own text: ' . html_specialchars($content['article_title'])), $content['all']);
?>
save file with the name "email_subject.php" under template/inc_script/frontend_render

or simply download the finished file HERE (email_subject.zip)
4.
now the article title is seen in the subject from your email - now, you can ident the different contact forms ...

much fun ...
(thx to O.G.)

Posted: Sun 7. Oct 2007, 21:00
by tester
Thanx markus s! :D

Maybe I didn't make my point clear or maybe I don't understand your solution. :?

I'm setting up a site for a customer who will add a lot of articles describing different products. I don't want him(my customer) to set up a form for every product. I want to "call" a form from the template with some sort of identification of the current article.

Hope this will clarify my intentions :D

Best regards
tester

Posted: Sun 7. Oct 2007, 22:10
by Oliver Georgi
This is described also a thousand times inside the forum - working like "send a friend".

Use an article with content part based on your needs outside public access.

Then use {SHOW_CONTENT:CP,ID} (ID = ID of the content part form) inside of your template.

It's no "out of the box" solution - but as I said it is discussed somewhere here in the forum.

Oliver

Re: Automatic subject in e-mail form

Posted: Fri 15. Oct 2010, 16:08
by photojo
Hallo,

ich habe das entsprechend meinen Bedürfnissen angepasst:

Code: Select all

<?php

// Ersetze Hidden mailsubject - vpn Oliver Georgie/PHPWCMS am 19.08.2007
// iniziert für DVA - Markus SChartner

$content['all'] = str_replace('[%reise_ziel%]', trim('Buchungsanfrage für ' . html_specialchars($content['article_title'])), $content['all']);
$content['all'] = str_replace('[%reise_zeit%]', trim('am ' . html_specialchars($content['article_subtitle'])), $content['all']);
?>
Leider wird der article_subtitle-Tag (hier Zeile 2) nicht umgesetzt, d.h. das Formularfeld bleibt leer. Mit article_id z. b. geht jedoch ohne Probleme. Woran liegt das?

Danke, Jo

Re: Automatic subject in e-mail form

Posted: Fri 15. Oct 2010, 22:00
by flip-flop
Hi,

mach mal ein

Code: Select all

dumpVar($content);
bzw. 
dumpVar($content['articles']);
Nach dem ersten Schock wirst du staunen .....

Die Variable

Code: Select all

$content['article_subtitle']
ist nicht ausgeführt, jedoch die ID mit

Code: Select all

$content['article_id']
und alle Artikel der aktuellen Ebene mit vielen Parametern im Array

Code: Select all

$content['articles']
unter anderem auch der SubTitle.

Somit erreichst du mit

Code: Select all

$content['articles'][$content['article_id']]['article_subtitle']
den Untertitel :idea:


Knut

Re: Automatic subject in e-mail form

Posted: Sat 16. Oct 2010, 06:50
by photojo
Ok, wieder was gelernt. Danke Knut!