using php includes
Permalink 1 user found helpfulI'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 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.
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.
I hope I can figure out how to make blocks. Is that c5's way of doing php includes?
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!
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...