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 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.
The Oncord templating syntax is used when calling PHP functions in-line.
To see this in action:
Edit a website page, click SRC > PHP, and then add the following PHP script:
Return to the "HTML" tab, and then call your PHP function inline:
[? myFunction(); ?]
Save the page, and click the "View" button.