4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: Jaap12 on October 17, 2002, 09:47:49 PM

Title: problem
Post by: Jaap12 on October 17, 2002, 09:47:49 PM
Hi,

I want to included a php script in my template file.

name.html
in the html file i have add this row: <?php include("doel.php"); ?>

But if the script want to run ii get this error:

Parse error: parse error in /home/zippie/HTML/includes/template.php(130) : eval()'d code on line 152

What can i do to fix it?

Plz help me. Btw.. i use 1.6
Title: Another way to php include
Post by: Chris on October 17, 2002, 10:15:40 PM
Try putting your php include in your template like this:
Code: [Select]
<?php
include&#40;"doel.php"&#41;;
?>

This usually works.
Title: problem
Post by: Jaap12 on October 17, 2002, 10:22:45 PM
<?php include("doel.php"); ?>

that makes no differents with this.
Title: Try it
Post by: Chris on October 17, 2002, 11:00:06 PM
Yes it DOES.  Just try it.  

For PHP syntax, it makes no difference.  For 4images template parsing sometimes it makes all the difference.   :wink:
Title: problem
Post by: Jaap12 on October 18, 2002, 08:55:58 AM
not by me :(


i have try it, but still geting the same error.
What can i do?
Title: Try full path
Post by: Chris on October 18, 2002, 02:49:45 PM
Have you tried using the full path and file name for the include?

Code: [Select]
<?php
include&#40;"/home/zippie/HTML/<whatever else goes here>/doel.php"&#41;;
?>

If that doesn't work, then I don't know what the problem could be.
Title: problem
Post by: Jaap12 on October 18, 2002, 03:38:41 PM
sorry dón't work :(

Code: [Select]

Parse error: parse error in /home/zippie/HTML/includes/template.php(130) : eval()'d code on line 155


line 155 is:       $line = preg_replace('/[\?|%]>/', '', $line);

i think that his mean that there is something in the code, with this caracters, the page won't open. I had delete this, but then i get somemore errors. Maby do you know how to fix it? I use still 1.6 hope that Jan can help me???
This is a very big problem :(
Title: problem
Post by: Jan on October 18, 2002, 04:26:34 PM
The php parsing of the templates is not made for including some code who must be executed. You should better try to include the files into a script file and register the output into a template variable.

Try this in "includes/page_header.php":

Code: [Select]
ob_start();
@ob_implicit_flush(0);
require("doel.php");
$contents = ob_get_contents();
ob_end_clean();
$site_template->register_vars("doel", $contents);


Use {doel} in your templates.

Jan
Title: problem
Post by: Jaap12 on October 18, 2002, 04:52:03 PM
Thanks for the tip,

But you sure that it must be placed in the page_header.php ?

If i do that and i relad the page, my hole page is white. With no content only a blank page.

In index.php i have this at the bottem:

Code: [Select]
require '/home/zippie/HTML/sympoll/booth.php';
ob_start();
@ob_implicit_flush(0);
newest_booth();
$contents = ob_get_contents();
ob_end_clean();
$site_template->register_vars("newest_booth", $contents);
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');

This is for al poll, maby that's why i doesn't work? Hope you can help me. If this is fixed all the problems by all the users are fixed with inludes function etc.


Thanks in advance,

jim
Title: problem
Post by: Jan on October 18, 2002, 06:07:32 PM
Can you post a link where you get the script?

Jan
Title: problem
Post by: Jaap12 on October 18, 2002, 06:16:26 PM
it's made by myself.

It works fine, only not in the templates.

If i do it with no template, then it works fine. But if i paste it into the layout it don't work.

This is the same for other (php) scripts.
Title: problem
Post by: Jan on October 18, 2002, 06:23:36 PM
Then try to save the outout in a variable and register it.

For example:
Code: [Select]
require '/home/zippie/HTML/sympoll/booth.php';
$contents = the_function_to return_the output();
$site_template->register_vars("newest_booth", $contents);

Jan
Title: problem
Post by: Jaap12 on October 18, 2002, 06:33:10 PM
hi jan , thanks for your fast reply

what you mean with this?

the_function_to return_the output??

sympoll that was my poll, that works fine but the error i get with

this:
<?php include("doel.php"); ?>

You said try this:

Try this in "includes/page_header.php":

Code: [Select]
ob_start();
@ob_implicit_flush(0);
require("doel.php");
$contents = ob_get_contents();
ob_end_clean();
$site_template->register_vars("doel", $contents); 

But how can i fix this?

in page_header i get a blank page if i put the code in it.
Soem months i had problems with my poll...

You said add this in your index.php
Code: [Select]
require '/home/zippie/HTML/sympoll/booth.php';
ob_start();
@ob_implicit_flush(0);
newest_booth();
$contents = ob_get_contents();
ob_end_clean();
$site_template->register_vars("newest_booth", $contents);
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
Works FINE!

But the other problem with the "doel.php"inlcude how can i fix that?

Thanks in advance

jim
Title: problem
Post by: Jan on October 18, 2002, 07:28:20 PM
Did you tried to add the code for doel.php in index.php?

Jan
Title: problem
Post by: Jaap12 on October 18, 2002, 07:34:50 PM
no, witch code you mean? the hole code of doel.php paste into index.php?

So if i do that i think it makes no sence for my template layout.

or do you mean this code?
Code: [Select]

require '/home/zippie/HTML/sympoll/booth.php';
$contents = the_function_to return_the output();
$site_template->register_vars("newest_booth", $contents);


And what do you mean with , the function to return the output?
Title: problem
Post by: Jan on October 18, 2002, 08:13:36 PM
I mean add the code for doel.php in index.php like you did with the code for the poll.

2. question:
Save all output into a variable instead of print it directly with echo. This variable can registered as template variable to show the the content in the templates.

Jan
Title: An alternative
Post by: Chris on October 18, 2002, 08:46:47 PM
I think I can suggest a MUCH simpler alternative, one that would not require any modification to the 4images or sympoll php code.  The sympoll php code is going expect http post data from the poll form which it will use to generate a results page.  

My suggestion?  Use an <iFrame>.  An inline frame only requires you to edit the template where you want the poll to appear and you can place it in a table cell.

Example:  (assuming sympoll is located at the web's root directory)
Code: [Select]
<iframe src="/sympoll/booth.php" width="150"
height="450" scrolling="no" frameborder="0">
Your browser does not support frames or is currently configured not to display frames.
However, you can still visit <a href="/sympoll/booth.php">the poll page</a></iframe>

Generally speaking, and only in my experience, the percentage of people using browsers that do not support the <iframe> HTML tag is VERY low these days.  If a visitor should happen to come along with such a browser, the message about visiting the poll page and providing a link to it would be displayed instead.  For all others, they would see the poll and the results page.  

I *think*, don't hold me to it, IE 4+ and NN 4.7+ or 4.6+ support the iframe.  So does Mozilla and Opera.  So the only vulnerability is to the small number of people using Netscape at a version less than 4.6 or 4.7.

This is how I'm going to add a poll to my 4images installation.  Far easier don't you think?  

It also makes it much easier to upgrade 4images when new versions become available because you don't have to figure out how to get your custom modification working in the new version if things change.

Yes, I'm sure this works.  I tried it just 4 days ago.
Title: problem
Post by: Jaap12 on October 20, 2002, 12:29:19 PM
yeah, i think that's the best soltution. But it doesn't work with my problem i think,

Here is my problem.

At the first page of my site, i have a dropdown menu, if the visitor have make a choice, then they need to click at the "send"button.

If they have do that, a new page load in with the same design, in that page there i have placed the iframe.

But now the problem is: how do get the results of "send"in a new page and opens in the iframe?

Code: [Select]

<iframe src="doel.php" width="150"
height="450" scrolling="no" frameborder="0">
Your browser does not support frames or is currently configured not to display frames.
However, you can still visit <a href="doel.php">the poll page</a></iframe>


Discription:

first page = page with dropdown menu
second page = same page as the first page, with the iframe menu

I need to get the results from the first page display in the second page, in the i frame. So i can't use php, so i need to do it with javascript or with html??

I think 4images need to be upgraded to fix this big problem.
Title: Need an example
Post by: Chris on October 20, 2002, 06:50:37 PM
I don't really understand what your problem is from reading your description.  If it's a poll being displayed in the iframe, then the "submit", "vote" or "view results" button should simply be a part of the poll form that is in the page displayed in the iframe.  

As far as the poll php code is concerned, it is the only page being shown to the user and most polls work by just replacing the poll page with the poll results page.  The fact that it's in an iframe is of no consequence.

If you truly need something triggered from the outer page that causes something in the iframe to change, you can assign a name to the iframe ID attribute and use javascript to code between the two.  

Can you show me an example of what you're trying to do?
Title: problem
Post by: Jaap12 on October 20, 2002, 06:53:22 PM
***
Title: problem
Post by: matthew on March 30, 2003, 04:32:39 AM
Chris,

I added the iframe but ran into a problem.

I added the poll using iframe into the left side of 4images, however my problem is it seems to overwrite everything thats on the right side. What I mean is on the right side I should have some text but it seems to overwrite everything.

To see what i'm talking about:
http://www.seclusion.org/index.php?template=polls

As you can see, on the left the poll shows up, however that big black space on the right should have text however it doesn't show it while the iframe is on the right. Not sure how clear this sounds but though you might have some idea?

Matt
Title: problem
Post by: Chris on March 30, 2003, 07:36:06 PM
That's because your template has invalid HTML

Code: [Select]

                      <p>
</iframe>

                      </p>
                      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
                        <tr>
                          <td width="100%" bgcolor="#000000">
                                                <iframe src="/sympoll/call_poll.php" width="148" height="270" scrolling="yes" frameborder="1">
                                                <?php
                                          
include&#40;$_SERVER['DOCUMENT_ROOT'&#93;."/sympoll/call_poll.php"&#41;; 
                                         
?>

                                         ;</iframe>


1.  You shouldn't have a closing </iframe> tag appear first.
2.  You should not have a ";" right before the 2nd closing <iframe> tag
Title: problem
Post by: matthew on March 30, 2003, 08:37:26 PM
Tried changing what you suggested, same thing happened. Thanks though!
Title: problem
Post by: matthew on April 03, 2003, 11:51:36 PM
Managed to get this working now. Was something in the html as you thought.