Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Not sure I fully understand how to use globals.php to do this.

I have a snippet with the following code
Code: Select all
       <!-- Action box style 3 new section -->
      <section class="hg_section bg-white ptop-80 pbottom-80">
         <div class="container">
            <div class="row">
               <div class="col-md-12 col-sm-12">
                  <!-- Action box element style 3 -->
                  <div class="action_box style3" data-arrowpos="center">
                     <div class="action_box_inner">
                        <div class="action_box_content">
                           <!-- Content -->
                           <div class="ac-content-text">
                              <h4 class="text"><span class="fw-semibold">0% Finance avaliable on all Remaps.<br> Spread the cost over 4 months</span></h4>
                              <h5 class="ac-subtitle">Contact us for more information</h5>
                           </div>
                           <!--/ Content -->

                           <!-- Buttons -->
                           <div class="ac-buttons">
                              <a class="btn btn-lined ac-btn" href="contact.php" target="_blank">Contact Us</a>
                           </div>
                           <!--/ Buttons -->
                        </div>
                        <!--/ .action_box_content -->
                     </div>
                     <!--/ .action_box_inner -->
                  </div>
                  <!--/ .action_box .style3 -->
               </div>
               <!--/ col-md-12 col-sm-12 -->
            </div>
            <!--/ row -->
         </div>
         <!--/ container -->
      </section>
      <!--/ Action box style 3 new section -->


I want to make the 2 text fields so they can be edited form the admin side.
Code: Select all
<cms:editable name='cta_large' type='text' order='8'>0% Finance avaliable on all Remaps.<br> Spread the cost over 4 months</cms:editable></h4>
<cms:editable name='cta_small' type='text' order='8'>Contact us for more information</cms:editable>


Any ideas?
1. Define the two editable regions within a global template (say named 'globals.php') as follows -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Global Settings' executable='0'>
    <cms:editable name='cta_large' type='text' order='8'>0% Finance avaliable on all Remaps.<br> Spread the cost over 4 months</cms:editable></h4>
    <cms:editable name='cta_small' type='text' order='8'>Contact us for more information</cms:editable>
</cms:template>
<?php COUCH::invoke(); ?>

2. Modify your snippet to fetch and show values from the global template as follows -
Code: Select all
<!-- Content -->
<div class="ac-content-text">
  <h4 class="text"><span class="fw-semibold"><cms:get_custom_field 'cta_large' masterpage='globals.php' /></h4>
  <h5 class="ac-subtitle"><cms:get_custom_field 'cta_small' masterpage='globals.php' /></h5>
</div>
<!--/ Content -->

Now you may use the snippet in several templates and they'll all show values fetched from a single location (globals.php).

Hope it helps.
Perfect, thanks
3 posts Page 1 of 1