Stopping certain fields from displaying in all records

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

By Mel - December 21, 2012

I have a section editor called Bios which is the master section for adding records

I add records by logging in to admin and not through a php page

In the Bios section there are roughly 100+ fields some are text, picture uploads, and others are check boxes


Of these 100 plus, around 60 of these are check boxes that deal with towns/cities/regions

for example the field tw20 is Alderly Edge, cu1 is Ambleside ...... etc, etc, etc

Most of the other check boxes, text areas, image upload boxes deal with bio details of the individual

So if I design a list page with the following

list($biosRecords, $biosMetaData) = getRecords(array(
    'tableName'   => 'bios',
    
    'where' => "  ambleside='1' OR ambleside60='1' OR ambleside90='1' OR ambleside2='1'",

This works fine for ambleside it loads all the individual bios record thumbnails and link to the individual record page which in turn displays a single bio record with all details

Up until now this has worked fine

However for a person to visit certain areas a minimum appointment time is required, so trying to be clever I added extra check boxes like

ambleside60 - which equals 60 mins
ambleside90 - which equals 90 mins        
ambleside2 -   which equals 2hrs

Then added the following code to the master single record page - which is used for all bios irrespective of town/city/region

<?php if ($biosRecord['ambleside60'] == '1'): ?>**<?php echo $biosRecord['name'] ?>'s minimum appointment time for Ambleside is 1hr
            <?php elseif ($biosRecord['ambleside90'] == '1'): ?>**<?php echo $biosRecord['name'] ?>'s minimum appointment time for Ambleside is 90 minutes
            <?php elseif ($biosRecord['ambleside2'] == '1'): ?>**<?php echo $biosRecord['name'] ?>'s minimum appointment time for Ambleside is 2hrs

Which works fine for ambleside but when you go to the Alderly Edge listings page or any other town/city/region and click on the same persons individual record link

Yes youv'e guessed it it also shows the above text up on that individual record page as well - because the check boxes are ticked on their bio's

And of course if you added more minimum appointment times for other areas, you will get a whole bunch more of irrelevant text showing up in single record pages for other towns/cities/regions

So a two part problem

1. How do I stop the text showing up in unrelated areas and only the places it is meant for

2. if I keep adding the else/if's for other towns to the master single record detail page it could get very cumbersome

Also I have this gut feeling that having a 100 plus fields on the master Bios section is possibly not the best way to do things

Initially I need to solve problems 1 & 2 but I am also open to suggestions as to a better way of organising things when it comes to the master Bios section or it may be that I need to organise it differently to solve questions 1 & 2

Thank you for your comments and help in advance
Mel
    


Hi Mel,

Are you passing any data to the detail page to tell it which town/city/region the user is from? 

If your planning on displaying all of the locations for every user, you could reduce the number of check boxes by having a wysiwyg editor and manually entering all of the data.

Another option is to replace grouped checkboxes with a list field. I've attached a screenshot of how you could set up the list field.

Then you could display what has been selected using the fields label:

 <?php echo @$biosRecord['amberside_time:label']; ?> 

This will reduce having 3 checkbox fields down to one 1 list field, and should make the detail page code look cleaner. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

example_003.png 15K

Hi Mel,

I'm assuming that there are a finite list of tons to be visited?

If that's true, then why not use Greg's suggestion of pull down menus and some sort of multi field search for information only where fields contain the keyword (ambleside, manchester, etc.)

Also,

Don't know if there's a tree to bark up here, but take a look at these two free plugins:

http://www.interactivetools.com/add-ons/detail.php?Show-Hide-Dependent-Fields-Plus-1060

and

http://www.interactivetools.com/add-ons/detail.php?Show-Hide-Fields-For-Users-1036

There may be a concept or two that will work for you.

Hope that helps

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

Mel,

I''ve attached a viewer that I use to cull records for particular exhibition submissions from a large database of submission records

maybe an idea will appear.

look around line 45 and 165.

I basically set the where from a pull down llist and use it to determine which records will show.

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
Attachments:

submissions_emaillist.php 11K

By Mel - December 24, 2012

Hi Jerry,

Will take a look at the attachement and the plugins you mentioned

In the meantime I have come up with a work around for a particular Area and locations within the area by doing the following

1. Set up a seperate detail page for the area and its locations

2. Manually coded the location pages with an ID that is passed to the new detail page

<a href="details1.php?id=cu6&num=<?php echo $biosRecord['num'];?>">View Details</a>

3. Then on the new detail page put the code below which works and shows the minimum appointment times for an individual record

<?php if ($id=='cu1'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['ambleside_times:label']; ?>
            <?php elseif ($id=='cu2'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['barrow_times:label']; ?>
            <?php elseif ($id=='cu3'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['carlisle_times:label']; ?>
            <?php elseif ($id=='cu4'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['cockermouth_times:label']; ?>
            <?php elseif ($id=='cu5'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['dalton_times:label']; ?>
            <?php elseif ($id=='cu6'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['kendal_times:label']; ?>
            <?php elseif ($id=='cu7'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['ulverston_times:label']; ?>
            <?php elseif ($id=='cu8'): ?>
            <?php echo $biosRecord['name'] ?>'s
            <?php echo @$biosRecord['windermere_times:label']; ?>
            <?php else: ?>
              <?php endif ?>      

But this is a quick fix just for a particular area and set of locations within that area where minimum appointment times are required

In the medium term hopefully there is another way of doing this, otherwise it will mean that I have to manually re-code in excess of 450 pages and growing! in order to pass values through and also end up with a massive list of if statements on the detail page that covers every town and sub category for that town/location

The 450 pages come about as all the main and sub categories are static pages and NOT dynamically produced - this has been done from a search engine point of view as each page has the title, description and keywords crafted for particular search terms - a ton of work but it has resulted in a lot of top 10 positions

If anybody would like to contribute to possible solutions to this, I would be most grateful

In the meantime a happy festive season to everyone

Mel