×
Blue Eagle 1.5.2 Released (11 Dec 2018)

The Kunena team has announce the arrival of Kunena Blue Eagle 1.5.2 which is now available for download as a native Joomla extension for Kunena 5.1. This version addresses most of the issues that were discovered in K 1.5.1 and issues discovered during the development stages of K 1.5.2.

× Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Question Add Phone and Address fields in posting

More
2 years 8 months ago - 2 years 8 months ago #1 by shawnhy
Hi,
I want to add two fields, phone number and Home address alike "e-mail" form when composing a post.



Edit [J!]/administrator/components/com_kunena/models/config.php ,about line 148, add
$lists ['showphone']              = JHtml::_('select.genericlist', $yesno, 'cfg_showphone', 'class="inputbox" size="1"', 'value', 'text', $this->config->showphone);
		$lists ['askphone']               = JHtml::_('select.genericlist', $yesno, 'cfg_askphone', 'class="inputbox" size="1"', 'value', 'text', $this->config->askphone);
		$lists ['showaddress']            = JHtml::_('select.genericlist', $yesno, 'cfg_showaddress', 'class="inputbox" size="1"', 'value', 'text', $this->config->showaddress);
		$lists ['askaddress']             = JHtml::_('select.genericlist', $yesno, 'cfg_askaddress', 'class="inputbox" size="1"', 'value', 'text', $this->config->askeaddress);
And file [J!]/administrator/components/com_kunena/template/joomla30/config/default.php, about line 473
<tr>
		<td>Phone no. required</td>
		<td><?php echo $this->lists ['askphone'] ?></td>
		<td><?php echo JText::_('COM_KUNENA_A_ASK_EMAIL_DESC') ?></td>
</tr>
<tr>
		<td>Phone number</td>
		<td><?php echo $this->lists ['showphone'] ?></td>
		<td><?php echo JText::_('COM_KUNENA_A_SHOWMAIL_DESC') ?></td>
</tr>
 
<tr>
		<td>Home Address required</td>
		<td><?php echo $this->lists ['askaddress'] ?></td>
		<td><?php echo JText::_('COM_KUNENA_A_ASK_EMAIL_DESC') ?></td>
</tr>
<tr>
		<td>Home Address</td>
		<td><?php echo $this->lists ['showaddress'] ?></td>
		<td><?php echo JText::_('COM_KUNENA_A_SHOWMAIL_DESC') ?></td>
</tr>
So far, we see 2 fields add and configurable in admin.



then I add code in file [J!]/components/com_kunena/template/blue_eagle/html/topic/edit.php
To make field visible to customers.
<?php if ($this->config->askphone) : ?>
		<tr class = "krow<?php echo 1+ $this->k^=1 ?>">
			<td class = "kcol-first"><strong>Phone No.*</strong></td>
			<td class="kcol-mid">
				<input type="text" id="phone" name="phone"  
				size="35" 
				class="kinputbox postinput required validate-phone" 
				maxlength="35" value="<?php echo !empty($this->message->phone) ? $this->escape($this->message->phone) : '' ?>" />
				<br />
				<?php echo $this->config->showphone == '0' ? JText::_('COM_KUNENA_POST_EMAIL_NEVER') : JText::_('COM_KUNENA_POST_EMAIL_REGISTERED'); ?>
			</td>
		</tr>
		<?php endif; ?>
 
		<?php if ($this->config->askaddress ) : ?>
		<tr class = "krow<?php echo 1+ $this->k^=1 ?>">
			<td class = "kcol-first"><strong>Home Address*</strong></td>
			<td class="kcol-mid">
				<input type="text" id="address" name="address"  
				size="35" class="kinputbox postinput required validate-address" 
				maxlength="35" 
				value="<?php echo !empty($this->message->address) ? $this->escape($this->message->address) : '' ?>" />
				<br />
				<?php echo $this->config->showaddress == '0' ? JText::_('COM_KUNENA_POST_EMAIL_NEVER') : JText::_('COM_KUNENA_POST_EMAIL_REGISTERED'); ?>
			</td>
		</tr>
		<?php endif; ?>



Now users are required to fill phone number and Home address and they should be seen by administrator only.

If we submit a testing post, of course administrator cannot get my hone and address, because there is no where to store these 2 values in the database. So I add two column in kunena_messages

My question is : how to write values into database?
I tried editing [J!]/components/com_kunena/controllers/topic.php but not success.

Thank you for helping
Attachments:
Last edit: 2 years 8 months ago by shawnhy. Reason: formatting

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Time to create page: 0.191 seconds