pmf 1.5.3 and embedding php in templates

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Corey
Posts: 1
Joined: Sun Nov 06, 2005 7:49 pm

pmf 1.5.3 and embedding php in templates

Post by Corey »

I turned on php parsing in the admin tool but my php code is not being parsed. I tried something as simple as <?php echo "Hello World"; ?> and that did not even work.

I am trying to incorporate components of the site's navigation into the template and would prefer to include an external file.

Is there a step I missed?
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

where did you insterted the PHP code?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
lsalsich
Posts: 3
Joined: Mon Feb 20, 2006 3:19 am

same issue

Post by lsalsich »

Hi,

I have the same problem. I enable 'php parsing' in the config file but it seems that PHP is not parsed in the template files. Any ideas on how to solve this would be great.

Is there another setting I need to alter?

Thanks!

Luke
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

did you enabled it in the admin configuration?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
lsalsich
Posts: 3
Joined: Mon Feb 20, 2006 3:19 am

Post by lsalsich »

Hi Thorsten,

Yes, I did enable it from within the admin panel.

I do see (I think) where you have the code in parser.php which parses the PHP code. It looks ok to me. Has this feature worked for you and others?

Thanks very mucvh for you assistance,

Luke
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

this feature works for me. How does your edited template look like?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
lsalsich
Posts: 3
Joined: Mon Feb 20, 2006 3:19 am

Post by lsalsich »

Solved the Parsing issue (I think):

lines 101 and 102 in parser.php:

Code: Select all

        	$phpstart = '<?php';
        	$phpstop = '?>';
will not match <?PHP since it is in caps. Many programers are in the habit of caping PHP. I would suggest adding some regex in this to match caps. Or, make it clear that PHP code must start with '<?php' in order to parsed.

Great application!

Luke
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

I never used <?PHP so I didn't checked for the uppercase version. :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jwdenzel
Posts: 5
Joined: Fri Mar 03, 2006 3:33 am

Same problem

Post by jwdenzel »

Hi there

I am having the exact same issue. I am using version 1.5.6. I have checked the "activate" button next to the PHP parser. I included two very basic PHP calls and neither shows up. I tried it with both <?PHP, and also <?php

Any ideas?

Inside the Faq/template/index.tpl file:

<body dir="{dir}">
<?PHP echo "Hello World 1"; ?>
<?php echo "Hello World 2"; ?>

...
Neither shows up.

Any ideas?
Thanks in advance

Jason
jwdenzel
Posts: 5
Joined: Fri Mar 03, 2006 3:33 am

Post by jwdenzel »

BTW --

When I view the source of my rendered page, it shows that the PHP was not parsed at all. Thoughts?

Jason
jazcyk
Posts: 385
Joined: Wed Sep 07, 2005 1:32 pm

PHP not parsed at all

Post by jazcyk »

@jwdenzel
When I view the source of my rendered page, it shows that the PHP was not parsed at all. Thoughts?


Looks like the PHP module did not load correctly at webserver startup?
Are you able to use PHP at all ?
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

maybe your provider has disabled the function eval()?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
jwdenzel
Posts: 5
Joined: Fri Mar 03, 2006 3:33 am

Post by jwdenzel »

Hi there

Thanks for the replies. Unfortunately, I don't think either of those are the answer.

1) I own my own server and have full control over it
2) I am able to do all other PHP functions on the same website. (I have phpBB running for example)

Check out the site if you like.
http://illian.no-ip.com/Faq

Thanks again
Jason
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Are U using the HTML source view?

Post by matteo »

jwdenzel wrote:I am having the exact same issue. I am using version 1.5.6. I have checked the "activate" button next to the PHP parser. I included two very basic PHP calls and neither shows up. I tried it with both <?PHP, and also <?php

Any ideas?
Inside the Faq/template/index.tpl file:

<body dir="{dir}">
<?PHP echo "Hello World 1"; ?>
<?php echo "Hello World 2"; ?>
Hi Jason,
I'd like to have just the confirmation that you are inserting:

Code: Select all

<?PHP echo "Hello World 1"; ?>
<?php echo "Hello World 2"; ?>
without the BODY tag, toggling the view in the WYSIWYG HTML editor clicking on "<>" (the tooltip is: " Toggle HTML Source"), at your right in the bottom of the toolbar.
Otherwise your PHP entries will be inserted as:

Code: Select all

<?PHP echo "Hello World 1"; ?>
<?php echo "Hello World 2"; ?>
with <> inserted with their HTML entities, unabling any PHP code evaluation.
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

and what also does not work is putting PHP code in the first line of the template file. Please add the line after the DOCTYPE decleration.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply