Please note that the forum isn't realy used anymore.

If you have questions, want support or just simply want to talk to us you can find us on slack.

 

Run this simple PHP code in widget on page

Hello, I just need to run this simple PHP code in widget on a page.

<?php ?>

Is there anybody who can make for me this widget? Thanks

Your code isnt showing, try to put in the pre tags. It would also be usefull to know which module this code/widget has to work with.

I just need to show the content which is loaded by this: https://github.com/fender/bracketcloud-php

so php code will be: <?php

include('bracketcloud.lib.php');

/** * Replace APIKEY with your BracketCloud API Key. */ $request = new BracketCloudAPIRequest(APIKEY);

// ... do something with $request!

?>

Try the module maker, use a name like BracketCloud for the module name but don't add input fields to the backend etc. Then generate the code. Remove everything that seems unnecessary from the installer.php, remove the php files inside Actions. Finally, you will have only a widget inside your installer that gets installed. Create a php file inside the widgets folder and also create a template.

You can create a settings.php file inside Actions folder (and add the settings page in your installer script) and create a template, to make a settings page for your BracketCloud Module where you can type your API key and save it.

In your frontend widget, you can retrieve the api key by doing something like this: FrontendModel::getModuleSetting('BracketCloud', 'api_key'). Then get the request. Do something with the request, and then parse the array into your template. And you have your first module!

It's a very simple module, not that hard to make, but it can be tricky when you first start working with forkcms. Download a few small modules and watch the files, how they're made. Or check out the modules that come with forkcms.

Thank you for your reply! Unfortunately I am really newbie in Fork CMS. I dont need any settings for this module.

It would be easier for me to make a new page with php output that mess with this... it could take a couple hours for me :(

Is there anybody who can modify it for me? I can add API manually into php file, setting is not necesary

Thank you

Unfortunately, you cannot add php to a page I think. If I have some spare time tomorrow, I'll take a look and generate a basic module with only a widget, where you can add php code.

It is not neccesary - I have found another way how to do it.

Anyway thank you! Have a nice day

Comment

The forum is deprecated in favor of our Slack channel, which provides real-time support for your issues.

Join us on Slack here: https://fork-cms.herokuapp.com/