Answers.Body: <p>To Override Main.tpl file - you can try using Main.extra.tpl which should work </p>
  
  <p>But Please try using - custom File - because if you are overriding the same file in some other extension it might not work sometime </p>
  
  <pre><code>function hook_civicrm_buildForm($formName, &amp;$form) {
  $templatePath = realpath(dirname(__FILE__)."/templates");
  CRM_Core_Region::instance('billing-block')-&gt;add(array(
      'template' =&gt; "{$templatePath}/custom/custom.tpl",
  ));
  }
  </code></pre>
  
  <p>and add your coding in the custom.tpl</p>
  
  <p>Also please note that for billing address all the fields are hard coded in the core also same for validation - </p>
  
  <p>If you need more help please let me know - thanks</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-09T14:14:58.497Z
Answers.LastActivityDate: 2016-03-09T14:14:58.497Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Body: <p>I found that the <code>BillingBlock.tpl</code> is included in <code>Main.tpl</code> file and all the variables are assigned to this templates using <code>Main.php</code> file. I can hardcode the variable there but I am worried about if there is another core update. So I am trying to override the <code>Main.php</code> file from my custom extension but it's not happening.</p>
  
  <p>My question is how do I override the <code>Main.php</code> file in civicrm from custom extension ( custom payment processor ) or if there is other method built in civicrm with which I can pass variable to <code>Main.tpl</code> or <code>BillingBlock.tpl</code>.</p>
  
  <p>P.S. I followed the same directory structure as of core.</p>
  
  <pre><code>customextension
  ├── CRM
     └── Contribute
         └── Form
             └── Contribution
                 └── Main.php
  </code></pre>
  
Tags: <extension><payment-processor>
Title: How to pass custom variables to BillingBlock.tpl?
ThreadText: # How to pass custom variables to BillingBlock.tpl?
  
  (Asked by: username_0 on 2016-03-09)
  
  I found that the BillingBlock.tpl is included in Main.tpl file and all the variables are assigned to this templates using Main.php file. I can hardcode the variable there but I am worried about if there is another core update. So I am trying to override the Main.php file from my custom extension but it's not happening.
  My question is how do I override the Main.php file in civicrm from custom extension ( custom payment processor ) or if there is other method built in civicrm with which I can pass variable to Main.tpl or BillingBlock.tpl.
  P.S. I followed the same directory structure as of core.
  customextension
  ├── CRM
     └── Contribute
         └── Form
             └── Contribution
                 └── Main.php
  
  **Tags:** extension, payment-processor
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-09. Score: 1
  
  To Override Main.tpl file - you can try using Main.extra.tpl which should work 
  But Please try using - custom File - because if you are overriding the same file in some other extension it might not work sometime 
  function hook_civicrm_buildForm($formName, &$form) {
  $templatePath = realpath(dirname(__FILE__)."/templates");
  CRM_Core_Region::instance('billing-block')->add(array(
      'template' => "{$templatePath}/custom/custom.tpl",
  ));
  }
  
  and add your coding in the custom.tpl
  Also please note that for billing address all the fields are hard coded in the core also same for validation - 
  If you need more help please let me know - thanks
  
  
  ---
  
  