Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP in page content
#1
Hi,

I am trying to place some PHP into a pages content in Source mode of the WYSIWYG editor. I have found a related post here http://get-simple.info/forum/topic/2370/...-the-page/

This has got me on track. I have installed Chris's Exec-PHP plugin and now i can execute PHP code within a page's content. Later in the above mentioned post the author also had a problem with CKEditor treating the PHP code wrongly, Connie suggested the addition of the CKEditor option

Quote:config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP code

This worked a treat to preserve the PHP code. So now after adding this i for some reason no longer have the WYSIWYG editor available. When editing a page it always shows source mode without the toolbar.

Is there a way to maintain the WYSIWYG mode yet still preserve (protect?) the PHP snippets?

TIA,
Ben
Reply
#2
zig Wrote:Hi,

I am trying to place some PHP into a pages content in Source mode of the WYSIWYG editor. I have found a related post here http://get-simple.info/forum/topic/2370/...-the-page/

This has got me on track. I have installed Chris's Exec-PHP plugin and now i can execute PHP code within a page's content. Later in the above mentioned post the author also had a problem with CKEditor treating the PHP code wrongly, Connie suggested the addition of the CKEditor option...

Just for your information: you may also want to look at DynPages plugin, where you put the php code into a component and then include this component (optionally passing parameters) in your page. This way you don't have problems with CKEditor messing with php code and it might save effort, if you want to include the same/similar code in multiple pages.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
zig Wrote:Hi mvicek,

I have installed your plugin now and done some quick experiments. To keep things simple i started out with
Code:
{% hello_world %}

Could you tell me where i define "hello_world" ?

The real nature of this is a simple contact-us type page, i just want it to send an email, but a simple example of where and how to define "hello_world" would go the distance to illustrate how to use the plugin Smile

Kind regards,
Ben

Just go to Theme/Edit Components and create a new component hello_world with your code, e.g.
Code:
<?php echo "Hello World!"; ?>

Another example would be a component hello with code
Code:
<?php global $args; echo "Hello ".$args[0]; ?>
called by {% hello Joe %}.

More information on http://mvlcek.bplaced.net/get-simple/dynpages/.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
Hi mvicek,

Thank you for your quick response, and after some quick experimentation your solution and plugin is working great! Smile I actually posted a question to you then deleted it as i caught onto how to do it. But in this time you had already responded so fast again! :-P Thank you so much for your help and 2nd reply (it was what i just worked out). Your plugin is nice and ur response time has been amazing Smile Great stuff

Cheers mvicek!
Ben
Reply
#5
No matter where I place the tag in wys editor and or component in php,
the hello from the above test always shows up outside all page elements.

Anyone know why and how to fix this please?

edit:
Ok after some tinkering I was able to get it to place withing the page.

The only problem now is I'm getting 2 messages/components.
1 generated in PHP and the other from the tag.

I only need the tag.

Thanks

edit:
I removed the php function call get_component() from theme template and I now only get the 'message' inline!
So all is well now.
Reply
#6
Hello All..I don't know its right place for this post or not, but i want to know that
i am new in PHP programming language i want to know that, which is the best and cheap way to
start leaning PHP. Thanks in Advance.
Reply
#7
Darin87 Wrote:Hello All..I don't know its right place for this post or not, but i want to know that
i am new in PHP programming language i want to know that, which is the best and cheap way to
start leaning PHP. Thanks in Advance.

@Darin87,

if you do not know where to post, post in "off topic"-section
you can find a lot of php tutorials, online, for free, as books
so do a search and I am sure you will find the relevant start,

good luck, Connie
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#8
Also check the site.
Each function has working examples that are easy to duplicate.
Reply
#9
Connie Wrote:
Darin87 Wrote:Hello All..I don't know its right place for this post or not, but i want to know that
i am new in PHP programming language i want to know that, which is the best and cheap way to
start leaning PHP. Thanks in Advance.

@Darin87,

if you do not know where to post, post in "off topic"-section
you can find a lot of php tutorials, online, for free, as books
so do a search and I am sure you will find the relevant start,

good luck, Connie

Thanks A Lot... Smile
Reply
#10
roy_b8te Wrote:Also check the site.
Each function has working examples that are easy to duplicate.
Thanks Man.. for this website... Smile
Reply




Users browsing this thread: 1 Guest(s)