Skip Navigation

[Resolved] info creation model

This support ticket is created 4 years, 1 month 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.

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/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by federicoA 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1527755
Schermata 2020-02-26 alle 00.40.46.png

I have created a model and it works quite well.
I have two requests for information ... I hope I can explain myself well.

1. I can't delete the first part of default (I attach image)
hidden link

2. I have created a gallery field and would like to use a WPBakery Page Builder tool. This shortcode wants past images with this syntax: include = "5210.5213.5212.5211.5214.5209". How can I insert the data of the toolset field in the shortcode

thanks
federico

#1528203

Dear federico,

Q1) According to your screenshot, those should be:
- Post title
- Post featured image.

It depends on your theme file, Toolset content template works only in post content area, it seems you are using a child theme of "allston", you will find and locate theme files for "Post title" and "Post featured image", and customize as what you want.

In most cases, you can create a new theme file single-{post-type}.php in the child theme folder, and customize it. see WordPress document:
https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
single-{post-type}.php – If the post type is product, WordPress would look for single-product.php.

Q2) How do you setup the "gallery field", if it is a custom repeating image field:
https://toolset.com/documentation/user-guides/custom-content/repeating-fields/

Since Toolset repeating image field save image's URL in database, you will need to setup custom codes to turn the image URLs into attachment IDs, for example, there is a similar thread:
https://toolset.com/forums/topic/display-image-ids-for-repeating-image-field/

For your reference.

#1529625

almost solved everything like this:

in functions.php I added:

add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
    global $post, $wpdb;
      
    $images = get_post_meta($post->ID, 'wpcf-gallery', false);
    $ids = array();
    foreach ($images as $image) {
        $attachment_id = $wpdb->get_var($wpdb->prepare(
            "SELECT ID FROM $wpdb->posts WHERE guid = %s",
        $image
        ));
        $ids[] = $attachment_id;
    }  
 $out = do_shortcode('[gallery ids="' . implode(",", $ids) . '"]');
    return $out;
}

there is one thing I don't understand (probably because of me). if at the end of the function I insert the shortcode that interests me like this:
$out=do_shortcode('[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="' . implode(",", $ids) . '" el_class=".gallery-prod"]');

I don't see the gallery on the product page, (I added in view [repeating_images_gallery_func]).

if instead I insert the code in the view:
[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="5210,5213,5212,5211,5214,5209" el_class=".gallery-prod"]

the gallery works.

shouldn't it be the same?
thanks

#1529801

It is a custom codes problem, please provide a test site with the same problem, also point out the problem page URL and where I can edit your PHP codes, I need to test and debug it in a live website. Thanks

#1530261

Thanks for the details, I have done below modifications in your website:
1) Change the PHP codes as below:

add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
    global $post, $wpdb;
      
    $images = get_post_meta($post->ID, 'wpcf-gallery', false);
    $ids = array();
    foreach ($images as $image) {
        $attachment_id = $wpdb->get_var($wpdb->prepare(
            "SELECT ID FROM $wpdb->posts WHERE guid = %s",
        $image
        ));
        $ids[] = $attachment_id;
    }
	$res = implode(',', $ids);
	
    //$out=do_shortcode('[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582759842872-f01f8d3b-a78e-1" include="5214,5209" el_class=".gallery-prod"][vc_media_grid element_width="6" gap="35" grid_id="vc_gid:1582759860998-d8827e1a-8297-4" include="' . $str . '"]');    

    return $res;
}

So the shortcode [repeating-images-gallery] will output the attachment IDs

2) Edit the content template, use above custom shortcode as below:
[vc_masonry_media_grid element_width="6" gap="20" item="5219" initial_loading_animation="none" grid_id="vc_gid:1582708009572-463b9c86-a233-10" include="[repeating-images-gallery]" el_class=".gallery-prod"]

3) Dashborad-> Toolset-> Settings-> Contenuto del front-end
In section "Argomenti degli shortcode di terze parti", add the shortcode name: repeating-images-gallery
Please test it again, check if it is fixed, thanks

#1530325

there were changes that I had tried too but the shortcode is not loaded well:
hidden link

#1530335

Thanks for the details, I can see the problem you mentioned above

Please test the shortcode directly:
[repeating-images-gallery]

You should be able to see it does outputs the attachment IDs correctly:
hidden link

But the problem is shortcode [vc_masonry_media_grid] does not support using other shortcode as attribute "include", you might need to check it with author of shortcode [vc_masonry_media_grid], how to pass other shortcode values to that shortcode.

#1530409

I tried using the toolset plugin block for viewing photos in masonry
hidden link
but I can't find the way to view the images completely and only 2 images per row.

#1530825

I solved by redoing the whole single page
My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.