Help coding this mess up.

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

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

By KCMedia - April 16, 2014

HI Chris

wow that was great instructions and it works perfect that was really doing my head in thanks for that.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz