×
Kunena 5.2 Beta 1 Released (24 Sep 2020)

The Kunena team is thrilled to announce the first public beta release of Kunena 5.2, a native Joomla extension for Joomla 3.9. This is a development release and should be only be used for testing; this version is not recommended for live websites at this stage.

The purpose of this release is to encourage testing by downloading, installing and identifying any problems or shortcomings that people may discover. K 5.2.0 B1 is stable and we are aware that people will discover defects. We encourage you to use the forum to report defects, as soon as they are discovered, so that the development team can work through the problems before the release of K 5.1 as a stable product. Reporting defects does not mean that the problems can or will be fixed. The Kunena team is looking forward to hearing your feedback on how well we have achieved our design goals.

× 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
4 years 5 months ago - 4 years 5 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: 4 years 5 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 edit your message.
Time to create page: 0.771 seconds