I want some PHP code running in my posts.
I have searched around the forum and i don't see anyone mention how to do so, in the FAQ it only show us how to embed PHP code in the template.
Is there are configuration I can do to make it run PHP codes?
run PHP code in posts
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: run PHP code in posts
Hi!
You cannot embed PHP code in entries because of security considerations.
You have two options:
1. Create a s9y plugin. The API is not that hard, and its the cleanest integration. See the docs on www.s9y.org for api docs.
2. Use the smartymarkup plugin to put Smarty markup code in entries. If you turn of smarty security - put a config.inc.php file in your template directory and set
- then you can also use {php} smarty markup within your entries.
Best regards,
Garvin
You cannot embed PHP code in entries because of security considerations.
You have two options:
1. Create a s9y plugin. The API is not that hard, and its the cleanest integration. See the docs on www.s9y.org for api docs.
2. Use the smartymarkup plugin to put Smarty markup code in entries. If you turn of smarty security - put a config.inc.php file in your template directory and set
Code: Select all
<?php
$serendipity['smarty']->security = false;
?>
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
I found this interesting post, unfortunately, I cannot understand how to set it up in my blog.
I installed Markup: Smarty Parsing plugin, add a config.inc.php file in the my "competition" template folder and added the following in the HTML code of my post: {php}echo 'hello';{php}.
When the post is diplay, I see echo 'hello'; instead of just hello! What am I doing wrong?
Thank you for your help.
Joel.
I installed Markup: Smarty Parsing plugin, add a config.inc.php file in the my "competition" template folder and added the following in the HTML code of my post: {php}echo 'hello';{php}.
When the post is diplay, I see echo 'hello'; instead of just hello! What am I doing wrong?
Thank you for your help.
Joel.
CORRECTED:
I found why the code was not exectuted: the closing tag was wrong: {/php} instead of {php}.
However, my goal is to get within the post a parameter comming from the URL: index.php?/2.my-post.html&vid=22.
I insert the following code: {php}$i=32;echo $i; echo $_GET['vid'];{/php} but only the output if echo $i, the second command is not displayed.
I found why the code was not exectuted: the closing tag was wrong: {/php} instead of {php}.
However, my goal is to get within the post a parameter comming from the URL: index.php?/2.my-post.html&vid=22.
I insert the following code: {php}$i=32;echo $i; echo $_GET['vid'];{/php} but only the output if echo $i, the second command is not displayed.
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Maybe you can add:
to see if $_GET is really there? Depending on your PHP Version you might need to use $HTTP_GET_VARS instead...?
Regards,
Garvin
Maybe you can add:
Code: Select all
print_r($GLOBALS);
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/