Can I add php to a page

Permalink
I'm trying out a few things and wondered how or where I could add a small bit of php to one of my pages. Nothing too technical just accessing a database and using mysql and displaying images. More of a trial too see if it's possible in C5.

any help would be appreciated - thanks

 
olliephillips replied on at Permalink Reply
olliephillips
You have a number of choices. Single page, page type, block or block custom template.

For little hacks on pages I want to reuse I opt for page type or block custom template. For larger snippets that are the sole purpose of the page I would go the single page route.

Probably should say you might be able to what you want more easilly, using Concrete5's built in database methods even if you're using an external database.

Hope that helps.
kappi replied on at Permalink Reply
thanks for the help, so how do is there a specific block type, apologies an not too sure which block would be useful, and you mentioned using a single page. What makes a single page so special compared to the normal default ( I mean apart from the fact that single pages aren't made into a page type).
olliephillips replied on at Permalink Reply
olliephillips
You could do it in any block, by making your own custom template. There is documentation on styling blocks on this website.

The difference between pages and single pages is also well documented on here, but 'typically' they get used for taking input via forms and outputting data i.e query results. Something data driven, where users are not typically going to need to edit the page via Concrete5's incontext editing (though it is perfectly possible to add editable areas to the view.php file which is usually the wrapper for single pages). The functionality only needs to exist in one place. If you wanted it in more places you'd go the block template or page type route.

So it's very flexible, there's no one right answer as to where you put your code.
Phallanx replied on at Permalink Reply
Phallanx
There is a PHP block that I use (quite a lot).
http://www.concrete5.org/marketplace/addons/simple-php-block/...