Help coding this mess up.

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 16, 2014   (RSS)

By KCMedia - April 14, 2014

Hi guys

i have this code that i need to build into the cmsb but i am having all kinds of issues trying to get it working, i have tried everything i know but just cant get it to work.

This is the code from the html

        <section id="cases">
          <div class="row row-1">
            <ul class='sortable clearfix'>
                <li><div class="table-cell"><a href='javascript://'><img src="images/case-img-1.jpg"></a></div></li>
                <li><div class="table-cell"><a href='javascript://'><img src="images/case-img-2.jpg"></a></div></li>
                <li><div class="table-cell"><a href='javascript://'>FINANCIAL<br/>SERVICES</a></div></li>
            </ul>
            <div class="tabs">
                <div id='tab1' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href="javascript://" class="img"><img src="images/case-img-2.jpg"></a></div>
                        <article class="acc-content">
                          <h2 class="title"> The 1 Tab Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>
                <div id='tab2' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href="javascript://" class="img"><img src="images/case-img-1.jpg"></a></div>
                        <article class="acc-content">
                          <h2 class="title"> The 2 Tab Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>
                <div id='tab3' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href='javascript://'>SIGNIFICANT<br/>GROCERY RETAILER</a></div>
                        <article class="acc-content">
                          <h2 class="title">The 3 Tab  Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>  
            </div>   
          </div>
          <div class="row row-1">
            <ul class='sortable clearfix'>
                <li><div class="table-cell"><a href='javascript://'>SERVICES<br/>ORGANISATION</a></div></li>
                <li><div class="table-cell"><a href='javascript://'>INDUSTRIAL<br/>ORGANISATION</a></div></li>
                <li><div class="table-cell"><a href='javascript://'>FINANCIAL<br/>SERVICES</a></div></li>
            </ul>
            <div class="tabs">
                <div id='tab4' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href='javascript://'>Section1</a></div>
                        <article class="acc-content">
                          <h2 class="title"> The 1 Tab Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>
                <div id='tab5' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href='javascript://'>Section1</a></div>
                        <article class="acc-content">
                          <h2 class="title"> The 2 Tab Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>
                <div id='tab6' class="tab">
                    <div class='accordion'>
                        <div class="acc-title"><a href='javascript://'>Section1</a></div>
                        <article class="acc-content">
                          <h2 class="title">The 3 Tab  Coles Selects Profectus' Financial Transaction Analysis</h2>
                          <div class="cols">
                            <div class="col col-1">
                              <h3>Background</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-2">
                              <h3>Challenge</h3>
                              <p>Coles has more than 100,000 employees and over 11 million customer transactions per week. They process more than 600,000 accounts payable transactions per month.</p>
                            </div>
                            <div class="col col-3">
                              <h3>Solution</h3>
                              <p>In 2003 Coles engaged Profectus to provide ongoing Financial Transaction Analysis (FTA) services to prevent errors from occurring and ensure best practice processing is maintained. Profectus detects and recovers lost profits due to overpayments and under </p>
                              <ul>
                                <li>Duplicate Payments / Payment Errors</li>
                                <li>Expense Category Reviews</li>
                                <li>Supplier Statement Analysis</li>
                                <li>Freight Analysis</li>
                              </ul>
                            </div>
                          </div>
                          <section class="quote">
                            <blockquote>
                            We have engaged Profectus for over 10 years to provide a full range of compliance audit services including AP audits and Merchandise audits. We needed a solution to manage the checking of all invoices for our 40 Freight vendors to ensure we are not overcharged.<br/><br/>
                             Profectus CCS has automated the cost checking of hundreds of invoices against all contract terms at consignment level including automated invoice capture, cost checking, SAP journal preparation and accrual processes.
                             
                            </blockquote>
                            <div class="from"><span class="name">Chief Financial Officer</span><span class="info">Major Australian Retailer </span></div>
                            
                          </section>
                        </article>
                    </div>
                </div>  
            </div>   
          </div>
          
         </section>

here is the cmsb code

  // load records from 'our_case_studies'

  list($our_case_studiesRecords, $our_case_studiesMetaData) = getRecords(array(
    'tableName'   => 'our_case_studies',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

    <?php foreach ($our_case_studiesRecords as $record): ?>

      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Background: <?php echo $record['background']; ?><br/>
      Challenge: <?php echo $record['challenge']; ?><br/>
      Solution: <?php echo $record['solution']; ?><br/>
      Testimonial: <?php echo htmlencode($record['testimonial']) ?><br/>
      Name: <?php echo htmlencode($record['name']) ?><br/>
      Position: <?php echo htmlencode($record['position']) ?><br/>
      _link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>




      <!-- STEP 2a: Display Uploads for field 'logo' (Paste this anywhere inside STEP2 to display uploads) -->

        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->

        Logo: (Copy the tags from below that you want to use, and erase the ones you don't need)

        <blockquote>

        <?php foreach ($record['logo'] as $index => $upload): ?>


          Upload Url: <?php echo $upload['urlPath'] ?><br/>




          Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>

          Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>



          Image Tags:<br/>

          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
          <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>


          info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/>
          info2 (Caption) : <?php echo htmlencode($upload['info2']) ?><br/><br/>



          Extension: <?php echo $upload['extension'] ?><br/>

          isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>

          hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>

          <hr/>



        <?php endforeach ?>

        </blockquote>

      <!-- STEP2a: /Display Uploads -->




      <hr/>

    <?php endforeach ?>



    <?php if (!$our_case_studiesRecords): ?>

      No records were found!<br/><br/>

    <?php endif ?>

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

By Chris - April 15, 2014

Hi Craig,

Can you give us a bit of an overview of what it's supposed to do and what's going wrong?

All the best,
Chris

By KCMedia - April 15, 2014 - edited: April 15, 2014

Hi Chris

if you look at the template file http://www.profectusgroup.com/_template/Case.html and you will understand each row of 3 icons that open need to be inside there own if statement but also the javascript that opens them also needs to be inside that statement also.

I have tried so many ways of getting to work but i have just stopped working on it as it have just caused so many issues with displaying it right, it really needs to do so many loops over so many things i am just brain dead about it all.

Also inside each record there is tab number and all kinds of classes that go up in numbers like row1, row2 etc all over the place.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

By Chris - April 16, 2014

Hi Craig,

Looking at your template, it seems like you're going to need to output 3 records at a time for each row, so you can do this with array_splice(). Let's start with that:

<?php

// loop for each row until we run out of records
while (true) {
  
  // get next 0-3 records, removing them from the list
  $row = array_splice( $our_case_studiesRecords, 0, 3 );
  
  // if we got 0 records, we're done, so break out of the while loop
  if (!$row) {
    break;
  }
  
  echo "<h1>Start of row!</h1>\n";  
 
  foreach ($row as $record) {
    echo "<h2>Start of record!</h2>\n";
    showme($record);
  }

}

?>

Furthermore, the template requires you to first list the titles of each record (in <UL CLASS="sortable">), then list the contents of each record (in <DIV CLASS="tabs">), so you'll need two foreaches:

<?php

// loop for each row until we run out of records
while (true) {
  
  // get next 0-3 records, removing them from the list
  $row = array_splice( $our_case_studiesRecords, 0, 3 );
  
  // if we got 0 records, we're done, so break out of the while loop
  if (!$row) {
    break;
  }
  
  echo "<h1>Start of row!</h1>\n";
  echo "<h2>Start of row list!</h2>\n";  
  
  foreach ($row as $record) {
    showme($record['title']);
  }

  echo "<h2>Start of row content!</h2>\n";

  foreach ($row as $record) {
    echo "<h2>Start of record!</h2>\n";
    showme($record);
  }

}

?>

With that structure in place, the next thing to do is copy the content in from the template, and replace the fields with the field code from the code generator:

<?php

// tab counter, so we have unique tab numbers (e.g. tab1, tab2, tab3...)
$tabCounter = 0;

// loop for each row until we run out of records
while (true) {
  
  // get next 0-3 records, removing them from the list
  $row = array_splice( $our_case_studiesRecords, 0, 3 );
  
  // if we got 0 records, we're done, so break out of the while loop
  if (!$row) {
    break;
  }
  
  ?>
    <div class="row row-1">
      <ul class='sortable clearfix'>
        <?php foreach ($row as $record): ?>
          <li><div class="table-cell"><a href='javascript://'><?php echo htmlencode($record['title']) ?></a></div></li>
        <?php endforeach ?>
      </ul>
      <div class="tabs">
        <?php foreach ($row as $record): ?>
          <?php $tabCounter = $tabCounter + 1; ?>
          <div id='tab<?php echo htmlencode($tabCounter) ?>' class="tab">
            <div class='accordion'>
              <div class="acc-title"><a href='javascript://'><?php echo htmlencode($record['title']) ?></a></div>
              <article class="acc-content">
                <h2 class="title"><?php echo htmlencode($record['name']) ?></h2>
                <div class="cols">
                  <div class="col col-1">
                    <h3>Background</h3>
                    <?php echo $record['background']; ?>
                  </div>
                  <div class="col col-2">
                    <h3>Challenge</h3>
                    <?php echo $record['challenge']; ?>
                  </div>
                  <div class="col col-3">
                    <h3>Solution</h3>
                    <?php echo $record['solution']; ?>
                  </div>
                </div>
                <section class="quote">
                  <blockquote>
                    <?php echo htmlencode($record['testimonial']) ?>
                  </blockquote>
                  <div class="from"><span class="name"><?php echo htmlencode($record['name']) ?></span><span class="info"><?php echo htmlencode($record['position']) ?></span></div>
                </section> 
              </article>
            </div>
          </div>
        <?php endforeach ?>
      </div>
    </div>
  <?php
  
}

?>

Does that help? Please let me know if you have any questions.

All the best,
Chris