 |

NigelGordijk
User
May 5, 2008, 8:02 AM
Post #1 of 8
(1912 views)
Shortcut
|
|
How to hide empty fields on listings pages?
|
Can't Post
|
|
Hi, there. I've set up Listings Manager for my local Board of Trade's Web site: http://www.newhamburg.ca. I'd like to be able to hide fields that have not been filled in; for example, if the member does not have a fax number, the label shouldn't appear on their profile page: http://www.newhamburg.ca/listman/listings/l0001.shtml. Any ideas, please? Nigel Gordijk Common Sense Design: User-focused Web design Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
(This post was edited by NigelGordijk on May 5, 2008, 8:02 AM)
|
|
|  |
 |

MikeB
Staff
/ Moderator

May 5, 2008, 12:53 PM
Post #2 of 8
(1907 views)
Shortcut
|
|
Re: [NigelGordijk] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi Nigel, Thanks for posting! In this case you could actually use some conditional JavaScript to determine what will be output on the page. In this example you've provided for the "Fax" field, you could just modify your _publish_listing.html template file and replace the existing "Fax" label, with this JavaScript:
<script type="text/javascript"> if ('$lfieldX$') { document.write("Fax:"); } </script> If your "Fax" field (lfieldX in this example) doesn't have a value, then the word "Fax" won't be output. If this field does have a value, whatever you put between the quotes in the "document.write" statement, will be output. I hope this helps! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
(This post was edited by MikeB on May 5, 2008, 12:54 PM)
|
|
|  |
 |

NigelGordijk
User
May 5, 2008, 1:16 PM
Post #3 of 8
(1904 views)
Shortcut
|
|
Re: [MikeB] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi, Mike. Thanks for your reply. At the moment, I have the fax information in a row within a table. In order for your javascript to work, would I need to have the fax details in its own table? Nigel Gordijk Common Sense Design: User-focused Web design Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
|
|
|  |
 |

Jake
Staff
/ Moderator

May 5, 2008, 11:39 PM
Post #4 of 8
(1888 views)
Shortcut
|
|
Re: [NigelGordijk] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi Nigel, The javascript Mike provided will work regardless of whether it is displayed within its own table, a table row, or outside of a table completely. If you wanted to hide the entire table row if there isn't any data for the fax field, just put all of the code for creating the table row inside of the quotes where the text "Fax:" is currently located. Let us know if you have any other questions! ----------------------------------------------------------- Cheers, Jake Swanson - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

NigelGordijk
User
May 29, 2008, 1:23 PM
Post #5 of 8
(694 views)
Shortcut
|
|
Re: [Jake] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi, Jake. Thanks for your reply. The way I have, say, the fax information displayed on the page is as follows: <TABLE border=0 cellspacing=0 cellpadding=0 width=100%> <TR> <TD><P>Fax:</P></TD> <TD> </TD> <TD><P CLASS="pListing">$lfield6$</P></TD> </TR> <TR> <TD VALIGN="top"><IMG SRC="../../../images/single-pixel.gif" WIDTH="120" HEIGHT="1" /></TD> <TD VALIGN="top"><IMG SRC="../../../images/single-pixel.gif" WIDTH="20" HEIGHT="1" /></TD> <TD><IMG SRC="../../../images/single-pixel.gif" WIDTH="446" HEIGHT="1" /></TD> </TR> </TABLE> If a listing doesn't have a fax number, then I don't want the the table above to be shown at all. I can't get Mike's JavaScript sample to hide the whole table, not just the fax info. Is there a way around this? Nigel Gordijk Common Sense Design: User-focused Web design Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
|
|
|  |
 |

MikeB
Staff
/ Moderator

May 30, 2008, 1:28 PM
Post #6 of 8
(675 views)
Shortcut
|
|
Re: [NigelGordijk] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi Nigel, Thanks for the post! If you're using this much code, you'll want to use single quotes for the document.write statements and ensure that you don't have any single quotes anywhere in this block of code. From there, you can just use multiple document.write statements so your code would look like this:
<script type="text/javascript"> if ('$lfield6$') { document.write('<TABLE border=0 cellspacing=0 cellpadding=0 width=100%><TR>'); document.write('<TD><P>Fax:</P></TD><TD> </TD>'); document.write('<TD><P CLASS="pListing">$lfield6$</P></TD></TR>'); document.write('<TR><TD VALIGN="top"><IMG SRC="../../../images/single-pixel.gif" WIDTH="120" HEIGHT="1" /></TD>'); document.write('<TD VALIGN="top"><IMG SRC="../../../images/single-pixel.gif" WIDTH="20" HEIGHT="1" /></TD>'); document.write('<TD><IMG SRC="../../../images/single-pixel.gif" WIDTH="446" HEIGHT="1" /></TD>'); document.write('</TR></TABLE>'); } </script> Let me know how this works for you! :) Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

NigelGordijk
User
Jun 3, 2008, 8:37 AM
Post #7 of 8
(622 views)
Shortcut
|
|
Re: [MikeB] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi, Mike. Thanks for the advice. I tried this and it seems to work on all of the fields, except the one for Clients. When I tried this code, it hid the table for Clients, even if there were actually some listed. I've changed the code back again, but here are two examples of pages, one which does list Clients and one which doesn't (and should therefore not have the table present). http://www.newhamburg.ca/listman/listings/l0001.shtml http://www.newhamburg.ca/listman/listings/l0020.shtml Any idea why the table disappears even if there are clients listed? Thanks! Nigel Gordijk Common Sense Design: User-focused Web design Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
|
|
|  |
 |

MikeB
Staff
/ Moderator

Jun 3, 2008, 12:34 PM
Post #8 of 8
(594 views)
Shortcut
|
|
Re: [NigelGordijk] How to hide empty fields on listings pages?
[In reply to]
|
Can't Post
|
|
Hi Nigel, I'm glad to hear that this is working for most of your fields here. That said, it's a bit tough to tell what might be preventing this from working for you on the "Clients" field. Do you think you could add the code back in for this field so I can have another look at these pages live on the site with the non-functional JavaScript code in there? I look forward to hearing from you Nigel! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
|