Skocz do zawartości

Rekomendowane odpowiedzi

Opublikowano

Witam,

Dokonuję modyfikacji rozszerzenia "Recent post", chcę uzyskać efekt wyświetlania ostatnich postów taki sam jak w "Najnowszych tematach". Natrafiłem na jeden problem mianowicie: avatar osoby, która napisała ostatni post nie wyświetla się, mimo to linkuje avatar do profilu użytkownika. Problem przedstawiam na screenie. Prawdopodobnie problem tkwi w <img>. Czy ktoś może mi dać wskazówki jak powinien wyglądać poprawnie kod.

postyg.png

<div class='ipsSideBlock clearfix'>
  <h3>Najnowsze posty</h3>
  <div class='_sbcollapsable'>
  <ul class='ipsList_withminiphoto'>
	 <foreach loop="posts:$recentPosts as $post">
	    <li class='clearfix'>
		   <a href='{parse url="showuser={$post['last_poster_id']}" seotitle="{$post['seo_last_name']}" template="showuser" base="public"}' title='{$this->lang->words['view_profile']}' class='ipsUserPhotoLink left'>
<img src='{$post['pp_mini_photo']}' alt="{parse expression="sprintf($this->lang->words['users_photo'],$post['members_display_name'])"}" class='ipsUserPhoto ipsUserPhoto_mini left' />

<div class='list_content'>
<a href='{parse url="showtopic={$post['tid']}" base="public" template="showtopic" seotitle="{$post['title_seo']}"}' rel='bookmark' class='ipsType_small' title='{$this->lang->words['view_topic']}'>{$post['title']}</a>
<p class='desc ipsType_smaller'><a href='{parse url="showuser={$post['last_poster_id']}" base="public" seotitle="{$post['seo_last_name']}" template="showuser"}'>{$post['last_poster_name']}</a> - {$post['last_post']}
												    </p>
										    </div>
								    </li>
						    </foreach>
				    </ul>
  </div>
</div>

Pozdrawiam

Opublikowano (edytowane)

if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class boardIndexRecentPosts
{
public function __construct()
{
	$this->registry = ipsRegistry::instance();
	$this->DB = $this->registry->DB();
	$this->settings =& $this->registry->fetchSettings();
	$this->memberData =& $this->registry->member()->fetchMemberData();
}

public function getOutput()
{
	if($this->settings['hsc_rp_groups']!='' && !in_array($this->memberData['member_group_id'],explode(",",$this->settings['hsc_rp_groups'])))
		return '';

	$topics = $this->_getTopics();
	if(!is_array($topics) || !count($topics))
		return '';

	foreach($topics as $id => $t)
	{
		if($this->settings['hsc_rp_post']!='N')
			$topics[$id]['post'] = $this->_formatPost($t['post']);

		$topics[$id]['start_date'] = $this->_formatDate($t['start_date']);
		$topics[$id]['last_post'] = $this->_formatDate($t['last_post']);
	}

	return $this->registry->output->getTemplate('boards')->recentPosts($topics);
}

private function _getTopics()
{
	$forumIds = $this->_loadForumIds();
	if(!is_array($forumIds) || !count($forumIds))
		return '';

	$query = array('select' => 't.*',
					'from' => array('topics' => 't'),
					'where' => "t.state='open' and t.approved=1 and t.forum_id in (".implode(",",$forumIds).")",
					'order' => 't.last_post desc',
					'limit' => array(0,$this->settings['hsc_rp_limit']));

	$query['add_join'][] = array('select' => 'f.name as forum_name, f.name_seo as forum_name_seo', 'from' => array('forums' => 'f'), 'where' => 't.forum_id=f.id', 'type' => 'left');

	if ($this->settings['hsc_rp_post'] == 'F')
	{
		$query['add_join'][] = array('select' => 'p.pid, p.post',
									'from' => array('posts' => 'p'),
									'where' => 't.topic_firstpost=p.pid',
									'type' => 'left');
	}

	$this->DB->build($query);
	$tQuery = $this->DB->execute();
	while($t = $this->DB->fetch($tQuery))
	{
		if($this->settings['hsc_rp_post']=='L')
		{
			$post = $this->DB->buildAndFetch(array('select' => 'pid,post', 'from' => 'posts', 'where' => 'topic_id='.$t['tid'],
							'order' => 'post_date desc', 'limit' => array(0,1)));
			$t = array_merge($t,$post);
		}
		$topics[] = $t;
	}

	return $topics;
}

private function _formatPost($post)
{
	// Strip out line breaks or the regex does not work
	$post = preg_replace('/[\n\r]/i','',$post);

	// Strip out quotes
	$post = preg_replace('/\[quote(.*?)\[\/quote\]/i','',$post);

	// Strip out emoticon images
	$post = preg_replace('/<img(.*?)\/>/i','',$post);

	// Strip out other images
	$post = preg_replace('/\[img(.*?)\[\/img\]/i','',$post);

	$post = $this->_parseBBCode($post);

	if($this->settings['hsc_rp_postlimit'] > 0 && strlen($post) > $this->settings['hsc_rp_postlimit'])
		$post = IPSText::truncate($post, $this->settings['hsc_rp_postlimit']);

	$post = strip_tags($post);
	return $post;
}

private function _formatDate($date)
{
	return $this->registry->class_localization->getDate( $date, SHORT );
}

private function _parseBBCode($post)
{
	IPSText::stripAttachTag($post);

	IPSText::getTextClass( 'bbcode' )->parse_smilies   = 1;
	IPSText::getTextClass( 'bbcode' )->parse_html	= 1;
 IPSText::getTextClass( 'bbcode' )->parse_nl2br	= 1;
 IPSText::getTextClass( 'bbcode' )->parse_bbcode	= 1;
 IPSText::getTextClass( 'bbcode' )->parsing_section   = 'topics';
 IPSText::getTextClass( 'bbcode' )->parsing_mgroup   = $this->memberdata['member_group_id'];
 IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $this->memberData['mgroup_others'];

 return IPSText::getTextClass('bbcode')->preDisplayParse( $post );
}

private function _loadForumIds()
{
	$forums = $this->registry->getClass('class_forums')->fetchSearchableForumIds();

	if ($this->settings['hsc_rp_forums'] != '')
	{
		foreach(explode(",",$this->settings['hsc_rp_forums']) as $f)
		{
			if(in_array($f,$forums))
				$forumIds[] = $f;
		}
		if(!is_array($forumIds) || !count($forumIds))
			return;

		return $forumIds;
	}

	return $forums;
}
}
?>

Edytowane przez Jakub
Dodano spoiler
  • Manager
Opublikowano

Musisz dodać takiego joina:

           array( 'select' => 'pp.*',
                               'from'   => array( 'profile_portal' => 'pp' ),
                             'where'  => 'pp.pp_member_id=t.starter_id',
                             'type'   => 'left' );

Generalnie ja bym polecał użyć IPSMember::load() do tego, a nie takie 'dziadowanie'. :)

  • Lubię to 1

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

  • Manager
Opublikowano

Problem ROZWIĄZANY. Jeśli są jakiekolwiek wątpliwości, pytania proszę o założenie nowego tematu.

Wszelkie uzasadnione reklamacje/pretensje/sugestie/rady przyjmuje ekipa forum.

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.