using php includes
Permalink 1 user found helpful
Hello -
I've searched the documentation and the forums about this, and still don't understand this. In my background of just html, just adding a simple
<?php include ('myfile.php'); ?>
is enough to make the magic happen. However here, when I try to add it in a page using the html source editor, this statement is immediately commented out like this:
<!--?php include ('myfile.php'); ?-->
I've seen answers ranging form "php will work anywhere", to buy a block, make a block, use
<?php
$this->inc('myfile.php');
?>
and various other suggestions.
All I want is to include one file on one page, and after three days of searching for answers and a bunch of trial and error, I give up. What is the secret to get this simple thing to work in Concrete5?
Thanks,
jj
I've searched the documentation and the forums about this, and still don't understand this. In my background of just html, just adding a simple
<?php include ('myfile.php'); ?>
is enough to make the magic happen. However here, when I try to add it in a page using the html source editor, this statement is immediately commented out like this:
<!--?php include ('myfile.php'); ?-->
I've seen answers ranging form "php will work anywhere", to buy a block, make a block, use
<?php
$this->inc('myfile.php');
?>
and various other suggestions.
All I want is to include one file on one page, and after three days of searching for answers and a bunch of trial and error, I give up. What is the secret to get this simple thing to work in Concrete5?
Thanks,
jj
Thanks for the suggestions -
I tried that free block, and while the include works, it also generates some error messages on the page. Plus the security disclaimer made me a bit jumpy. Thanks for the book suggestions. If I find c5 will work for me, I'll look into purchasing them.
I tried that free block, and while the include works, it also generates some error messages on the page. Plus the security disclaimer made me a bit jumpy. Thanks for the book suggestions. If I find c5 will work for me, I'll look into purchasing them.
Would an iframe be an option?
Iframe didn't work in my case.
Learning to create a C5 block is a skill well worth having/knowing/using, and would be the most appropriate and flexible solution for you:http://www.concrete5.org/documentation/how-tos/developers/understan...
If you need something quick and dirty on one dedicated page, create a new page type in your theme based on an existing page type, and hard code the php, or include the php file in the appropriate place.
If you need something quick and dirty on one dedicated page, create a new page type in your theme based on an existing page type, and hard code the php, or include the php file in the appropriate place.
If I understand what you're saying, using a page type to start with will let me get this going today. I can't get to the dashboard until my index page is a c5 page, so I can still show my page, and also be able to get into the dashboard to work on other pages. Then I'll start figuring out blocks.
I hope I can figure out how to make blocks. Is that c5's way of doing php includes?
I hope I can figure out how to make blocks. Is that c5's way of doing php includes?
Yes. Take an existing page type, modify it, save under a different name, and register it in the dashboard page types. However, as you note, you won't be able to register it until your index.php is a C5 file, as you note.
Blocks are the building blocks of C5 and the primary method (along with packages which are a larger aggregate) of enhancing the front end and back end features of your application. The link I provided gives a nice overview of the process. Remo's book on Beginning gives some nice examples of simple to sophisticated blocks to give you familiarity.
Blocks are composed of modules which include PHP, HTML, CSS code and so forth. They are a larger conceptual unit than include files, and based on an MVC type foundation. There's a bit of complexity to address, but these then give you the flexibility of incorporating the resulting blocks on any page.
All the best in your exploration!
Blocks are the building blocks of C5 and the primary method (along with packages which are a larger aggregate) of enhancing the front end and back end features of your application. The link I provided gives a nice overview of the process. Remo's book on Beginning gives some nice examples of simple to sophisticated blocks to give you familiarity.
Blocks are composed of modules which include PHP, HTML, CSS code and so forth. They are a larger conceptual unit than include files, and based on an MVC type foundation. There's a bit of complexity to address, but these then give you the flexibility of incorporating the resulting blocks on any page.
All the best in your exploration!
Not really meaning to necro the convo but in case anyone else finds this on a search about working with php in concrete5........................The external form has been a nice, easy intro for me to learn a bit of php in effort to communicate with an external api and return some data for the user to view. Very tidy.
The most direct solution for you would be to use a free php block from the marketplace.
http://www.concrete5.org/marketplace/addons/simple-php-block/...
However, whether adding your code to such a block will result in code that actually works in the context of concrete5 is another matter. If your code breaks the page and hence prevents you editing, you will need to enter the dashboard URL directly, then use the sitemap to find the page, approve a previous working version, and delete the version containing the breaking code.
There are many better (and probably safer) ways of adding php into concrete5 than a php block. As you know some php and are new to concrete5, I strongly recommend Remo's books:
http://www.concrete5.org/about/blog/concrete5-sightings/book-on-con...
http://www.concrete5.org/about/blog/concrete5-sightings/new-book-cr...