External php script

Permalink
Hi! I search a way how to execute a separate php script in the context of C5, so that i i have for example already a DB connection and all constants set/available. Is there already something built in for this purpose?

dkellenberger
 
dkellenberger replied on at Permalink Reply
dkellenberger
Hey, you made it realy easy to add implementations. I just looked how it was done with the properties.php in your filemanager. So for all others:

1) Create a folder "tools" in your block folder of your choice and add a custom php file, e.g. yay.php

2) Start your PHP file e.g. with:
<?php
/**
* Your custom comment.
* $Id$
*/
defined('C5_EXECUTE') or die(_("Access Denied."));
$b = Block::getByID($_REQUEST['bID']);
$bc = $b->getInstance();

// implement what you like
?>

Cool. More and more i must say, CC5 is the coolest CMS I ever saw!
ryan replied on at Permalink Reply
ryan
You could add a single page to the site if you wanted to do a one-off php script / form or whatever.

Just add a new (empty) php file to your [site root]/single_pages/ directory ex:
[site root]/single_pages/test.php

Navigate to the dashboard -> Pages and Themes -> Single Pages

At the very bottom of that page enter "test" or whatever the name of your single page is (without the .php) in the "Add single page" form.

Navigate to [site url]/index.php/test and you'll be running that new file, rendered using the "view.php" template in your current theme.
erminos replied on at Permalink Reply
Hi Daniel, Hi ryan,

I am having the same issue, can you please explain to which blocks folder i should put the custom made php file and what are the further steps.

I tried by creating the tools folder and the custom made file at the blocks folder where i installed my c5 version and don't know how to access it?

Thanks in advace

Regards,
Ermin
Mnkras replied on at Permalink Reply
Mnkras
make the file in /single_pages/

so its like /single_pages/blah.php

then in the dashboard do what ryan said above