Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newb PHP in pages
#1
First of all i want to introduce myself, my name is Enrico 30 from Italy and i want to sorry for my english. i don't understand how to insert PHP script in page. For example i have a scipt to list all the file in a directory, and i want to insert this script on the index page or in an another page. I've tried to insert the function in the functions.php file but i don't understand hot to recall the function in the page..

so, anyway, thx for this CMS and for the Help.
Ciao
#2
Normally PHP can only be used from within other PHP code. In the case of GetSimple, you can only call functions from within the theme files.

If you want to be able to use PHP in the normal page editor, you will need a plugin. Chris’ Exec-PHP can help you out.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
#3
Zegnåt Wrote:Normally PHP can only be used from within other PHP code. In the case of GetSimple, you can only call functions from within the theme files.

If you want to be able to use PHP in the normal page editor, you will need a plugin. Chris’ Exec-PHP can help you out.

I've download the exec-php plugin but it seems not to work I mean if i write php code in the normal page editor.. the result is that you read on the page the php code i wrote..
i hope you can understand me better then i explein Smile)
#4
Exec-PHP requires disabling the rich editor. Looks like you pasted your code in WYSIWYG mode.
#5
for exec php to work, i believe you need to turn the HTML editor off in the settings panel. Can you try that?
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
#6
Some other possible options...

- Just insert code in your theme's template.php file (wherever you want it):

Code:
<?php
if (return_page_slug()=='page-with-php-code') {
    /* your code here */
}
?>

(Of course you can use if...else or switch...case... sentences, for several pages, different code, etc.)

- Another option is stuffing that code into a function, and call it using one of GetSimple's front-end hooks. Example:

Code:
<?php
add_action('content-top','my_php_code');

function my_php_code() {
    if (return_page_slug()=='page-with-php-code') {
        /* your code here */
        }
}
?>

This can be done either in your theme's functions.php file, or by creating your own custom plugin.

(The plugin option may be better because your code will be executed with any theme: no need to edit themes or copy the functions.php file.)
#7
OMG Chris! We both answered at the same minute!! :-D
#8
haha, great minds think alike. Also, great mini-tutorial there Carlos.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
#9
Thx a lot to everyone. At the moment i've to go to work so i can't do any "try". Tonight i'll try to turn off the html editor, and also other method.
really thx. if i succeed in using PHP with this CMS, i thik i'll use CMS for every site i'll do.
Grazie Smile)
#10
Does turning HTML editor is really needed ?
Can't be the php code pasted in "source view" mode in wysiwyg ckedit window ?
Addons: blue business theme, Online Visitors, Notepad
#11
ccagle8, if you want to add at the title of the post with solved.
Turning off the html editor the exec-php plugin works.
The method of Carlos works too.
So really thx to every one.
Cheers




Users browsing this thread: 4 Guest(s)