Pages: [1]
Author Topic: How to insert php code in custom page  (Read 3727 times)
sank
Guest


Email
on: Nov 30, 07, 06:01 AM

Hi,

I would like to know if it's possible to create a custom page (to put my newsletter script for example) and to insert some php code ... ?

When I edit a custom page, I can only edit html code, an idea chief ?  Wink

San-K
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #1 on: Nov 30, 07, 06:53 AM

you can place your php code into a new page block accessible by custom pages, see screenshots.
Please note, since this script uses a template system, it's impossible to output anything produced by your php code right into the browser using "echo()" aor anything similar. Instead, you should assign your output to a named macro. Like in this sample:
Code:
<?php
$myText 
"Text output test";
$tpl->assign"MY_PHPOUTPUT"$myText );
?>


And put that macro somewhere in your custom page.


* php_block.png (49.71 KB, 909x768 - viewed 301 times.)

* php_output.png (42.07 KB, 849x645 - viewed 289 times.)
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #2 on: Nov 30, 07, 07:02 AM

Another way to add php page - make it from scratch using my index.php (just 69 lines of code Smiley ) as reference. Using this approach you can use the main theme, place default page blocks, etc. Everything my index.php does, plus add your own code anywhere you wish.
Logged
sank
Guest


Email
Reply #3 on: Nov 30, 07, 07:39 AM

Thank U Sergey for your great answer,
I'll try this as soon as possible on my website  Grin
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #4 on: Nov 30, 07, 07:54 AM

one more thing about the php block: it will be called on each custom page, even if you don't wish it to run on some of them. So to limit its "scope" you should check the page title (the $cPage constant which is "about" for "about.html" page, etc.)

The code might be the following:
Code:
if( $cPage != "mypage" )
   return;
Logged
Administrator
Sr. Member
*

Karma: 7
Posts: 486


Email
Reply #5 on: Sep 13, 08, 02:01 AM

Update: in ProArcadeScript version 1.3 or higher you can add PHP custom pages, as shown on the attached screenshot. The process of addition is simple and straightforward - just open the "Pages" tab, make sure that file extension in the "Page filename" field is php and write your php code in the "Code" field.


* custompage_php.png (32.64 KB, 810x590 - viewed 192 times.)
« Last Edit: Sep 13, 08, 05:40 AM by Sergey » Logged
Pages: [1]
 
Jump to: