Displaying an include based on specific values

6 posts by 3 authors in: Forums > CMS Builder
Last Post: March 12, 2012   (RSS)

I have a site where my client can put events into one of four time segments: 10:15am - 11:15am, 11:30am - 12:30pm, 1:45pm - 2:45pm, or 3:00pm - 4:00pm.

I'd like to present these on a page listed under subheadings for each time segment, so the events taking place at 10:15am - 11:15am would show up under that subheading, and so on.

The live page is here - http://www.springflingevent.ca/sessions2.php - and the session details are displayed via an include, _include-sessions-segment.php.

Every session is being displayed under each time segment, rather than being sorted. Any suggestions on how to get this to work properly, please?

Also, once that's working, how do I get this to display in two columns?

======

_include-sessions-segment.php code:

<?php foreach ($sessions_detailsRecords as $record): ?>
<h2 class="h2Smaller"><strong><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?> &raquo;</a></strong></h2>
<p>Presented by <?php echo $record['presenter_s'] ?><br />
Time: <?php echo $record['time'] ?></p></td>
<?php endforeach; ?>

======

This is the code in sessions2.php that displays the include for 10:15am - 11:15am:

<?php
$_REQUEST['time']="10:15am - 11:15am";
include("_include-sessions-segment.php");
?>

======

Thank you!
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [Jason] Displaying an include based on specific values

Perfect! Thanks, Jason.

http://www.springflingevent.ca/sessions2.php

Any idea how I get this to show up in two columns, please?
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Displaying an include based on specific values

Hi Nigel,

There's a recipe in my CMSB Cookbook http://thecmsbcookbook.com called:

FORMATTING TEXT TO AUTOMATICALLY FLOW EVENLY INTO MULTIPLE COLUMNS

Here’s one approach, that uses a combination of CSS and Javascript to handle the discrepancies in the current implementation of the “proposed” CSS3 multi column rules.

It’s based on the examples shown in these articles:

http://www.alistapart.com/articles/css3multicolumn/

and

http://www.cvwdesign.com/txp/article/360/

So that I could follow the examples in the articles, I created:

A .css style sheet called multi-column.css
A Javascript file called css3-multi-column.js
And a sample page called column-sample.php
,
You can download the CSS, Javascript and sample files from

http://www.thecmsbcookbook.com/downloads/css3-multi-column.zip

Every implementation will be slightly different so I’d recommend playing with the different possibilities listed in the article and in the proposed spec to get your page looking like you want it to.

Because of some conflict issues with the Javascript, you may get css conflicts if you use more than one set of column classes in the same external css file, EVEN IF YOU NAME THE CLASSES DIFFERENTLY.

So either put the column formatting in the head your web page or create a totally different copy of the external .css file for each pages that uses different parameters.

http://www.w3.org/TR/css3-multicol

Note that in this example, the Javascript is called only for IE, and the css style sheet contains -moz and -webkit- prefixes for Mozilla and Safari.

That said, Here’s the pretty simple code that I used:

In the head section of my 2 column viewer (column sample.php), I called the javascript and CSS file with:
<link href="multi-column.css" rel="stylesheet" type="text/css" />
<!--[if IE]>
<script type="text/javascript" src="css3-multi-column.js"></script>
<![endif]-->
[code/]

Then in the body, where I wanted to display the 2 column text, I enclosed it in a <div> tag. You can display multiple fields in the same <div> and they’ll all flow into neat columns.
<div class="column" align="left">
<?php echo $yourRecord['your_field'] ?><br /><br /><hr width="200">
</div>


Since first writing this, I’ve been able to use the technique to create automatic flow in some pretty complex viewers, so experiment.

Hope it works for you.

When you're done could you post the finished code/viewers.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Displaying an include based on specific values

Thanks for the advice, Jerry. I didn't go for the double columns in the end, sticking with just one.

However, I did use Jason's code to help create a form with drop down menus, based on the same data entered into CMSB. This is the page Jason helped me with - http://www.springflingevent.ca/sessions.php - and this is the form page, which uses some of the same records - http://www.springflingevent.ca/register.php.

Here's the code for the include that creates the drop down menus:

<select name="select">
<option>Please choose a session:</option>
<?php foreach ($sessions_detailsRecords as $record): ?>
<?php if ($record['time'] != @$_REQUEST['time']) { continue; } ?>
<option value="TICKETS FOR <?php echo $record['title'] ?>"><?php echo $record['title'] ?></option>
<?php endforeach; ?>
</select>

Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Displaying an include based on specific values

Thanks Nigel,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php