CB Content Bot

6 years 3 months ago #301407 by 3cellhosting
CB Content Bot was created by 3cellhosting
Hello Support,

I am struggling with the basics again (no surprise there).

I have to display a page with a list of Secretaries contact details and the client didn't like the CB list as I have already done a table elsewhere that they do like. (I know, the table will be converted to divs eventually for responsiveness).

My initial thought was to use the content plugin to populate the correct rows in the table. This way it will update when the secretaries are updated, there is a finite number of records as they represent clubs. My problem occurs with addresses as we have 6 available fields and some people only need 4 or 5 of the fields.

How can I concatenate the fields into one block of text and ignore empty fields?

I was guessing initially that the concatenation would be like this...

<td>[cb:userfield field="cb_secaddress1" user="58" /], [cb:userfield field="cb_secaddress2" user="58" /], [cb:userfield field="cb_secaddress3" user="58" /], [cb:userfield field="cb_sectown" user="58" /], [cb:userfield field="cb_seccounty" user="58" /], [cb:userfield field="cb_secpostcode" user="58" /]</td>

Obviously all fields would be added but there could be blanks so I end up with two commas perhaps Address-1, Address-2,,Town, County, Postcode

All advice gratefully received.

Regards

David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

Please Log in to join the conversation.

6 years 3 months ago #301410 by krileon
Replied by krileon on topic CB Content Bot
Use IF conditions to exclude empty fields. Example as follows.

[cb:if cb_secpostcode!=""], [cb:userfield field="cb_secpostcode" user="58" /][/cb:if]

See the bottom of the substitutions tutorial below for further IF usage information.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: 3cellhosting

Please Log in to join the conversation.

6 years 3 months ago - 6 years 3 months ago #301416 by 3cellhosting
Replied by 3cellhosting on topic CB Content Bot
Hi Kyle,

OK - Perhaps I am getting it wrong still? Here is code I have used...
<td>&nbsp;[cb:userfield field="firstname" user="58" /] [cb:userfield field="lastname" user="58" /]</td>
			<td>&nbsp;[cb:if cb_secaddress1!=""][cb:userfield field="cb_secaddress1" user="58" /][/cb:if][cb:if cb_secaddress2!=""], [cb:userfield field="cb_secaddress2" user="58" /][/cb:if][cb:if cb_secaddress3!=""], [cb:userfield field="cb_secaddress3" user="58" /][/cb:if][cb:if cb_sectown!=""], [cb:userfield field="cb_sectown" user="58" /][/cb:if][cb:if cb_secpostcode!=""], [cb:userfield field="cb_secpostcode" user="58" /][/cb:if]<br />[cb:userfield field="email" user="58" /]</td>
			<td>&nbsp;[cb:userfield field="cb_sectelno" user="58" /]</td>

Cell 1 appears correctly and so does cell 3. The 2nd cell displays the email address but none of the if statements deliver any output.

If I edit the 3rd cell to <td>&nbsp;[cb:if cb_sectelno!=""][cb:userfield field="cb_sectelno" user="58" /][/cb:if]</td> then the telephone number disappears. So it seems the syntax for cb:if may be wrong?

Sorry to be a pain. So close but so far.

PS: !="" doesn't work because the default in the database is NULL so if I use !="NULL" the content is delivered.

Regards

David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

Please Log in to join the conversation.

6 years 3 months ago - 6 years 3 months ago #301418 by 3cellhosting
Replied by 3cellhosting on topic CB Content Bot
Hi Kyle,

OK - I think I have found the problem. The fields that did show all appear on the user profile. The address fields are not on the profile so when I set one to appear on the profile it then appeared in the table.

I need to find a solution as we don't want to display their addresses on their profile tab. I will see what I can do to hide that information.

Getting there!

After discovering that NULL is important I find that records with NULL in database are displayed still, although it is a hyphen.

Regards

David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

Please Log in to join the conversation.

6 years 3 months ago - 6 years 3 months ago #301443 by 3cellhosting
Replied by 3cellhosting on topic CB Content Bot
Hello Kyle,

I have found a bigger issue now. Hoping it is a setting somewhere but the rendered text does not appear on Mac devices. All other text is displayed as normal.

P.S: (added after original post) A colleague has checked for me and his browser is throwing up a warning

The link and access details are in the confidential information. If you need admin access then let me know and I will provide a login for you.

[REMOVED]

Regards

David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.
Attachments:

Please Log in to join the conversation.

6 years 3 months ago #301446 by krileon
Replied by krileon on topic CB Content Bot
You have user="58" specified for your field substitutions, but not for your IF substitutions. So it's probably conditioning the wrong user. So for example you'd probably have the below.

[cb:if user="58" cb_secpostcode!=""], [cb:userfield field="cb_secpostcode" user="58" /][/cb:if]

NULL shouldn't be an issue and works fine with !="" conditions in my tests.

P.S: (added after original post) A colleague has checked for me and his browser is throwing up a warning

Nothing to do with CB. Your Joomla template or an extension you've installed is logging that to the browser console. Facebook does this and for whatever reason others decided to copy doing it.

The link and access details are in the confidential information. If you need admin access then let me know and I will provide a login for you.

Do not share login credentials on the forums and do not provide credentials that were not requested. We can not guarantee Kunena confidential tags will always behave the way they currently do.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.186 seconds