vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   creating plugin issue (https://vborg.vbsupport.ru/showthread.php?t=299400)

Honourable 06-22-2013 06:29 PM

creating plugin issue
 
Hi,

I would like

to run this plugin

PHP Code:

$this->registry->db->query_read_slave(("SET CHARACTER SET utf8");
$stream =  $this->registry->db->query_read_slave(("                        
            SELECT stream.*, users.* FROM " 
TABLE_PREFIX "dmods_stream AS stream
            INNER JOIN " 
TABLE_PREFIX "user AS users USING (userid)
            WHERE stream.touserid = 0 || stream.touserid = " 
$this->registry->userinfo['userid'] . "
            ORDER BY stream.dateline DESC  
        "
);

        
$streamHTML "";

while(
$item $this->registry->db->fetch_array($stream)) {

            if (
$item['type'] == 'status') {
                        
            
// Unserialize params
            
$streamdata unserialize($item['parameters']);
            
            
$templater vB_Template::create('lywomen_allstatuses');

            
$templater->register('stream'$streamdata);
            
$templater->register('streaminfo'$item);
            
            
$streamHTML .= $templater->render();

            }
}

vB_Template::preRegister('ad_global_below_navbar', array('streamHTML' => $streamHTML)); 

in this template ad_global_below_navbar

using this

PHP Code:

<ul id="webticker">
{
vb:raw streamHTML}
</
ul

and in this template lywomen_allstatuses which contains the bits

PHP Code:

<li><span class="usersign"><a href="member.php?u={vb:raw streaminfo.userid}">{vb:raw streaminfo.username}</a></span> {vb:raw stream.status}</li


I'm having a problem with the plugin as internal error for whole website once I make it activated I tried to hook the plugin in parse_templates as well as process_templates_complete also loads of hooks but non of them works

some hook places such as procces_templates_complete it does get rid of internal error yet is not doing what it suppose such as displaying data out in ad_global_below_navbar template


any suggestions as I'm makin connection to the database retrieve elements contained within a table then construct out in template

I will be more than happy if I can see any help or hint at least

Many thanks in advance :D

kh99 06-22-2013 07:06 PM

Try changing all occurences of $this->registry->db-> to $vbulletin->db-> , and use hook parse_templates.

Honourable 06-22-2013 07:07 PM

Hi,

I changed variables names maybe conflict with something else

but it still not working

PHP Code:

$streamxha =  $this->registry->db->query_read_slave(("                        
            SELECT stream.*, users.* FROM " 
TABLE_PREFIX "dmods_stream AS stream
            INNER JOIN " 
TABLE_PREFIX "user AS users USING (userid)
            WHERE stream.touserid = 0 || stream.touserid = " 
$this->registry->userinfo['userid'] . "
            ORDER BY stream.dateline DESC  
        "
);

$streamhtmlxha "";

while(
$itemxha $this->registry->db->fetch_array($streamxha)) {

                        
            
// Unserialize params
            
$streamdataxha unserialize($itemxha['parameters']);
            
            
$templater vB_Template::create('lywomen_allstatuses');

            
$templater->register('streamxha'$streamdataxha);
            
$templater->register('streaminfoxha'$itemxha);
            
            
$streamhtmlxha .= $templater->render();

}

vB_Template::preRegister('ad_global_below_navbar', array('streamhtmlxha' => $streamhtmlxha)); 

looking forward to your help

--------------- Added [DATE]1371931663[/DATE] at [TIME]1371931663[/TIME] ---------------

seconds I will try ur suggestion please dont leave

i will update u in seconds

--------------- Added [DATE]1371931850[/DATE] at [TIME]1371931850[/TIME] ---------------

I changed any occurance of $this->registry->db-> to $vbulletin->db->

adn the hook place to parse_templates

is not working unfurunately

please what do you think?

--------------- Added [DATE]1371931939[/DATE] at [TIME]1371931939[/TIME] ---------------

Also this making a huge conflict as when I browse any registered user with us it tells me
this user is not register once I disable the plugin I can browse users profile with no problem

what do you think?

note the internal error is gone now yet is not display the content that should be retrieved from db

kh99 06-22-2013 07:18 PM

Can you post again the exact code you're using?

Honourable 06-22-2013 07:19 PM

Here u go

PHP Code:

$vbulletin->db->query_read_slave(("SET CHARACTER SET utf8");
$stream =  $vbulletin->db->query_read_slave(("                        
            SELECT stream.*, users.* FROM " 
TABLE_PREFIX "dmods_stream AS stream
            INNER JOIN " 
TABLE_PREFIX "user AS users USING (userid)
            WHERE stream.touserid = 0 || stream.touserid = " 
$this->registry->userinfo['userid'] . "
            ORDER BY stream.dateline DESC  
        "
);

        
$streamHTML "";

while(
$item $vbulletin->db->fetch_array($stream)) {

            if (
$item['type'] == 'status') {
                        
            
// Unserialize params
            
$streamdata unserialize($item['parameters']);
            
            
$templater vB_Template::create('lywomen_allstatuses');

            
$templater->register('stream'$streamdata);
            
$templater->register('streaminfo'$item);
            
            
$streamHTML .= $templater->render();

            }
}

vB_Template::preRegister('ad_global_below_navbar', array('streamHTML' => $streamHTML)); 


kh99 06-22-2013 07:22 PM

Try this:

PHP Code:

$vbulletin->db->query_read_slave("SET CHARACTER SET utf8");
$stream =  $vbulletin->db->query_read_slave("                        
            SELECT stream.*, users.* FROM " 
TABLE_PREFIX "dmods_stream AS stream
            INNER JOIN " 
TABLE_PREFIX "user AS users USING (userid)
            WHERE stream.touserid = 0 || stream.touserid = " 
$vbulletin->userinfo['userid'] . "
            ORDER BY stream.dateline DESC  
        "
);

        
$streamHTML "";

while(
$item $vbulletin->db->fetch_array($stream)) {

            if (
$item['type'] == 'status') {
                        
            
// Unserialize params
            
$streamdata unserialize($item['parameters']);
            
            
$templater vB_Template::create('lywomen_allstatuses');

            
$templater->register('stream'$streamdata);
            
$templater->register('streaminfo'$item);
            
            
$streamHTML .= $templater->render();

            }
}

vB_Template::preRegister('ad_global_below_navbar', array('streamHTML' => $streamHTML)); 


Honourable 06-22-2013 07:23 PM

still not working???

--------------- Added [DATE]1371932856[/DATE] at [TIME]1371932856[/TIME] ---------------

just to let you know when I delete this bit

PHP Code:

$vbulletin->db->query_read_slave(("SET CHARACTER SET utf8"); 
$stream =  $vbulletin->db->query_read_slave(("                         
            SELECT stream.*, users.* FROM " 
TABLE_PREFIX "dmods_stream AS stream
            INNER JOIN " 
TABLE_PREFIX "user AS users USING (userid) 
            WHERE stream.touserid = 0 || stream.touserid = " 
$vbulletin->userinfo['userid'] . 
            ORDER BY stream.dateline DESC   
        "
); 

I can browse users profile but still not working the sql query seems to me is the issue
as it makes problem in the whole forum if it existed??

kh99 06-22-2013 07:28 PM

Try the above code again (I just fixed a couple things instead of posting it all again).

Honourable 06-22-2013 07:29 PM

ur last edit works great

please explain to me what was the problem I really want to learn

many thanks in advance

kh99 06-22-2013 07:31 PM

Well, first I should have told you to replace $this->registry with $vbulletin, because there was one that didn't have a ->db on it. $this is used when inside an object method. I guess you copied the code from a class definition, so those had to be changed.

Also, these two lines had extra '(' characters (in red):

Code:

$vbulletin->db->query_read_slave(("SET CHARACTER SET utf8");
$stream =  $vbulletin->db->query_read_slave(("



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

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01117 seconds
  • Memory Usage 1,798KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete