Convert PHP file for use in Smarty template
Jamroom Developers
There is already a module that posts to twitter, its called OneAll
Modules: OneAll
https://www.jamroom.net/the-jamroom-network/networkmarket/47/oneall-social
If you wanted to turn your existing php file into a jamroom module then you can do it that way too.
Yes, everything in jamroom is a module.
The most basic module has a directory, a changelog.txt an include.php and in your case, if you want it to control a URL then it needs an index.php
Example
* call your module xxPost and place it in /modules/xxPost/
/modules/xxPost/changelog.txt
/modules/xxPost/include.php
/modules/xxPost/index.php
/modules/xxPost/changelog.txt
Changelog for Post to Twitter module
Version 1.0.0
- Initial Release
/modules/xxPost/include.php
<?php
/**
* @copyright ..........................
* @author ........ .......... <someone [at] somewhere [dot] com>
*/
// make sure we are not being called directly
defined('APP_DIR') or exit();
/**
* meta
*/
function xxPost_meta(){
$_tmp = array(
'name' => 'Post to Twitter',
'url' => 'post',
'version' => '1.0.0',
'developer' => 'Sombody Somwhere, ©' . strftime('%Y'),
'description' => 'Somthing about your module here',
'category' => 'custom'
);
return $_tmp;
}
/**
* init
*/
function xxPost_init(){
return true;
}
That will get your module appearing in the ACP. If you cant see it run the INTEGRITY CHECK. Then go to the INFO tab of the module and check the checkbox to activate it.
Next make it do something
/modules/xxPost/index.php
<?php
/**
* @copyright ..........................
* @author ........ .......... <someone [at] somewhere [dot] com>
*/
// make sure we are not being called directly
defined('APP_DIR') or exit();
//------------------------------
// create
//------------------------------
function view_xxPost_message($_post, $_user, $_conf)
{
// the $_post array contains anything coming in on the URL and the _message part of this function is the url.
// this function will fire when you visit example.com/post/message
// So you can either have the url example.com/post/message/message=hello
// then $_post['message'] will equal "hello" or you can skip the name and just use the url example.com/post/message/hello
// and "hello" can be found on either $_post['_1'] or $_post['_2'] need to check.
// put the contents of your PHP file in this function and return whatever you want echoed to the screen
return 'all the processing has completed';
or to return to a different location:
jrCore_location("{$_conf['jrCore_base_url']}/somewhere/you/want/to/redirect/to");
}
Docs: "Freelancers Read this"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/3513/freelance-developers-read-this
updated by @michael: 05/17/18 02:24:21AM