PDA

View Full Version : Questions and errors: "Create your own vBulletin page" - receiving errors


sergioloporto
09-16-2010, 07:17 AM
Hello, my VB4 CMS is installed here: '/home/user/public_html/myforum

I am using/trying to create a custom page with the same template as in the example. So this is the code of my test.php [the test.php is inside /home/user/public_html/myforum/concorso]:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT', 'test');
define('CSRF_PROTECTION', true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('TEST',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
chdir ('/home/user/public_html/myforum');
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';

fdsfdsga


// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

?>

Also the template is the same (for testing purposes) as the one of this article: https://vborg.vbsupport.ru/showthread.php?t=228112



In the test.php there is a field:

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';

fdsfdsga


But if I add text like the one you see above I get an error:
Parse error: syntax error, unexpected T_VARIABLE in /home/user/public_html/myforum/concorso/test.php on line 46


Question: Why I get that error? What kind of code should go there?
If I want to put some <script> and html, should it go here in the test.php or in the template?

--------------- Added 1284628226 at 1284628226 ---------------

If I in the browser I stay in the test.php page for long time (about 10 - 20 minutes) and then I refresh the page, this is what I get:

Unable to add cookies, header already sent.
File: /home/user/public_html/myforum/concorso/test.php
Line: 1


In order to see the test.php page I need to go to a normal page of the forum, and then I have to go back to the test.php in order to see it without errors.

Question 2: why this is happening? How to resolve it?

Lynne
09-16-2010, 01:36 PM
You cannot just add text like this into your php page:
fdsfdsga
You need to put PHP into your php page and that is not php.

What are you trying to do there?

sergioloporto
09-16-2010, 01:44 PM
I need to put something like this, not the same, but very similar:

<form method="post" action="https://app.xxxx.com/main.php?moduleName=fm_subscribers&amp;action=add_subs criber">
<input type="hidden" name="subscribers_list_hash" value="xxxxx" />
<label for="freshmail_email"> Email </label><br /><input type="text" name="xxxmail_email" id="xxxmail_email"><br />
<input type="submit" value="confirm">
</form>

and I will need to put images and text (static text and images)

Where should I put this?

Lynne
09-16-2010, 05:48 PM
The html goes into the template. php goes into the php file.

sergioloporto
09-16-2010, 05:55 PM
Ok thanks, I'll try it out.

What about the "Unable to add cookies, header already sent." message that I get when I have the page open for long time and then press refresh?

Lynne
09-16-2010, 05:59 PM
You get that with the totally default test page and test template?

sergioloporto
09-16-2010, 06:06 PM
yes, exactly using the template and test.php as in the first page of th article, no changes. Also file names and template names are the same. Exactly copy and paste.

The only change is the: chdir ('/home/user/public_html/myforum');

It happens only when refreshing the test.php page

Lynne
09-16-2010, 11:47 PM
Make sure you are using a text editor (not something like Word, but one just for text or php), and also make sure you put no extra lines or spaces before the <?php

sergioloporto
09-17-2010, 06:38 AM
I always use Notepad++, and I confirm there are no spaces before <php

Now I will try to see if I get the same cookies error after disable my mods and I'll let you know

sergioloporto
09-17-2010, 10:11 AM
Update:

I disabled the whole plugin system from the settings in the cp, but I get the same error.

Here attached:
-test.php
-screenshot of the error message
-screenshot of the template
-screenshot of the filetree


Password via PM

Lynne
09-17-2010, 02:42 PM
I don't know why it won't work in your directory. I think you may need to grab your directory path, then change to the forum one, include the global.php file, then change back to your directory. There are threads about this, but I don't have time to go looking around for them. But, go try searching and you should find them.

sergioloporto
09-17-2010, 06:43 PM
I don't know why it won't work in your directory. I think you may need to grab your directory path, then change to the forum one, include the global.php file, then change back to your directory. There are threads about this, but I don't have time to go looking around for them. But, go try searching and you should find them.

Thanks, I understand and I appreciate your sincerity.

Please give me some seconds and tell me if I should what you suggested above even if I get the same "cookies" error if I put the test.php on the forum root (of course with the chdir commented)?

Because I tried and the same happens.

Lynne
09-17-2010, 10:45 PM
I do not get the cookie error if I put the file above the forums directory and do a chdir to the forums directory. And, I don't get the cookie error if I put the file in the forums directory and don't use any chdir line.

sergioloporto
09-18-2010, 08:16 AM
Could you please link to a page (no matter if yours or not) that is using a custom template made from your article?

I would like to see if I get the same, just to test we are on the same wavelength.

Lynne
09-18-2010, 02:47 PM
I can't link to a vB4 page on any of my sites because they are all test sites and thus password protected. There were several links in the article to pages uses have made.

sergioloporto
09-18-2010, 07:57 PM
Thank you, I tried to check some other sites, but it unfortunately happens only to me :(

--------------- Added 1284891929 at 1284891929 ---------------

I found out!!!

It's a codification problem. I get that error if I save the php file in UTF-8. But is should be saved in ANSI.

However if I use ANSI I cannot use the special characters ł?ężźć, but I need them.
I have to use online converters from whatever to ANSI :/

BTW, thanks much for your support