Support Forum
Hi Support,
I have integrated a calendar into the meta view.
I have added the required div id into the template section that will display the calendar view using js library.
I have added the required javascript code under the javascript tab.
Here you can see we are using static data array that we need to convert with event post type data array.
I have added a query post argument into the meta view and get all the event title there.
Please let me know how can we add the array variable in which I can store the required data, encode it in json format and pass it into the script section.
https://tinyurl.com/248h6jkk
https://tinyurl.com/26aev6p2
Please check the attached screenshot and suggest me on it.
Thank you.
Hi,
It is a basic question about creating an array and pushing elements to it by using Twig. Please refer to this article to know how to do that https://ourcodeworld.com/articles/read/622/how-to-push-an-item-to-an-array-in-twig-easily
Hi Support,
Thank you for sharing the above example,
I have created array (eventArray) and marge the data in it.
Please check the screenshot attached.
https://tinyurl.com/2bejdyjh
https://tinyurl.com/23vpyexk
Please let me know how can i display the array in meta view template tab and also how can I get this array variable into Javascript tab.
Thank you.
Hi Support,
Do you have any response for the above ?
Hi,
The view does not support using variables between tab CSS, and JS like that. In the case of using JS and PHP code, I recommend using PHP code to query posts and localize data via the WP function wp_localize_script()
then you can use the array in view JS content as well.
https://developer.wordpress.org/reference/functions/wp_localize_script/
Its seems like a custom solution to use the wp_localize_script() in the template.
Do you have any other way to fix the it within the meta template and javascript tab ?
Hi,
No, unfortunately. It is not possible to use a variable between tabs in View (CSS, JS). I will inform the development team to consider supporting this case in future updates.