- Posts: 29
COMMUNITY FORUM
Inserting a shortcode into K2 layout code
- Jack Hughes
-
Topic Author
- Offline
- Junior Member
Less
More
8 years 9 months ago #156659
by Jack Hughes
Inserting a shortcode into K2 layout code was created by Jack Hughes
Greetings,
I have a system plugin installed that inserts a webform in the content using the code: {mauticform 2} the plugin runs some js that inserts the form into my content.
First off I really don't know what the accepted description for this type of { } thing. Wayback it was called Mambot and Wordpress calls it shortcode.
Anyway,
What code do I use to insert this code into a K2 layout override such as item.php?
My workaround right now is to create a module, add the snippet code to that module then in item.php I enter the following into php:
<?php
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_custom','signup-insert');
echo JModuleHelper::renderModule($module);
?>
Isn't there a better way to plugin into the K2 layout?
Thanks
Jack
I have a system plugin installed that inserts a webform in the content using the code: {mauticform 2} the plugin runs some js that inserts the form into my content.
First off I really don't know what the accepted description for this type of { } thing. Wayback it was called Mambot and Wordpress calls it shortcode.
Anyway,
What code do I use to insert this code into a K2 layout override such as item.php?
My workaround right now is to create a module, add the snippet code to that module then in item.php I enter the following into php:
<?php
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_custom','signup-insert');
echo JModuleHelper::renderModule($module);
?>
Isn't there a better way to plugin into the K2 layout?
Thanks
Jack
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 9 months ago #156664
by Krikor Boghossian
Replied by Krikor Boghossian on topic Inserting a shortcode into K2 layout code
Shortcode or snippet will suffice.
You can add this shortcode in the item's full text or you can use an extrafield which can be rendered directly on your overrides.
Here is an example:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L104-L109
And more info on overrides:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
You can add this shortcode in the item's full text or you can use an extrafield which can be rendered directly on your overrides.
Here is an example:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L104-L109
And more info on overrides:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Please Log in or Create an account to join the conversation.
- Jack Hughes
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 29
8 years 9 months ago #156701
by Jack Hughes
Replied by Jack Hughes on topic Inserting a shortcode into K2 layout code
Thanks for the reply.
So there is no way to directly insert a plugin shortcode or snippet directly into the code of item.php of a K2 layout override?
Thanks
So there is no way to directly insert a plugin shortcode or snippet directly into the code of item.php of a K2 layout override?
Thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 9 months ago #156710
by Krikor Boghossian
Replied by Krikor Boghossian on topic Inserting a shortcode into K2 layout code
You have multiple options.
A K2 plugin will be executed in all items, this will do the trick but you will have to develop it manually.
The module solution is also an option, which you have correctly developed.
The extrafield can be rendered directly in the item.php override but you would still need to enter the value upon item creation.
Finally you can ask the RS devs if there is a K2 plugin available.
Depending on the site's traffic and budget I'd go for the module for simpler sires or with the plugin if you site is larger.
A K2 plugin will be executed in all items, this will do the trick but you will have to develop it manually.
The module solution is also an option, which you have correctly developed.
The extrafield can be rendered directly in the item.php override but you would still need to enter the value upon item creation.
Finally you can ask the RS devs if there is a K2 plugin available.
Depending on the site's traffic and budget I'd go for the module for simpler sires or with the plugin if you site is larger.
Please Log in or Create an account to join the conversation.