Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-29-2009, 06:32 AM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default need help on building output in template

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 tabhttps://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;
        
$forumidsnull;
                
        
$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.
Attached Images
File Type: jpg screen.jpg (117.3 KB, 0 views)
Reply With Quote
  #2  
Old 12-29-2009, 02:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see what the stuff you've circled in red in your image has to do with your code. The code you wrote just adds a tab to your profile, which is seen on the right in your image. I don't see any code that outputs anything where you circled stuff in red.
Reply With Quote
  #3  
Old 12-29-2009, 04:05 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no that happend when i run my code.

that is a side affect. it is somthing i work on later.

it's more like should i rewrite te template so that it gets it's data from the plugin.
or do i create the output in the plugin itself.

if i have to rewrite the template where do i start, i couldn't find resources that helpt me with this problem. so please help me.

ps. forget the red circel, this is a side effect from my plugin.
Reply With Quote
  #4  
Old 12-29-2009, 05:53 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can either output the html directly from the plugin or use templates. It really doesn't matter which way you do it. I have a couple of added tabs on my site and I use templates in one of them and just output html in the other. So, it's personal preference.
Reply With Quote
  #5  
Old 12-30-2009, 01:56 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so what i do is pretty normal.

can i use sanitize_pageresults in a plugin so that it render a peace of code to insert in my page?

i had to try this befor using this link but there where some errors.

how do i use sanitize in a plugin?
Reply With Quote
  #6  
Old 12-31-2009, 05:10 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you create a template memberinfo_block_mymodification? What does it look like? (Did you make it similar to the other memberinfo_block_* ?)
Reply With Quote
  #7  
Old 12-31-2009, 05:50 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of you follow the first post that is what i put in my template. It looks like it feta à wrong class in it's div. I don't how to alter this. It looks like it's somewhere hardcoded
Reply With Quote
  #8  
Old 12-31-2009, 05:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The old template will not work for vb4.
Reply With Quote
  #9  
Old 12-31-2009, 07:02 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oke but how do i fix it ?

do i need to register the outpu and put it that way in my template ?
Reply With Quote
  #10  
Old 12-31-2009, 07:50 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The only data that gets spit out in the template is the block_data ({vb:raw block_data.mymodification})which you are defining in the plugin, so you don't need to register any variables.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06583 seconds
  • Memory Usage 2,329KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete