PHP include for Single Page

Permalink
Is there something similar to
$this->getBlockPath()
for Single Pages? I'm trying to do a PHP include.

I'm also fairly new to PHP/C5 so if there is a better way, I'm all ears.

Thanks in advance.
Josh

joshhawthorne
 
joshhawthorne replied on at Permalink Reply
joshhawthorne
Since the file I was trying to include was in the same directory as my file that had the include statement in it, I didn't have to specify the path. i.e.

<?php include('filename.php); ?>


Still not sure if this is preferred or not, but for now it's working.
ScottC replied on at Permalink Reply
ScottC
$this->inc('php filename');

It is used in themes and is a view property so it should work fine, although I haven't tested it so berate me mercilessly if it doesn't work ;)

Usually though most includes are usually methods better relegated to the controller and then a model. Totally depends on what you want to do though.
kutis replied on at Permalink Reply
kutis
php was started as a scripted language, thus it'll try to work on anything that you throw at it.

that said, if the php u're including is some sort of logic process (ie processing a form, etc) it should've been in the controller
joshhawthorne replied on at Permalink Reply
joshhawthorne
Good call on the logic. This was to share a view across add and edit, so I think I'm good.

Thanks again for all the help.
brianhayes replied on at Permalink Reply
I am trying to call a remote page with the script <?php include ("http://remote_url/page.html");?> and this does not work inside a C5 theme. Is there any code that will achieve the same effect?
Mnkras replied on at Permalink Reply
Mnkras
brian that should work if its a remote site i believe
brianhayes replied on at Permalink Reply
I get the following error message. It looks as if some adjustment must be made in libraries/3rdparty but I do not know what it might be. regards,
Brian

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /var/www/vhosts/holidexchange.com/httpdocs/nz/themes/intervac/default.php on line 543
Warning: include(http://www.intervac.com/templates/whatsnew_mini_04_en_GB.html) [function.include]: failed to open stream: no suitable wrapper could be found in /var/www/vhosts/holidexchange.com/httpdocs/nz/themes/intervac/default.php on line 543
Warning: include() [function.include]: Failed opening 'http://www.intervac.com/templates/whatsnew_mini_04_en_GB.html' for inclusion (include_path='.::/var/www/vhosts/holidexchange.com/httpdocs/nz/libraries/3rdparty:/var/www/vhosts/holidexchange.com/httpdocs/nz/concrete/config/../libraries/3rdparty') in /var/www/vhosts/holidexchange.com/httpdocs/nz/themes/intervac/default.php on line 543
Mnkras replied on at Permalink Reply
Mnkras
do you have curl on your server?
brianhayes replied on at Permalink Reply
The answer would appear to be yes. A <? phpinfo();?> search revealed that cURL was enabled with this information:


cURL Information: libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

Brian
mose replied on at Permalink Reply
mose
The very first line says that file access is disabled in the server configuration. You will need to enable access in php.ini. Generally, it is considered a security risk to include some random file from another server, because that file could be anything. If it is not treated carefully, the remote file could compromise the local system.

Would it work to create an IFRAME and let the user's browser retrieve the remote page directly rather than having the website retrieve the web page and pass it along to the user? That cuts out the middleman.
brianhayes replied on at Permalink Reply
Thanks. A valuable answer. I had worked out that the problem was with PHP on my server as I had it upgraded to meet c5 5.3.3.1 requirements and I spent a fruitless 90 minutes on the telephone trying to get my VPS host to understand. The problem with an iframe is that the called up html has links and unless I can get the remote host to make them target=_blank it does not work. I finally found another script which is

<?php $file= "http://www.intervac-homeexchange.com/templates/whatsnew_mini_02_en_GB.html ";
if($data = file_get_contents($file)){
echo $data;
} else {
echo "No data to echo";
}?>

I feel I should pay you guys something for your time in giving this help. The link is not obvious on your site or are you 100% altruistic?

Regards,

Brian