Fuhrmann
Well-known member
I am making a addon and i want to load extra data from my table.
xf_dados_posts:
dados_id
user_id
post_id
dados_date
dados_tag
dados_state
I have extended the model XenForo_Model_Post like this:
But does not work. IS there another way to do that? I want my extra data avaliable in the thread.
xf_dados_posts:
dados_id
user_id
post_id
dados_date
dados_tag
dados_state
I have extended the model XenForo_Model_Post like this:
PHP:
<?php
/**
*
* @see XenForo_Model_Post
* @author Fuhrmann
*
*/
class DadosPosts_Extend_Model_Post extends XFCP_DadosPosts_Extend_Model_Post
{
const FETCH_DADOS = 0x050;
public function getPostsInThread($threadId, array $fetchOptions = array())
{
$fetchOptions['join'] += self::FETCH_DADOS;
return parent::getPostsInThread($threadId, $fetchOptions);
}
public function preparePostJoinOptions(array $fetchOptions)
{
$selectFields = '';
$joinTables = '';
if ($fetchOptions['join'] & self::FETCH_DADOS)
{
$selectFields .= ',
dados_posts.user_id AS dados_posts.user_id,
dados_posts.post_id AS dados_posts.post_id';
$joinTables .= '
INNER JOIN xf_dados_posts AS dados_posts ON
(dados.post_id = post.post_id AND dados.user_id = post.user_id)';
}
return parent::preparePostJoinOptions($fetchOptions);
}
/**
* @return DadosPosts_Model_DadosPosts
*/
protected function _getDadosModel()
{
return $this->getModelFromCache('DadosPosts_Model_DadosPosts');
}
}
But does not work. IS there another way to do that? I want my extra data avaliable in the thread.