Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-30 18:26:32

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

How do I add an article title to my code...

Hi all,

sorry for what may appear to be an easy question – but i can’t seem to find the answer.

i have a contact form – using Zem’s ‘zem_contact’ – that appears at the bottom of some articles on my site.

what i want is to be able to insert the article title into this form, so that when the user submits, I know which page it was sent from.

i know ‘txp:title’ will display from a form, but i really need to do this in the presentation window, so that it will insert the title as a piece of text inside the code…

been looking for a solution, but there seems none to be found…

any ideas??

thanks!
luke


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#2 2006-08-31 04:33:48

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,393
Website GitHub Mastodon

Re: How do I add an article title to my code...

You can add any inormation to the message zem_contact sends by adding a member to the array it uses as a storage for its values, $zem_contact_form. It requires a small portion of PHP, though, see below:

<txp:zem_contact to="noone@domain.invalid">
<txp:php>
global $zem_contact_form;
// insert post title here, will be e-mailed with an 'article-title:'  prefix
$zem_contact_form['article-title'] = title(array());
</txp:php>
<txp:zem_contact_text label="Name" required="yes" break="" name="name" />
<!-- any other commonly used zem_contact tag -->
[...]
</txp:zem_contact>

Done!

Last edited by wet (2006-08-31 04:35:04)

Offline

#3 2006-08-31 09:00:34

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: How do I add an article title to my code...

ahh splendid. thanks so much!


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#4 2006-08-31 13:10:27

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: How do I add an article title to my code...

hmm… i tried the php above. it certainly added ‘article title:’ to the email received, but no article title was in there! … i’m afraid i don’t know enough about PHP to figure out why!


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#5 2006-08-31 13:23:59

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,393
Website GitHub Mastodon

Re: How do I add an article title to my code...

If you add <txp:title /> just above the <txp:zem_contact_form to=... > tag, does it display anything?

Offline

#6 2006-08-31 13:45:39

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: How do I add an article title to my code...

it doesn’t appear to do anything.

here is the page in question fyi: http://www.farfrontiers.org/new_site/rgs/tibet

i have the input fields in a separate form, that is called by ‘txp:zem_contact form=’ … i put the php above at the bottom of the form, and as said it prints ‘article-title:’ as required.

i just put ‘txp:title’ at the top of the form, but it does nothing. the title you see on the page i’ve linked to above is pulled separately, and nothing to do with ‘zem_contact’


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#7 2006-08-31 16:11:54

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,393
Website GitHub Mastodon

Re: How do I add an article title to my code...

Then it won’t work.

You’ve got to be in an article context in order to have access to the current article’s properties, i.e. include zem_contact into your article form somehow (either direct or via txp:output_form). The upcoming Txp 4.0.4 will even issue warnings whenver it encounters an improper (out of article context) use of article related tags like txp:title.

Offline

#8 2006-08-31 20:27:31

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: How do I add an article title to my code...

ok, i get it now… i need to put the entire form in a textpattern ‘form’ and then call with an ‘txp:article’ tag… it works perfectly now, thanks for your help.


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

Board footer

Powered by FluxBB