Keyword

Dynamic use of Extra Fields

  • Jason Chen
  • Jason Chen's Avatar Topic Author
  • Offline
  • New Member
More
12 years 4 months ago #61382 by Jason Chen
Dynamic use of Extra Fields was created by Jason Chen
Hi,

I'm new to Joomla and K2 and I think both are great! However, I have a question on how to properly use extra fields. I find there aren't enough practically examples out there, so hopefully, someone can help.

In particular, I am trying to read from / write to extra fields using php. Essentially, what I want to do is have an extra field called "Location". When a user creates a new item, I want to find a user's location (using some yet to be determined php code) and pre-populate the extra-field with it.

I have 2 questions. First, am I editing the right file? I'm working in itemform.php.
Secondly, I'm looking at the code:

<?php foreach($this->extraFields as $extraField): ?>
<tr>
<td align="right" class="key">
<?php echo $extraField->name; ?>
</td>
<td>
<?php echo $extraField->element; ?>
</td>
</tr>
<?php endforeach; ?>

and it appears to be just display code? So how do I go about writing code that can dynamically place data into the field?

Thanks in advance!

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


Powered by Kunena Forum