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

By Mel - December 21, 2012

Hi Greg,

Not a 100% sure I know what you are asking but I will have a stab at it

If I am looking for company to visit me in Ambleside I go along to the Ambleside listing page

On that listing page will be displayed lets say 5 thumbnail pics which link to the individual record page, on the individual record page all the persons bio is displayed

Some will visit Ambleside for 1 hr and others will require a longer appointment  time, hence the 1hr 90 mins 2hrs text

But the same people that visit Ambleside also visit other places lets say for example Manchester plus many other areas, so if you go to the Manchester page it will show lets say again 5 thumbnails and you click on the thumbnail and it takes you to the same master individual record page which at the present time still has the text on about Ambleside appointments

But I would not be interested in what their minimum appointment time was for Ambleside, obviously if it were the case that they had minimum appointment times for Manchester, then I would want them to show but NOT the comments about Ambleside

When you click on a thumbnail in any town/city/region section it does not as far as I am aware pass any information through to the detail page showing what town/city/region page you have clicked through from - which judging by your question might be what is adding to the problem - below is the code that display the thumbnail and link to the detail page

------------------------------------

 <div align="center" class="img_border"><?php foreach ($biosRecord['newimage'] as $upload): ?>
  <?php if ($upload['isImage']): ?>
          <a href="<?php echo $biosRecord['_link'] ?>" target="_self"><img src="<?php echo get_custom_watermark_url($upload['urlPath'], '110watermarkSmall.png') ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo $biosRecord['name'] ?>"></a>
          <?php else: ?>     
          <?php endif ?>
    </div>
    <?php endforeach ?>
              
     <div align="right"style="padding-top:3px;">
     <a href="<?php echo $biosRecord['_link'] ?>" target="_self">View My Details</a>
     </div>

------------------------------------

Thanks

Mel

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