How to setup defaults for fields in multiple locations

8 posts by 2 authors in: Forums > CMS Builder
Last Post: February 18, 2011   (RSS)

By csdesign - February 15, 2011

Okay, I don't know if that subject line made enough sense.

Here's what I want to accomplish:
On the Big Horn Status (blue table) screenshot - there are a list of ski trails/runs. I would like the client to be able to go down a list and mark the ones that are open - OPEN would then replace CLOSED in that column and same thing with whether the run was groomed overnight. (see screenshot in editor - my feeble attempt that's not working)

Basically, I believe I need to have each field set as having the default "CLOSED" and "NO" and then if the client goes down the list in the editor and checks that run, it changes to OPEN or YES.

Is this doable? I would appreciate the help. Thanks!! Tina
Attachments:

picture-27.png 92K

picture-26.png 24K

Re: [csdesign] How to setup defaults for fields in multiple locations

By Jason - February 16, 2011

Hi Tina,

It sounds doable. Would you be able to attach the .php file you're currently working with? That way I can see what your code is doing so far and can then give some examples of how to fix it.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How to setup defaults for fields in multiple locations

By csdesign - February 16, 2011

sure thing! thanks Jason!
Attachments:

mountain-stats.php 32K

Re: [csdesign] How to setup defaults for fields in multiple locations

By Jason - February 16, 2011

Hi Tina,

Here's an example to help get you started.

In this example code, I've had to make a number of assumptions. First, that the name of your check box list fields are open_trails, and groomed_overnight. I've also assumed that the values of your list are the text fully spelled out (ie, "Homebound Traverse").

The first thing we do is to set up an array with the text we want to be able to display. Then we take our list fields and turn them into arrays we can use:

<?php

$openTrailText = array( 0 => 'CLOSED', 1 => 'OPEN');
$groomedText = array( 0 => 'NO', 1 => 'YES' );

$open_trails = explode( '\t', trim($mountain_statsRecord['open_trails'], '\t'));
$groomed_overnight = explode( '\t', trim($mountain_statsRecord['groomed_overnight'], '\t'));

?>


After that we output out text based on whether or not a name is in our array. Here's an example for Homebound Traverse"

<tr>
<td align="left" valign="top"><img src="images/trail-easy.png" alt="easy trail" width="23" height="18" align="absbottom" />Homebound Traverse</td>
<td align="center" valign="top" class="tableInfo"><?php echo $openTrailText[ in_array('Homebound Traverse',$open_trails)];?></td>
<td align="center" valign="top" class="tableInfo"><?php echo $groomedText[ in_array('Homebound Traverse',$groomed_overnight)];?></td>
</tr>


Please note that this code is untested and may need to be modified depending on how your data is being stored.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How to setup defaults for fields in multiple locations

By csdesign - February 16, 2011

thanks Jason! I'll try it out!

Re: [csdesign] How to setup defaults for fields in multiple locations

By Jason - February 17, 2011

Hi,

I'll need to be able to take a closer look at what you're storing. If you could fill out a [url http://www.interactivetools.com/support]2nd Level Support Request[/url]. I can take a quick look at what's happening.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [csdesign] How to setup defaults for fields in multiple locations

By Jason - February 18, 2011

Hi,

I took a look and found the issue. In the code I gave you, we used single quotes around the tab characters ('\t') when creating our arrays. We needed to be using double quotes. Everything works after that.

So the new code now looks like this:

$openTrailText = array( 0 => 'CLOSED', 1 => 'OPEN');
$groomedText = array( 0 => 'NO', 1 => 'YES' );

$open_trails = explode( "\t", trim($mountain_statsRecord['open_trails'], "\t"));
$groomed_overnight = explode( "\t", trim($mountain_statsRecord['groomed_overnight'], "\t"));


Hope this helps.

Jason
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/