Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-04 19:11:52

Neko
Member
Registered: 2004-03-18
Posts: 458

zem_contact_reborn as a mail-order form?

I was trying to have ZCR to display a series fo select elements, each of them containing the title of a product that’s being sold on a web site.

Like, among the cheese they have: gorgonzola, parmigiano, cheddar. Using simple PHP I did a select via MySQL (select * from textpattern where Category1 = “cheese”) and then echoing each product title within select tags. The output I managed to obtain is exactly the following:

<label for="Gorgonzola">
	Gorgonzola<select class="zemSelect" name="Gorgonzola" id="Gorgonzola">
	<option selected="" disabled="">Quantity</option>
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
</select>
</label>

Problem is the output is OK, I can see the select elements within the HTML page, but when I push “sumbit” the fields I created with PHP are not included in the e-mail body, while all the other fields directly generated by ZCR are being displayed correctly (Name, email, message). Any idea? Thanks,

-N.

Last edited by Neko (2008-05-04 19:18:33)

Offline

#2 2008-05-04 20:00:02

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn as a mail-order form?

Instead of generating the above HTML using PHP, simply call the zem_contact_select function with the appropriate parameters:

<txp:php>
  $cheese = 'Goudse kaas';
  $quantities = ',1,2,3';
  echo zem_contact_select(array(
    'label' => $cheese,
    'list' => $quantities
  ));
</txp:php>

Last edited by ruud (2008-05-04 20:01:34)

Offline

#3 2008-05-04 20:26:14

Neko
Member
Registered: 2004-03-18
Posts: 458

Re: zem_contact_reborn as a mail-order form?

Thanks, Ruud. Problem is, for me, I’d like to have the form automatically updated whenever a new cheese should be added among the articles.

Offline

#4 2008-05-04 20:33:44

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn as a mail-order form?

Sure, but if you know how to generate HTML dynamically using PHP, you can do the same using a call to zem_contact_select (unless of course I’m misunderstanding what you’re trying to accomplish):

<txp:php>
  $cheeses = safe_query( ... );
  foreach($cheeses as $cheese) 
  {
     echo zem_contact_select( ... );
  }
</txp:php>

Offline

#5 2008-05-04 20:36:02

Neko
Member
Registered: 2004-03-18
Posts: 458

Re: zem_contact_reborn as a mail-order form?

OK, that super works, thanks a lot, Ruud:

  $cheese = $row['Title'];
  $quantities = ',1,2,3,4,5';
  echo zem_contact_select(array(
    'label' => $cheese,
    'list' => $quantities
  ));

:))))

Offline

Board footer

Powered by FluxBB