We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Base url in javascript | Forum

Abdul Muiz
Abdul Muiz Jul 27 '13
Can anyone tell me how to write base url of oxwall in javascript......??


Alexandr Makarov
Alexandr Makarov Jul 27 '13
you can pass this url as variable from php controller:


OW::getDocument()->addScriptDeclarationBeforeIncludes("var base_url = '" . OW::getRouter()->getBaseUrl() . "';");

ross Team
ross Jul 29 '13
Why do you need this URL? For what technical purposes?
Abdul Muiz
Abdul Muiz Aug 6 '13
i am making plugin for my site......
ross Team
ross Aug 6 '13
Topic was moved from General Questions.
Daisy Team
Daisy Aug 8 '13
Here is an example of the code you should use in your plugin init.php file if you need this variable to be global, or in a specific component:

function foo_js_declarations( $e )
{
    OW::getDocument()->addOnloadScript("window.BASE_URL=" . json_encode(OW_URL_HOME));
}
OW::getEventManager()->bind(OW_EventManager::ON_FINALIZE, 'foo_js_declarations');