How do I add a check box in a module ?

izhmel
@izhmel
6 years ago
1,319 posts
How do I add a check box in a module ?so I can just check the box or just enter i.e. the quota id . quota id 1, , limit="500, and so on instead of writing codes {jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = 2" order_by="_item_id random"}

want to be able to just check the box or just enter the quota id defined in the example
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/788/jrcore-media-player

I created this module in the link below and want to add check boxes in the module

http://www.dubmusic.com/radio/dubmusicradio


--
The Scientist
dubmusic.com
Thanks for any assistance.

updated by @izhmel: 10/09/18 08:06:03PM
michael
@michael
6 years ago
7,692 posts
izhmel:...How do I add a check box in a module ?....
Depends on where you want to add it. If you mean to a Form, you can use the Form Designer

Docs: "Using the Form Designer"
https://www.jamroom.net/the-jamroom-network/documentation/getting-started/1275/using-the-form-designer

Video Learning: "Admin Handbook: The Form Designer"
https://www.jamroom.net/video-training/85/the-admin-handbook-the-form-designer
izhmel
@izhmel
6 years ago
1,319 posts
I created a module and edited " item_index.tpl" and would like to add " a box so I can just add the following input i.e. limit ="500 , quota_id = 2 and so on instead of writing the codes in "item_index.tpl" to create a radio station shown in the link
http://www.dubmusic.com/radio/dubmusicradio


--
The Scientist
dubmusic.com
Thanks for any assistance.
paul
@paul
6 years ago
4,325 posts
Sorry, but I'm not understanding what you want to do.
You say you've created a module? What does that module do?
You want to add a checkbox to the module such that if checked limit and quota_id are automatically added to the smarty call to create a station?
Please explain more.
Thanks


--
Paul Asher - JR Developer and System Import Specialist
izhmel
@izhmel
6 years ago
1,319 posts
I created a module and edited"item_index.tpl" and added "
{jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = 1" autoplay="true" order_by="_item_id random" limit="500" }

{jrShareThis module="jrAudio" item_id=$item._item_id}" ..

I want to have check boxes so I can just check the box or enter the value instead of writing codes ... i.e. quota ID 1, auto play yes , limit 500, this function will be only assessed by the admin, ..

Thanks

the module is here
http://www.dubmusic.com/radio/dubmusicradio


--
The Scientist
dubmusic.com
Thanks for any assistance.

updated by @izhmel: 07/07/18 11:50:01AM
paul
@paul
6 years ago
4,325 posts
OK - So your module is creating (player) items?
In that case, add the fields to the module create form and then use the entered parameters in the template jrCore_media_player call. Eg. your create form fields might be -

mymodule_quotas
mymodule_autoplay
mymodule_limit

so then in the template -

{jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = $item.mymodule_quotas" autoplay=$item.mymodule_autoplay order_by="_item_id random" limit=$item.mymodule_limit }

hth


--
Paul Asher - JR Developer and System Import Specialist
izhmel
@izhmel
6 years ago
1,319 posts
module is creating (player) Yes
It did not work , the check or input box did not show up in the admin so I can enter the values Eg.
quota ID 1


--
The Scientist
dubmusic.com
Thanks for any assistance.
paul
@paul
6 years ago
4,325 posts
You'll need to post your module index.php create and create_save functions in order for us to advise further.


--
Paul Asher - JR Developer and System Import Specialist
izhmel
@izhmel
6 years ago
1,319 posts
Do you mean post here index.php here ?


--
The Scientist
dubmusic.com
Thanks for any assistance.
izhmel
@izhmel
6 years ago
1,319 posts
<?php /**
* Jamroom 5 radio module
*
* copyright 2003 - 2016
* by The Jamroom Network
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. Please see the included "license.html" file.
*
* This module may include works that are not developed by
* The Jamroom Network
* and are used under license - any licenses are included and
* can be found in the "contrib" directory within this module.
*
* Jamroom may use modules and skins that are licensed by third party
* developers, and licensed under a different license - please
* reference the individual module or skin license that is included
* with your installation.
*
* This software is provided "as is" and any express or implied
* warranties, including, but not limited to, the implied warranties
* of merchantability and fitness for a particular purpose are
* disclaimed. In no event shall the Jamroom Network be liable for
* any direct, indirect, incidental, special, exemplary or
* consequential damages (including but not limited to, procurement
* of substitute goods or services; loss of use, data or profits;
* or business interruption) however caused and on any theory of
* liability, whether in contract, strict liability, or tort
* (including negligence or otherwise) arising from the use of this
* software, even if advised of the possibility of such damage.
* Some jurisdictions may not allow disclaimers of implied warranties
* and certain statements in the above disclaimer may not apply to
* you as regards implied warranties; the other terms and conditions
* remain enforceable notwithstanding. In some jurisdictions it is
* not permitted to limit liability and therefore such limitations
* may not apply to you.
*
* @copyright 2012 Talldude Networks, LLC.
*/

// make sure we are not being called directly
defined('APP_DIR') or exit();

//------------------------------
// create
//------------------------------
function view_xxRadio_create($_post, $_user, $_conf)
{
// Must be logged in to create a new radio
jrUser_session_require_login();
jrUser_check_quota_access('xxRadio');
jrProfile_check_disk_usage();

// Get language strings
$_lang = jrUser_load_lang_strings();

// Start our create form
$_sr = array(
"_profile_id = {$_user['user_active_profile_id']}",
);
$tmp = jrCore_page_banner_item_jumper('xxRadio', 'radio_title', $_sr, 'create', 'update');
jrCore_page_banner($_lang['xxRadio'][2], $tmp);

// Form init
$_tmp = array(
'submit_value' => 2,
'cancel' => jrCore_is_profile_referrer()
);
jrCore_form_create($_tmp);

// radio Title
$_tmp = array(
'name' => 'radio_title',
'label' => 3,
'help' => 4,
'type' => 'text',
'validate' => 'printable',
'required' => true,
'onkeypress' => "if (event && event.keyCode == 13) return false;"
);
jrCore_form_field_create($_tmp);

// Display page with form in it
jrCore_page_display();
}

//------------------------------
// create_save
//------------------------------
function view_xxRadio_create_save($_post, $_user, $_conf)
{
// Must be logged in
jrUser_session_require_login();
jrCore_form_validate($_post);
jrUser_check_quota_access('xxRadio');

// Get our posted data - the jrCore_form_get_save_data function will
// return just those fields that were presented in the form.
$_rt = jrCore_form_get_save_data('xxRadio', 'create', $_post);

// Add in our SEO URL names
$_rt['radio_title_url'] = jrCore_url_string($_rt['radio_title']);

// $xid will be the INSERT_ID (_item_id) of the created item
$xid = jrCore_db_create_item('xxRadio', $_rt);
if (!$xid) {
jrCore_set_form_notice('error', 5);
jrCore_form_result();
}

// Save any uploaded media files added in by our
jrCore_save_all_media_files('xxRadio', 'create', $_user['user_active_profile_id'], $xid);

// Add to Actions...
jrCore_run_module_function('jrAction_save', 'create', 'xxRadio', $xid);

jrCore_form_delete_session();
jrProfile_reset_cache();

// redirect to the actual radio page, not the update page.
jrCore_form_result("{$_conf['jrCore_base_url']}/{$_user['profile_url']}/{$_post['module_url']}/{$xid}/{$_rt['radio_title_url']}");
}

//------------------------------
// update
//------------------------------
function view_xxRadio_update($_post, $_user, $_conf)
{
// Must be logged in
jrUser_session_require_login();
jrUser_check_quota_access('xxRadio');

// We should get an id on the URL
if (!isset($_post['id']) || !jrCore_checktype($_post['id'], 'number_nz')) {
jrCore_notice_page('error', 6);
}
$_rt = jrCore_db_get_item('xxRadio', $_post['id']);
if (!$_rt) {
jrCore_notice_page('error', 7);
}
// Make sure the calling user has permission to edit this item
if (!jrUser_can_edit_item($_rt)) {
jrUser_not_authorized();
}

// Start output
$_sr = array(
"_profile_id = {$_user['user_active_profile_id']}",
);
$tmp = jrCore_page_banner_item_jumper('xxRadio', 'radio_title', $_sr, 'create', 'update');
jrCore_page_banner(8, $tmp);

// Form init
$_tmp = array(
'submit_value' => 9,
'cancel' => jrCore_is_profile_referrer(),
'values' => $_rt
);
jrCore_form_create($_tmp);

// id
$_tmp = array(
'name' => 'id',
'type' => 'hidden',
'value' => $_post['id'],
'validate' => 'number_nz'
);
jrCore_form_field_create($_tmp);

// radio Title
$_tmp = array(
'name' => 'radio_title',
'label' => 3,
'help' => 4,
'type' => 'text',
'validate' => 'printable',
'required' => true
);
jrCore_form_field_create($_tmp);

// Display page with form in it
jrCore_page_display();
}

//------------------------------
// update_save
//------------------------------
function view_xxRadio_update_save($_post, $_user, $_conf)
{
// Must be logged in
jrUser_session_require_login();

// Validate all incoming posted data
jrCore_form_validate($_post);
jrUser_check_quota_access('xxRadio');

// Make sure we get a good _item_id
if (!isset($_post['id']) || !jrCore_checktype($_post['id'], 'number_nz')) {
jrCore_notice_page('error', 6);
jrCore_form_result('referrer');
}

// Get data
$_rt = jrCore_db_get_item('xxRadio', $_post['id']);
if (!isset($_rt) || !is_array($_rt)) {
// Item does not exist....
jrCore_notice_page('error', 7);
jrCore_form_result('referrer');
}

// Make sure the calling user has permission to edit this item
if (!jrUser_can_edit_item($_rt)) {
jrUser_not_authorized();
}

// Get our posted data - the jrCore_form_get_save_data function will
// return just those fields that were presented in the form.
$_sv = jrCore_form_get_save_data('xxRadio', 'update', $_post);

// Add in our SEO URL names
$_sv['radio_title_url'] = jrCore_url_string($_sv['radio_title']);

// Save all updated fields to the Data Store
jrCore_db_update_item('xxRadio', $_post['id'], $_sv);

// Save any uploaded media file
jrCore_save_all_media_files('xxRadio', 'update', $_user['user_active_profile_id'], $_post['id']);

// Add to Actions...
jrCore_run_module_function('jrAction_save', 'update', 'xxRadio', $_post['id']);

jrCore_form_delete_session();
jrProfile_reset_cache();
jrCore_form_result("{$_conf['jrCore_base_url']}/{$_user['profile_url']}/{$_post['module_url']}/{$_post['id']}/{$_sv['radio_title_url']}");
}

//------------------------------
// delete
//------------------------------
function view_xxRadio_delete($_post, $_user, $_conf)
{
// Must be logged in
jrUser_session_require_login();
jrUser_check_quota_access('xxRadio');

// Make sure we get a good id
if (!isset($_post['id']) || !jrCore_checktype($_post['id'], 'number_nz')) {
jrCore_notice_page('error', 6);
jrCore_form_result('referrer');
}
$_rt = jrCore_db_get_item('xxRadio', $_post['id']);

// Make sure the calling user has permission to delete this item
if (!jrUser_can_edit_item($_rt)) {
jrUser_not_authorized();
}
// Delete item and any associated files
jrCore_db_delete_item('xxRadio', $_post['id']);
jrProfile_reset_cache();
jrCore_form_result('delete_referrer');
}


--
The Scientist
dubmusic.com
Thanks for any assistance.
michael
@michael
6 years ago
7,692 posts
In your code you have this:
// radio Title
$_tmp = array(
'name' => 'radio_title',
'label' => 3,
'help' => 4,
'type' => 'text',
'validate' => 'printable',
'required' => true,
'onkeypress' => "if (event && event.keyCode == 13) return false;"
);
jrCore_form_field_create($_tmp);

That is a form field for a 'text' field, to add a checkbox, just use the checkbox type

    $_tmp = array(
        'name'     => 'radio_checkbox',
        'default'  => 'off',
        'type'     => 'checkbox',
        'validate' => 'onoff',
        'required' => 'off',
        'label'    => "The Checkbox",
        'help'     => "You can add your explanation of what its for here"
    );
    jrCore_form_field_create($_tmp);
izhmel
@izhmel
6 years ago
1,319 posts
This is what I have in"item_index.tpl" I am not sure what to do with all this code the way it is explained, can you hive a more detailed instruction ? I just want to be able to inter the data EG. "limit="500",profile_quota_id = 2 .......
http://www.dubmusic.com/radio/dubmusicradio
{jrCore_module_url module="xxDUBMUSICRADIO" assign="murl"}


{jrShareThis module="jrAudio" item_id=$item._item_id}


{jrCore_item_index_buttons module="xxDUBMUSICRADIO" profile_id=$_profile_id}

{jrCore_lang module="xxDUBMUSICRADIO" id="10" default="DUBMUSIC RADIO"}

{$profile_name} ยป {jrCore_lang module="xxDUBMUSICRADIO" id="10" default="DUBMUSIC RADIO"}





{jrCore_list module="xxDUBMUSICRADIO" profile_id=$_profile_id order_by="_created desc" pagebreak="8" page=$_post.p pager=true}

{jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = 1" autoplay="true" order_by="_item_id random" limit="500" }




{jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = $item.dubmusicradio_quotas" autoplay=$item.dubmusicradio_autoplay order_by="_item_id random" limit=$item.dubmusicradio_limit }



{jrShareThis module="jrAudio" item_id=$item._item_id}





--
The Scientist
dubmusic.com
Thanks for any assistance.
paul
@paul
6 years ago
4,325 posts
Quote: This is what I have in"item_index.tpl" I am not sure what to do with all this code the way it is explained, can you hive a more detailed instruction ? I just want to be able to inter the data EG. "limit="500",profile_quota_id = 2 .......
Not too sure what you mean by this, but Michael's code above needs to go into your module's view_xxRadio_create and view_xxRadio_update functions as described. Then, in your templates you'll get the 'radio_checkbox' value for the created item, so that can be tested -
{if $item.radio_checkbox == 'on'}
    {jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" search="profile_quota_id = 1" autoplay="true" order_by="_item_id random" limit="500" }
{else}
    // Do something else ??
{/if}

Also, I'd suggest the its the module's item_list.tpl or item_detail.tpl templates that you need to do this in as the radio items' data will not be available to templates until after the {jrCore_list module="xxRadio" . . . } call that I would expect to be in the item_index.tpl template.

hth


--
Paul Asher - JR Developer and System Import Specialist
izhmel
@izhmel
6 years ago
1,319 posts
what I want is when I 'click create radio' from the module I created , there is a form field box for the limit wish is 500 for the limit , a nest form field box where I enter the quota ID =1 , auto play , check boxes for yes or no ... I want to be able to do this without have to edit "item_index.tpl" This feature must be only available to admin

http://www.dubmusic.com/youngdaze/dubmusicradio

Please give a detail instruction where to put the code

Thanks in advance


--
The Scientist
dubmusic.com
Thanks for any assistance.

updated by @izhmel: 07/10/18 07:36:39AM
michael
@michael
6 years ago
7,692 posts
What you're asking for is too broad. You're asking for the someone to build the module you want for you, then to write detailed instructions that you can copy so that you can have the module.

Docs: "Sponsor a module"
https://www.jamroom.net/the-jamroom-network/documentation/jamroomnet/4931/sponsor-a-module

Tags