questions on 'Creating a add-on to insert tabs in profile page (using hooks) - Part 4'

typostudy

Member
I am reading this tutorial:
Creating a add-on to insert tabs in profile page (using hooks) - Part 4(http://xenforo.com/community/resour...rofile-page-using-hooks.335/update?update=488)

I have several questions:

1.
Step 8 - Input text field and "Send" button
Code:
<input type="submit" value="Send" accesskey="s" class="button primary">
how could I find the definition of this class:primary, if I want to change its value?

2.
Code:
<xen:avatar user="$note.user" size="s" class="icon" />
I checked this file: XenForo\Template\Compiler\Tag\Avatar.php,
Code:
public function compile(XenForo_Template_Compiler $compiler, $tag, array $attributes, array $children, array $options)
but it does not have such parameters: size, class, so how could I know all the available options(size,class..) for avatar? and how to use them?

3.
Step 10 - Create a DataWriter to manipulate data
In library\newProfileTabs\DataWriter\Notes.php, we have several functions here:
Code:
class newProfileTabs_DataWriter_Notes extends XenForo_DataWriter
{
  protected function _getFields(){}
  protected function _getExistingData($data){}
  protected function _getUpdateCondition($tableName){}
}
In library\newProfileTabs\Extend\ControllerPublic\Member.php, we have:

Code:
  $dw = XenForo_DataWriter::create('newProfileTabs_DataWriter_Notes');
    $dw->set('given_user_id', $visitor['user_id']);
    $dw->set('received_user_id', $userId);
    $dw->set('note_message', $note_message);
    $dw->set('note_date', $note_date);
    $dw->save();
But it seems that we did not use those functions we created in DataWriter\Notes.php: _getFields,_getExistingData,_getUpdateCondition, so why?
 
1) primary will be a class defined somewhere in the XenForo css files. Search templates for titles containing .css. You should be adding additional classes to that HTML rather than amending the existing class CSS.

2) Best example is to see how this is used elsewhere in the existing code. Search templates for contents "<xen:avatar". In actual fact, the tag compiler you have seen returns XenForo_Template_Helper_Core::callHelper('avatarHtml') so you may get a better idea of usage that way.

3) Those three functions are necessary for DataWriters to run. The first defines the fields and the properties of each field - you can set here the field type, max length, required, pass a validation call back. Although you don't directly use them yourself in the code, they are very much used in the background. Same applies to _getExistingData and _getUpdateCondition. They're necessary to ensure that in the case of data updates and fetching existing data that the correct data is worked with. You don't use them when you're simply setting and saving, but if you were updating an existing record then they would be used.
 
Last edited:
Back
Top Bottom