Skip Navigation

[Resolved] Split: Error showing while editing a content template

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 2.05 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 11 replies, has 2 voices.

Last updated by BradH1338 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1906385

Hi many thanks for your reply. I am assuming the page that I must apply this to is as per the page in my attached screen shot. Please could you tell me why there is this error when I open that page and what must I do to solve this. Please see screen shot

#1906411

Hi,

To investigate this error I'll need to see how this content template is set up in the admin area.

Can you please share temporary admin login details?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1908837

Hi Waqar, I trust you are well. I am just following up on my last message to you which included the login details. I'm , hoping you got them and all is order? Regards
Brad

#1909177

Hi Brad,

Thank you for sharing the admin access.

While troubleshooting the error in the "Template for Companies" content template, I noticed that no company post was set to show the information from, in the preview settings.

I've selected one of them and the error is now gone.
( screenshot: hidden link )

regards,
Waqar

#1909229
added sectors.jpg
add sectors-screenshot.jpg

Ok great thank you. Not too sure what that was. So back to my original query. I wanted to add the company sectors to each company as per the attached screen shot. I tried now according to your answer a few days ago. But I don't think I did it correctly. Because now it shows numbers instead of the actual sector names like "mining", "agriculture" etc. Please see 2nd screenshot

#1910383

Thanks for writing back.

This limitation of the check boxes type custom field is already known and under review:
https://toolset.com/errata/cannot-output-checkboxes-field-option-titles/

The single block or the Types field shortcode currently doesn't output the option titles and for that you'll have to register a custom shortcode:


add_shortcode( 'checkboxes', function( $atts = [] ){

// provide defaults
$atts = shortcode_atts(
array(
'field'=> 'null',
'separator' => ', '
),
$atts
);

$output = "";
global $post;

$field_settings = types_get_field( $atts['field'] );

$field_values = get_post_meta( $post->ID, 'wpcf-'.$atts['field'], false );
$field_value_options = array_keys( $field_values[0] );

$separator = "";
foreach ($field_value_options as $field_value_option) {

$field_value_option_title = $field_settings['data']['options'][$field_value_option]['title'];
$output .= $separator . $field_value_option_title;

$separator = $atts['separator'];
}

return $output;
});

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

After that, you can include a "Fields and Text" block in place of the "Single Field" block in the template and use this new custom shortcode like this:


[checkboxes field='sectors' separator=', ']

#1910469

Hi Waqar, apologies I have no clue what this is now. So does this mean I cannot list the "Sectors" under each Companies profile. Just as I added the "Phone number" the "Address" the "Email" the "Website" and the "Contact persons name"?

#1910547

I apologize, if my last message caused some confusion.

I meant that you can list the "Sectors" under each Companies profile, but some extra steps will be needed.
(I've added those steps for you now)

1. I've added the code for the custom shortcode at WP Admin -> Toolset -> Settings -> Custom Code.

2. I've also added the shortcode "[checkboxes field='sectors' separator=', ']" in the "Template for Companies".
( screenshot: hidden link )

You'll see that the relevant sector titles are now showing on the single company pages.

#1910665

Thank you very much. I really appreciate your assistance. I think that will be all for now. I hope so 🙂

#1910679

Sorry one more thing. If I edit the "Sector list" will it update on the companies profile automatically? For example on the "Hydac" company that you showed in your screen shot. The one sector is "Engineering, industrial" now I might want to edit that because it now looks like two sectors where in fact it is one sector. So I might change those to read something like, Engineering-Industrial, Engineering-Ports, and so on.

#1910685

You're very welcome and glad that I was able to help 🙂

You can add, remove or rename the sector options and their titles and the code will keep showing them automatically.

Feel free to mark this ticket as resolved and start a new one, for each new question or concern.

#1910695

My issue is resolved now. Thank you! I just wish I knew how I get hold of someone like Waqar for the future. If there is simple way please could you let me know how to do this