Help needed with hide/show plugin please
3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 3, 2014 (RSS)
By willydoit - July 2, 2014
Hi all, hope no-one minds my double posting this here as I originally posted it in the plugins forum but it hasn't even been viewed there so as my need to understand this is pretty urgent so I can decide whether we are able to use it I thought I would post it here too.
Before we start am not a programmer of any type so maybe I have misunderstood what this plugin does or have bitten off more than I can chew.
What I currently have
I currently have five different sections designed to store information on different businesses within certain categories. These are Serviced Accommodation, self catering accommodation, holiday property, camp and caravan site. and I also have a fifth table for other general business types. Each of the accommodation related sections have "services/facilities provided" checklists which the advertisers need to complete so that visitors to the site can search against certain services/facilities they require from their accommodation. As you can imagine, the services and facilities applicable differ between each accommodation type, for example whether there is "caravan rental available" or a "shower block" wouldnt be applicable to a hotel. Because each category had different checklists I thought it would be simpler and less confusing for our advertisers if the sections for each accommodation type were created a separate sections, hence why we ended up with 5 different sections.
Hopefully that all makes sense.
What I want to do
I would ideally like to merge all the 5 existing sections to become just one section and in doing so have only the fields relevant to the selected business category displayed when a business_category field is selected. So when a new record is created a user would be presented with a number of basic fields, business name, address etc, basically all the fields which would be applicable to any/all the business categories. Then when they select the business category which is relevent to their business from a drop down list I want the additional fields applicable to that business type to be displayed so they can be completed by the user. I don't want the user to be confused by seeing option boxes for services or facilities which are not applicable to that business category.
Why I thought that was possible and what happened next
I came across the ShowHideDependantFields plugin and assumed that it would do what I wanted, because our database is currently live and I didnt want to risk screwing anything up I made a backup of the database and installed it on another domain which we are using to develop our current rewrite of the site. after a few initial teething issues cmsb seems to be working fine with the restored database so so far so good.
I then uploaded the plugin to the plugins folder and activated it within cmsb. I then took a look at the config.php and this is where I start to come unstuck. Not being a programmer and a bit simple I could only guess at what was required with the file and so I completed it as shown below just to see whether it worked as I expected. Having done so I assumed that when I accessed the section "bridlington_business" there would only be the business_category element showing (as nothing had yet been selected in business_category) and when I selected the drop down list "business_category" and selected one of the options of either Serviced Accommodation - 'Self Catering Accommodation - Holiday Property - Camp or Caravan Park or Other Business that the fields I had listed as being applicable to that business category would magically appear. (note that the current config.php is just a test to display different fields depending upon which category is selected)
However in reality what is happening is that all the fields are visible as soon as I try to create a new record and nothing happens when I select the business category, which leads me to believe that I have either misunderstood what the plugin is meant to do or I haven't configured the config.php correctly which I have posted below.
If someone could explain to me in words of one syllable where I have gone wrong it would be gratefully appreciated.
Thanks in advance for any help provided.
Below is my created config.php.
"bridlington_business" is the name of the section and "business_category" is the field with the drop down box of selections. Serviced Accommodation - Self Catering Accommodation - Holiday Property - Camp or Caravan Park or Other Business are the options that are available to be selected from the "business category" options list.
<?php if(!isset($shdfpIncluded)) die('Restricted Access');
// refer to instructions.txt for detailed instructions and examples
$fields = array(
// enter your rule sets here //
'bridlington_business' => array(
'business_category' => array(
'_none_' => array('business_category'),
'_any_value_' => array('business_category'),
'Serviced Accommodation' => array('business_name','telephone'),
'Self Catering Accommodation' => array('town', 'postcode'),
'Holiday Property' => array('website', 'email'),
'Camp or Caravan Park' => array('field_3', 'field_4'),
'Other Business' => array('field_3', 'field_4'),
),
),
);
$devmode = false;
?>
By Dave - July 3, 2014
Hi Willy,
Which plugin is this you're using? Is it this one?
http://www.interactivetools.com/add-ons/showhide-dependent-fields-plus/
We generally don't support any of them, and I'm not very familiar with either of the plugins myself, but what I'd suggest is starting by creating a test section with just a few fields and working with that. Get it working with just a few fields and then try adding things.
Hope that helps!
interactivetools.com
By willydoit - July 3, 2014
Hi Dave,
it is stripped down as basic as I can make it, but as I am not sure it is even designed to do what I am wanting it doesnt make it any easier.
Thanks anyway, hopefully someone who has used the plugin will be able to provide some help.