Skip to Content Skip to Menu

executing content plugins in tab.php

  • carin
  • carin
  • OFFLINE
  • Posts: 417
  • Thanks: 18
  • Karma: 0
7 years 5 months ago #294208 by carin
I made a template for the user account page: components\com_comprofiler\plugin\user\plug_cbarticles\templates\kwg\tab.php. I would need to execute content plugins on that file before it gets rendered in the front end. Particularly the Hikashop plugin code {product 6|name|description|pricedis3} needs to get handled. How can I trigger plugins in that template file?

CB 2.0

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48449
  • Thanks: 8280
  • Karma: 1443
7 years 5 months ago #294215 by krileon
Replied by krileon on topic executing content plugins in tab.php
Send whatever string you want processed by content plugins through the below API function.

Code:
Application::Cms()->prepareHtmlContentPlugins( STRING_HERE, CONTEXT_HERE, USER_ID_HERE )

Example as follows.

Code:
Application::Cms()->prepareHtmlContentPlugins( 'Test {product 6|name|description|pricedis3}', 'cbarticles', $user->get( 'id', 0, GetterInterface::INT ) )

You may need to add a user statement at the top of the page to CBs Application class if not already there. Recommend loading your Joomla install into phpstorm with autocomplete otherwise using namespaced classes is going to be a pain.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • carin
  • carin
  • OFFLINE
  • Posts: 417
  • Thanks: 18
  • Karma: 0
7 years 5 months ago - 7 years 5 months ago #294223 by carin
Replied by carin on topic executing content plugins in tab.php
Thanks. I have no idea how to use that code. Who or what is "phpstorm"? Why would I use "namespaced classes", how would I use that, what for would I use that? Is there some docs I could read?

When I place that code in my file I get: Class 'Application' not found

CB 2.0
Last edit: 7 years 5 months ago by carin.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48449
  • Thanks: 8280
  • Karma: 1443
7 years 5 months ago #294241 by krileon
Replied by krileon on topic executing content plugins in tab.php
PhpStorm is an IDE. I suggest hiring a contract web developer with PHP experience to make the change for you if those concepts are not understood. Alternatively you can start learning PHP using some of the resources below.

General:
www.w3schools.com/php/default.asp

Namespaces:
php.net/manual/en/language.namespaces.basics.php

Please understand we are not here to teach coding languages and can not help you utilize API if you do not understand the language powering it.

When I place that code in my file I get: Class 'Application' not found

That's because the use statement for the namespaced class isn't specified at the top of the page. You can use the API without specifying a use statement with the below.

Code:
\CBLib\Application\Application::Cms()->prepareHtmlContentPlugins( STRING_HERE, CONTEXT_HERE, USER_ID_HERE )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: carin

Please Log in or Create an account to join the conversation.

  • carin
  • carin
  • OFFLINE
  • Posts: 417
  • Thanks: 18
  • Karma: 0
7 years 4 months ago #294540 by carin
Replied by carin on topic executing content plugins in tab.php
Thanks, that got me going. No I do not expect a PHP training :) I was just surprised how complex it got for a supposedly small task.

CB 2.0

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48449
  • Thanks: 8280
  • Karma: 1443
7 years 4 months ago #294550 by krileon
Replied by krileon on topic executing content plugins in tab.php
Using an IDE will help with that as it'll automatically add the use statements for you and provides auto complete. Using API is only complicated when you're trying to do so without an IDE. I personally use phpstorm and my entire Joomla install is a project within it so I can auto complete Joomla, CB, and any other installed extensions API. It's a commercial IDE though. For a free IDE I recommend Netbeans, but I haven't used it in years so not sure how well it has progressed.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum