The DailyStory PHP SDK is an open source library hosted on GitHub used by PHP developers to integrate DailyStory's capabilities into their PHP application.
DailyStory Web Forms enable you to create, design and manage web forms within DailyStory. You can then include those forms within your web application to request information from visitors, such as a signing up for a newsletter.
A web form is part of a DailyStory campaign and once a form is submitted the contents are used to either create a new lead within a campaign or add to an existing lead.
To include a DailyStory Web Form in your existing PHP application, follow these steps:
Include the PHP Class files in your PHP application. For DailyStory Web Forms you will need the dailystory_webform.php class file.
Find your DailyStory Site Id, as this will be required to use the PHP SDK. You can find your Site Id on the Tracking Code page in your DailyStory application.
Next, get the Unique Id of the DailyStory Web Form you want to include. You can find your Web Form Unique Id by clicking on any Web Form.
Open or create a PHP page and include the
dailystory_webform.php class. Next, create an instance of the DailyStoryWebForm object and call its
renderWebForm method passing in your DailyStory Site Id and Web Form Id:
<?php require_once('dailystory_webform.php'); // Create an instance of the web form $webform = new DailyStoryWebForm(); // Get the web form echo $webform->renderWebForm($siteId,$formId); ?>
Replace $siteId and $formId are the values from your DailyStory application from step 2 and step 3.
When you run this page, you should see something similar to this:
To make things simple, DailyStory uses Bootstrap class names in the CSS. While not required, this means that you can quickly use the Bootstrap framework to immediately make your form responsive and adaptive (i.e., mobile friendly).
Finally, DailyStory additionally provides some pre-built CSS files to add form validation and basic styling. These are completely optional:
Now our web form looks a little nicer:
There are several pre-built CSS templates to choose from. For example, if you want a simple horizontal form you can replace the
base_webform-horizontal.css and change the Web Form Layout to Hide Form Labels:
If you are actively testing a webform or make changes you can invalidate the PHP web form file cache by include
__dsCache=refreshin the URL of any page that is rendering a web form.
If you would like to see more examples please see our PHP examples in the SDK.