Automatic subject in e-mail form

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
tester
Posts: 76
Joined: Mon 3. Jul 2006, 20:36
Location: Århus, Denmark

Automatic subject in e-mail form

Post 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
tester
Posts: 76
Joined: Mon 3. Jul 2006, 20:36
Location: Århus, Denmark

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9906
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
tester
Posts: 76
Joined: Mon 3. Jul 2006, 20:36
Location: Århus, Denmark

Post 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
User avatar
markus s
Moderator
Posts: 654
Joined: Sat 16. Dec 2006, 19:21
Location: Radfeld / Tirol
Contact:

here is the solution

Post 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.)
moderator
propelled by fresh air from tirol
XING|FACEBOOK|OMENTO
tester
Posts: 76
Joined: Mon 3. Jul 2006, 20:36
Location: Århus, Denmark

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9906
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
photojo
Posts: 717
Joined: Wed 15. Nov 2006, 20:02
Location: Regensburg, Germany
Contact:

Re: Automatic subject in e-mail form

Post 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
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Automatic subject in e-mail form

Post 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
Last edited by flip-flop on Sat 16. Oct 2010, 07:30, edited 1 time in total.
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
photojo
Posts: 717
Joined: Wed 15. Nov 2006, 20:02
Location: Regensburg, Germany
Contact:

Re: Automatic subject in e-mail form

Post by photojo »

Ok, wieder was gelernt. Danke Knut!
Post Reply