How to setup defaults for fields in multiple locations

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

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

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

Hi Jason, I added the code. Right now I'm just getting default answers (pic4) I added it to 4 different trails (Cubby, Homebound Traverse, Bottle Neck and Wild Bill) and set them according to the screenshot-pic 3 (default - closed/no, those checked should be "open" or "yes" or both)

I hope this isn't a stupid question, but I put the first bit of code in the header... hope that was right. I've also re-attached the edited php page.

I double check spelling, etc. I just don't know enough about php (yet) to know what to fix. Your help would be greatly appreciated!

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/