hello,
i'm bussy on writing a plugin. but after a while i have the idea that what i'm doing is not right.
i do the output to the webpage with echo "...." but i think i have to parse the output somehow to the template.
but how do i do that.
i use a table to display the user attachments. but i realy would do this in the template.
i used this link to add a extra members tab
https://vborg.vbsupport.ru/showthrea...light=profile*
This is done good, the template it self is not altert, the plugin so far i have now is below.
how do i output everything to the template. a specialy the table.
there should be a better way than i did.
please need help and or suggestions.
as i have solved this, there should be :
above the table a page navigation
in admincp-> options a settingsfield where maxcol,maxrow, .... can be alterd.
there should be an ability to alter te language of the outputed data.
but hese are all next steps in my project.
i have searched the inet but i'm getting stucked here.
i think the messed up left colum would be oke if i put the stuff in the template.
PHP Code:
$maxcolum = 4;
$maxrow = 4;
$maxwidth = 200;
$maxheight = 200;
$page = $vbulletin->input->clean_gpc('r', 'page', TYPE_INT);
$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'Bijlagen',
'hook_location' => 'profile_left_last'
)
));
class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';
function confirm_empty_wrap()
{
return false;
}
function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}
function prepare_output($id = '', $options = array())
{
global $maxcolum, $maxrow, $maxwidth, $maxheight, $vbulletin, $page;
$colum = 0;
$forumids= null;
$perpage = $maxcolum * $maxrow;
foreach ($vbulletin->userinfo['forumpermissions'] AS $vbulletin->foruminfo[forumid] => $perm)
{
if (($perm & $vbulletin->bf_ugp_forumpermissions['canview']))
{
$forumids .= ','.$vbulletin->foruminfo[forumid];
}
}
$attachments = $vbulletin->db->query_read("
SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
thread.title, thread.open
FROM vb3_attachment as attachment
LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
WHERE attachment.userid = ".$this->profile->userinfo['userid']. "
AND (
thread.forumid IN(0$forumids)
AND thread.visible = 1
AND post.visible = 1
AND deletionlog.primaryid IS NULL)");
$totalattachments = $vbulletin->db->num_rows($attachments);
$totalpages = ceil($totalattachments / ($perpage));
$perpage = $maxcolum * $maxrow;
$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_UINT,
'pagenumber' => TYPE_UINT,
));
$attachments = $vbulletin->db->query_read("
SELECT attachment.attachmentid, attachment.contentid, attachment.userid, post.postid, post.threadid, post.visible,thread.forumid,
thread.title, thread.open
FROM vb3_attachment as attachment
LEFT JOIN vb3_post AS post ON (post.postid = attachment.contentid)
LEFT JOIN vb3_thread as thread on(post.threadid = thread.threadid)
LEFT JOIN vb3_deletionlog AS deletionlog ON(attachment.contentid = deletionlog.primaryid AND type = 'post')
WHERE attachment.userid = ".$this->profile->userinfo['userid']. "
AND (
thread.forumid IN(0$forumids)
AND thread.visible = 1
AND post.visible = 1
AND deletionlog.primaryid IS NULL) limit ".($page*$perpage). ",". (($page+1)*$perpage));
$output = "";
$output .= "<br>Totaal aantal bijlagen ".$totalattachments. "<br>Huidige pagina : ". $curentpage. " van ". $totalpages. "
URL page : ".$page."<br>
<table border=1>";
while ($post = mysql_fetch_array($attachments))
{
if ($colum == 0) {$output .= "<TR>";}
$output .= "<td width=".$maxwidth." height=".$maxheight."><a target=blank href=attachment.php?attachmentid=".$post['attachmentid']."/>
<img border=0 src=attachment.php?attachmentid=".$post['attachmentid']."&thumb=1 width=100% height=100%/>
</a></td>" ;
$colum = $colum + 1;
if ($colum == $maxcolum){
$colum = 0;
echo "</tr>";
}
}
$output .= "</table>";
$this->block_data['mymodification'] = $output;
}
}
and a screenshot of the outputed data.