Working With PHP
PHP is used to retrieve and manipulate data stored within Oncord, such as contacts, pages or products.
When working with Oncord, PHP is commonly used in the following scenarios:
- Calculate shipping costs based on a custom algorithm.
- Run a custom function after a form submission to manipulate a contact or run a sale.
- Show posts, contacts or products based on a custom set of conditions.
We recommend reviewing the following W3Schools tutorials to brush up on your PHP knowledge:
- PHP Variables
- PHP Numbers
- PHP Strings
- IF ELSE Conditional Statements
- PHP Loops
- PHP Functions
- PHP Arrays
- PHP Date and Time
Add a PHP Script
To add a custom PHP script to an Oncord powered website:
Edit a Website Design or Website Page > Click the SRC button > Select the PHP tab.
A PHP script starts with <?php and ends with ?>
If you need to use this PHP throughout multiple pages, the script should reside in your website design theme, rather than a single page.
Oncord uses a simple templating syntax to add dynamic content to a page. An expression can be placed anywhere in the document, starting with [? and ending with ?]
Return to the "HTML" tab after adding the above PHP script, and then call your PHP function inline:
Save the page, and click the "View" button.