How would i use $mybb->settings['bburl'] in a js file
Thumbs Down 
This user has been denied support. This user has been denied support.
i have a js file which has a link to /images/bk/ 

 i have used $mybb->settings['bburl'] but that doesn't workin js since it's a php variable


also  why is this isnt working

// Disallow direct access to this file for security reasons
	die("Direct initialization of this file is not allowed.");

$plugins->add_hook('NerdieTony Hourly BK Change Plugin', 'bkchange');

function bkchange_info()
	return array(
		"name"			=> "NerdieTony Hourly BK Change Plugin",
		"description"	=> "Changes background image every hour...",
		"website"		=> "",
		"author"		=> "NerdieTony",
		"authorsite"	=> "",
		"version"		=> "1.0",
		"guid" 			=> "",
		"codename"		=> "",
		"compatibility" => "18*"

function bkchange_install()


function bkchange_is_installed()

 global $db;
        return true;
    return false;

function bkchange_uninstall()


function bkchange_activate()

 global $db, $mybb;

$setting_group = array(
    'name' => 'bkchange',
    'title' => 'NerdieTony Hourly BK Change Plugin',
    'description' => 'Changes background image every hour...',
    'disporder' => 5, // The order your setting group will display
    'isdefault' => 0

$gid = $db->insert_query("settinggroups", $setting_group);

$setting_array = array(
    // A text setting
    'bkchange' => array(
        'title' => 'File Location',
        'description' => 'Where are the backgrounds located',
        'optionscode' => 'text',
        'value' => '/images/bk/', // Default
        'disporder' => 1

foreach($setting_array as $name => $setting)
    $setting['name'] = $name;
    $setting['gid'] = $gid;

    $db->insert_query('settings', $setting);

// Don't forget this!


function bkchange_deactivate()

 global $db; $db->delete_query('settings', "name IN ('bkchange')"); $db->delete_query('settinggroups', "name = 'mysettinggroup'"); // Don't forget this rebuild_settings();

function do_something()

global $bk;

$bk = '<script src="<?php $mybb->settings['bburl']?>//jscripts/bkchange"></script> ';

   require_once MYBB_ROOT."/inc/adminfunctions_templates.php";

    "#" . preg_quote('') . "#i",


This user has been denied support. This user has been denied support.
If you right click view page source anywhere in MyBB you might notice how some bunch of variables are exported to JavaScript... by adding it as JavaScript code to the webpage.

<script type="text/javascript">
 lang.unknown_error = "An unknown error has occurred.";

 lang.select2_match = "One result is available, press enter to select it.";
 lang.select2_matches = "{1} results are available, use up and down arrow keys to navigate.";
 lang.select2_nomatches = "No matches found";
 lang.select2_inputtooshort_single = "Please enter one or more character";
 lang.select2_inputtooshort_plural = "Please enter {1} or more characters";
 lang.select2_inputtoolong_single = "Please delete one character";
 lang.select2_inputtoolong_plural = "Please delete {1} characters";
 lang.select2_selectiontoobig_single = "You can only select one item";
 lang.select2_selectiontoobig_plural = "You can only select {1} items";
 lang.select2_loadmore = "Loading more results…";
 lang.select2_searching = "Searching…";

 var cookieDomain = "";
 var cookiePath = "/";
 var cookiePrefix = "";
 var deleteevent_confirm = "Are you sure you want to delete this event?";
 var removeattach_confirm = "Are you sure you want to remove the selected attachment from this post?";
 var loading_text = 'Loading. <br />Please Wait..';
 var saving_changes = 'Saving changes..';
 var use_xmlhttprequest = "1";
 var my_post_key = "45dd85d7i2p31s500h669hi49767t2t1";
 var rootpath = "";
 var imagepath = "";
   var yes_confirm = "Yes";
 var no_confirm = "No";
 var MyBBEditor = null;
 var spinner_image = "";
 var spinner = "<img src='" + spinner_image +"' alt='' />";
 var modal_zindex = 9999;
// -->
<!-- end: headerinclude -->
<script type="text/javascript">
 var quickdelete_confirm = "Are you sure you want to delete this post?";
 var quickrestore_confirm = "Are you sure you want to restore this post?";
 var allowEditReason = "1";
 lang.save_changes = "Save Changes";
 lang.cancel_edit = "Cancel Edit";
 lang.quick_edit_update_error = "There was an error editing your reply:";
 lang.quick_reply_post_error = "There was an error posting your reply:";
 lang.quick_delete_error = "There was an error deleting your reply:";
 lang.quick_delete_success = "The post was deleted successfully.";
 lang.quick_delete_thread_success = "The thread was deleted successfully.";
 lang.quick_restore_error = "There was an error restoring your reply:";
 lang.quick_restore_success = "The post was restored successfully.";
 lang.editreason = "Edit Reason";
// -->

There is no bburl but maybe rootpath is the same. If you need something else just do it the same way, generate javascript code that sets the variable you like.

As for your add hook, you should look at some example... you need a hook name, and function name that should be called, not a description or whatever it is you have in there...

From the looks of things you still have a long way to go - good luck.

Forum Jump:

Users browsing this thread: 1 Guest(s)