-
-
Save jakejackson1/6c0a5268fa23ba51a285 to your computer and use it in GitHub Desktop.
Hello World – Part 2 Completed sample.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Hello World | |
* Version: 0.1 | |
* Description: A basic "Hello World" PDF template showing custom PDF templates in action | |
* Author: Jake Jackson | |
* Author URI: https://gravitypdf.com | |
* Group: Sol System | |
* License: GPLv2 | |
* Required PDF Version: 4.0 | |
* Tags: space, solar system, getting started | |
*/ | |
/* Prevent direct access to the template (always good to include this) */ | |
if ( ! class_exists( 'GFForms' ) ) { | |
return; | |
} | |
/** | |
* All Gravity PDF v4/v5/v6 templates have access to the following variables: | |
* | |
* @var array $form The current Gravity Form array | |
* @var array $entry The raw entry data | |
* @var array $form_data The processed entry data stored in an array | |
* @var object $settings The current PDF configuration | |
* @var array $fields An array of Gravity Form fields which can be accessed with their ID number | |
* @var array $config The initialised template config class – eg. /config/zadani.php | |
*/ | |
?> | |
<!-- Any PDF CSS styles can be placed in the style tag below --> | |
<style> | |
h1 { | |
text-align: center; | |
text-transform: uppercase; | |
color: #a62828; | |
border-bottom: 1px solid #999; | |
} | |
</style> | |
<h1>Hello World</h1> | |
<p>You're from {Where do you live?:3}, {Name (First):1.3}? How cool is that!</p> | |
[gravityforms action="conditional" merge_tag="{Where do you live?:3}" condition="is" value="Earth"] | |
<p>The birth-rate on Earth has dropped almost 25% in the past 50 years due to colonisation of the solar system.</p> | |
[/gravityforms] | |
[gravityforms action="conditional" merge_tag="{Where do you live?:3}" condition="is" value="Moon"] | |
<p>The lunar colony was first established in 2115 with a population of 200. Now it supports over 900,000 people.</p> | |
[/gravityforms] | |
[gravityforms action="conditional" merge_tag="{Where do you live?:3}" condition="is" value="Mars"] | |
<p>Mars was the second body to be colonised in the solar system in 2135, 20 years after the moon.</p> | |
[/gravityforms] | |
[gravityforms action="conditional" merge_tag="{Where do you live?:3}" condition="is" value="Titan"] | |
<p>Titan's colony is only recently established. You're one of only 500 people currently living there!</p> | |
[/gravityforms] |
What about "Else" or "Else if" conditions?
What about "Else" or "Else if" conditions?
No, sorry. Gravity Forms only supports simple IF conditions with this syntax. Use PHP if you'd like to include more complex logic: https://gravitypdf.com/documentation/v5/developer-php-form-data-array/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jake!
I try to create my own pdf template for gravity form. I create my html structure and add the merge tag to it. But I don't know how to create core template with it. Can you help me with that
https://gist.github.com/Alexeinporis/4efb90d4617b4bf5d1ca7f8588386f6b