vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=260744

postbit_legacy template editing error
by ninadbe
21 Mar 2011 22:05

I am editing postbit_legacy at "template" table. I want to displaye some images extracted from remote server after 1st post.
My code is as follows

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

After editing postbit_legacy with above customized code, I am getting following error


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

When remote server connection string code is removed, I am not getting any errors.

It seems like I am getting error because existing connection is active


Please help me with this problem.

Thanks

Lynne 21 Mar 2011 23:56

I'm not sure exactly what you are saying, but you said your were editing the template via the table? Do you mean you were editing it directly in the database? Please don't do that. You should be editing it via the admincp > style manager > find style > edit templates. Also, you cannot put php in templates. Templates are for html only. If you need the output from some php to show up in a template, then you need to create a plugin to run the php code and assign the output to a variable that you would then put into the template.

ninadbe 22 Mar 2011 00:05

Yes I were editing templates at database through phpmyadmin.

Is there any help topic regarding how to create plugin and implement output in template?

Lynne 22 Mar 2011 00:16

I would suggest download a mod that does that to see how it was done. I'm not sure if there is a help topic because I haven't actually looked for one, but you can take a look in the vB4 Articles forum for one.

ninadbe 23 Mar 2011 17:45

Can you please suggest me any plugin that uses remote database connection or use to extract data from other server?
We have vbulletin forum for our site, but our site is located on one server and forum located on another server in order to avoid load.
I want to extract data from main site (which is located on another server) and display it on forum.

I tried lot , searched everywhere. But I not found any specific plugin / mod.

I created custom plugin on my own but it giving errors like
"MySql client ran out of memory"
"Invalid key error"

Please any help would be appreciated.

Thanks

Lynne 23 Mar 2011 18:10

Connecting to the database is something you set up in the config.php file. If it is set up correctly there, then you just make a database call and the config.php file points to the correct database. (I have my database on a different server and it works just fine).

Those errors you posted - running out of memory and invalid key error, are server errors and you should talk to your host about them.

ninadbe 23 Mar 2011 18:24

I am connecting to the my main site database not vbulletin database.

My vbulleting forum and database are on same server , but main site and its databse are on another server.

I linked forum with main site via Menu Tab.

At config.php I think there is setting for vbulletin database.

Lynne 23 Mar 2011 18:38

Then I guess you will need to do this via the mysql_connect that you were talking about earlier. You cannot put it in a template though. You will need to put php in a plugin. I doubt there is any example here that actually shows to php to use for your specific situation of connecting to an external database. You will have to just use regular php/mysql for that.

ninadbe 23 Mar 2011 18:58

Yes thats what I have been trying since last, created plugin , hooked it at "SHOWTHREAD" , "postbit" template.

I also tried to include file with following code


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Above code gives error


following code do works 60%

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

However if I tired above code it works fine. It showing product successfully. But problem is that, I want to show products related to forum title. Therefore why I passed parameters along with it as

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

but its not working.


It is not passing parameter successfully.

--------------- Added 23 Mar 2011 at 19:09 ---------------

session variables are not working.
Do you it would work with cookie variable? i.e store threadtitle with the help of cookie.

--------------- Added 23 Mar 2011 at 20:45 ---------------

ob_start();
$threadtitle = $threadinfo['title'];
setcookie('threadtitle111',$threadtitle);
require_once('http://naturalparenting.com.au/prod_gallery.php');
$prods = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('postbit_legacy',array('prods' => $prods));


Dont know why setcookie not working at vbulletin?

Lynne 23 Mar 2011 22:01

I do not understand all all what you are doing. If you are putting that code in a plugin, you need to tell us what hook location you are using. - there is no such thing as "hooked it at "SHOWTHREAD" , "postbit" template". You don't hook to a template.

ninadbe 23 Mar 2011 22:19

hook : global_start

at postbit_legacy => {vb:raw prods}


It is working, only facing problem with cookie.
I have changed
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

as setcookie is not working. vbsetcookie works.

It seems like cookies at vbulletin are encrypted.
So cannot fetch cookie at location.

Lynne 23 Mar 2011 22:23

I would not pick the global_start template. If you look that template up, you will see it is deprecated and you are supposed to use another one instead (I can't remember which one, but you are told when you look that one up).

ninadbe 23 Mar 2011 23:34

I hooked it at showthread_start. Also tried hooking with global_bootstrap_init_start.

Plugin is working with all hooks I have tried so far (global_start, global_bootstrap_init_start, showthread_start etc). As I explained before mine problem is with cookies.

I have set cookies with the help of foolowing code

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

As I said before vbulletin is encrypting cookie. Therefore I cannot get cookie value at included location.
Is there anyway to decode cookies?


All times are GMT. The time now is 13:54.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.