We need to create some code snippets (i.e. the DIV of the main menu) to be used within custom templates so to have only one ource to be changed if the code within the snippet shall be modified.
For example if we add a class to the DIV, we need that class shall be applied wherever that snippet is recalled (even in multiple custom templates).
Is there something available to get that result?
I specify that we are using the traditional editor for the content templates since eww know that Toolset does not yet support the custom JS box in the block editor.
Thanks for any help on this.
Franco
Hello Franco and thank you for contacting the Toolset support.
I am not really sure to understand your use case. Do you want to have a reusable Javascript snippet then include it in some posts/pages or in the whole site?
Can you elaborate more on what you would like to have?
Hi Jamal,
what I need to have is the possibility to insert some snippets of HTML code, for example the DIV of the main menu:
<div class="menu">
</div>
In this case we need something like a shortcode or other element that refers to the source of that code, so if we need to change the class"menu" into "main-menu" we do not have to re-edit every single content template.
Is it something available in Toolset?
Franco
Of course, that is possible.
You can create an unassigned content template, insert your HTML/CSS/JS.
Then you can use that content template inside any Toolset View or Content Template.
You may also consider to use a third-party plugin such as:
- https://wordpress.org/plugins/shortcoder/
- https://wordpress.org/plugins/post-snippets/
I hope this helps. Let me know if you have any questions.
Great news, how is possible to insert an unassigned content template within another cotent template?
You can use a shortcode on the legacy views or a view block with Gutenberg.
The shortcode is "wpv-post-body"
[wpv-post-body view_template="my-content-template-slug"]
Check its documentation here https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-153372
My issue is resolved now. Thank you!