Commas and two Detail viewers from one section
3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 30, 2010 (RSS)
By fleff - July 29, 2010
It's a real estate website. A property may be offered for rent for the summer and, let's say, annually. If so, the listing should display "Summer, Annual" on the listings page and the details page. My problem is the comma. What I would like is a single field called "Rental Period" that offers a choice of one or more periods: Summer, Seasonal, Annual or Short Term. If more than one period is selected, they should be separated by commas on the viewer page. I've tried the code in the forum for commas but It works with separate fields, not multiple choice in one field. Is there some way of doing this without setting up four fields? I'd like to be able to do a search on the keywords in the single field called Rental Period using a multi-value pulldown or checkboxes.
Also, I am trying to set up the entering of listings so that my client doesn't have to enter the info twice, once in a section for Sales and a second time in a section for Rentals if the property is offered both ways. I have set up a few fields specific to Rentals in a single section for houses (vs. land), and the houses.php and houses_details.php viewer pages work fine for sales. I have also set up a viewer list page called rentals.php to display properties For Rent. That works fine too, but I can't figure out how to get a listing to go from there to a rentals_details.php page instead of the houses_details.php page where the info is different from the For Rent info. Is there some way to do this from a single section?
Thanks for your help,
Farnham
Also, I am trying to set up the entering of listings so that my client doesn't have to enter the info twice, once in a section for Sales and a second time in a section for Rentals if the property is offered both ways. I have set up a few fields specific to Rentals in a single section for houses (vs. land), and the houses.php and houses_details.php viewer pages work fine for sales. I have also set up a viewer list page called rentals.php to display properties For Rent. That works fine too, but I can't figure out how to get a listing to go from there to a rentals_details.php page instead of the houses_details.php page where the info is different from the For Rent info. Is there some way to do this from a single section?
Thanks for your help,
Farnham
Re: [fleff] Commas and two Detail viewers from one section
By Jason - July 30, 2010
Hi Farnham,
In regards to your first question, it sounds like a multiselect drop down would be the best solution for you. When more than one option is selected, CMS Builder stores them as a string separated by tabs (\t). It also puts a tab character at the beginning and end of the string. Here is an example of how you could get a comma in between the options:
The first line removes the tab from the front and end of the string. The second line replaces all the remaining tab characters with commas. You can then output the variable $record['rental_period'] where ever you want.
As for the second question, it depends on how you set it up. I think the best thing would be to have 2 check boxes: 1 for "Rental" 1 for "For Sale". On different pages, you can then decide which fields to display based on which check boxes are selected.
Hope this helps.
In regards to your first question, it sounds like a multiselect drop down would be the best solution for you. When more than one option is selected, CMS Builder stores them as a string separated by tabs (\t). It also puts a tab character at the beginning and end of the string. Here is an example of how you could get a comma in between the options:
$record['rental_period'] = trim($record['rental_period'],"\t");
$record['rental_period'] = str_replace("\t",",",$record['rental_period']);
The first line removes the tab from the front and end of the string. The second line replaces all the remaining tab characters with commas. You can then output the variable $record['rental_period'] where ever you want.
As for the second question, it depends on how you set it up. I think the best thing would be to have 2 check boxes: 1 for "Rental" 1 for "For Sale". On different pages, you can then decide which fields to display based on which check boxes are selected.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
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] Commas and two Detail viewers from one section
By fleff - July 30, 2010
Thanks, Jason. The commas work fine with the code you posted.
As to the the viewer information, I have a Status dropdown field:
For Sale
Sold
For Rent
Rented
Do you mean to apply if statements based on the selected option to show or hide the proper fields for that status on the details page? Sounds good. I'll try it.
Farnham
As to the the viewer information, I have a Status dropdown field:
For Sale
Sold
For Rent
Rented
Do you mean to apply if statements based on the selected option to show or hide the proper fields for that status on the details page? Sounds good. I'll try it.
Farnham