PDA

View Full Version : Need to Implement Custom Pages That Execute PHP Code


kardus
05-16-2010, 06:23 AM
I've been doing a lot of searching around and have found a few guides that allow you to create custom pages within vbulletin, namely this guide: https://vborg.vbsupport.ru/showthread.php?t=228112

I followed it and it seems to work as advertised. Unfortunately, I want these pages to be able to execute PHP code, which doesn't seem to work with this method. I found http://www.vbulletin.com/docs/html/templates_externalfiles and tried to implement these changes for php/registering variables for vb4, but I can't seem to get it working.

Basically what I am trying to achieve is a setup like this: http://tools.digitalpoint.com so some of my own PHP web applications are streamlined with my forums.

I just need to manage some content/these web apps (most likely 10-30 pages). I tried vbadvanced which actually worked, but seemed like a huge amount of overkill for what I am trying to achieve, and I really didn't like how it was handling my pages, url issues, interference with other mods, etc.. I also tried https://vborg.vbsupport.ru/showthread.php?t=232207 but this mod seems outdated and gave me errors.

I'm basically looking for a simple, easy to implement, and working solution that doesn't involve me adding my own plugins/templates for every single new page I want, if possible. Essentially I want to run already finished php webapps that do various tasks, into my forums in the fashion as shown on digitalpoint forums.

I would really appreciate some assistance. I've been working on my forums for hours and this really is the only (but vital) thing I need to work out before they go live.

--------------- Added 1274076562 at 1274076562 ---------------

bump?

ragtek
05-18-2010, 02:55 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=228112" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228112</a> should work

what did you exactly try?

kardus
05-18-2010, 03:44 AM
Oh, that worked fine. The only problem is that it only seemed to work for only HTML/plaintext. I put in some PHP code to test an output (just a simple echo for testing purposes) and it just displays the code how I wrote it. I made the plugin as seen in the vbulletin manual:
ob_start();
include('path/to/this/file/myfile.php');
$includedphp = ob_get_contents();
ob_end_clean();


and then put

{vb:raw includedphp}

in the template that Lynne's guide told me to make.

I also added vB_Template::preRegister('FORUMHOME',array('includ edphp ' => $includedphp));

To the test.php file, and it still doesn't seem to want to include my php code.

I've been trying to get this working for nearly two days now with nothing but frustration :(

cellarius
05-18-2010, 04:30 AM
I can't imagine that you're using the FORUMHOME template for your custom php file, do you really? You are registering your variable for that template, but you need to register it for the template you actually use for your custom php page. If you want to output something on forumhome, you don't need a custom php page. You would put your code into a plugin.

kardus
05-18-2010, 05:04 AM
I can't imagine that you're using the FORUMHOME template for your custom php file, do you really? You are registering your variable for that template, but you need to register it for the template you actually use for your custom php page. If you want to output something on forumhome, you don't need a custom php page. You would put your code into a plugin.

I'm not sure I understand you completely. My goal is just to have pre-written pages of php/html code display neatly where the forums region would be in a normal forum, similar to http://tools.digitalpoint.com... I'm very new to vb and have not much of a clue how it works. I've just followed what I've seen here and while the custom pages are working, php is not being parsed.

cellarius
05-18-2010, 05:18 AM
No, you did not follow the custom pages tutorial ;) - at least not closely. You need to create your own template for your custom php page and register your variable for that template you created. You are registering it for FORUMHOME template, which most probably is wrong. What is the name of the template you created for your custom page?

kardus
05-18-2010, 05:48 AM
I followed the tutorial exactly as how it was written, just to try it out and made sure I was doing it properly. My file is test.php, and my template it called TEST just as the tutorial showed.

Text and html work fine. If I put on my page: <?php Print "Hello, World!"; ?>, it will not say "Hello, World!" but rather Print "Hello, World!"; ?>

My variable registration looks like: vB_Template::preRegister('TEST',array('includedphp ' => $includedphp));

Sorry if that was not clear, I was just pasting it from the vb manual. On my real forums, it does say 'TEST' rather than 'FORUMHOME', I know I am doing this correctly as instructed, but I don't know why php fails to parse.

cellarius
05-18-2010, 08:26 AM
Why at all do you use the preregister method? The (correct) method in the tutorial is different and does not use preregister:
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

For your variable you would have to add a line like this:
$templater->register('includephp', $includephp);
Concerning your test with
<?php Print "Hello, World!"; ?>
It looks to me that you use <?php ?> while not needing to - it's already around the complete page, so if you put your code somewhere in the middle, you don't need it once again. But this is plain guesswork without seeing your code. The base line is that the tutorial works perfectly well if followed correctly, so there need to be errors in your code. It would be helpful if you would paste the whole thing, with those little tidbids it's really hard to tell.

kardus
05-18-2010, 01:59 PM
Finally got it working! Thank you.

P.S. I followed what you said exactly and it STILL did not work. I was copying your line: $templater->register('includephp', $includephp); , but my variable was included, it took be about an hour to figure this out :p

theraven1
08-13-2010, 10:51 PM
I would like to see this code if possible.. in a working site..

kardus
08-13-2010, 11:10 PM
<a href="https://vborg.vbsupport.ru/showthread.php?t=228112" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228112</a> actually works fine, I believe I was doing something incorrectly or misunderstood an instruction.