How do i add a js to head using components

Moneya Posted in Component Development 9 years ago

hi
please how do i add a js to head section of ossn instead of editing the theme head section..
how do i make this using a components

Replies
Indonesian Arsalan Shah Replied 9 years ago
  function new_site_js(){
     echo ossn_html_js(array('src' => 'http://site.com/jquery/files/jquery0.js'));
     echo ossn_html_js(array('src' => 'http://site.com/jquery/files/jquery1.js'));
     echo ossn_html_js(array('src' => 'http://site.com/jquery/files/jquery2.js'));
  }
ng Moneya Replied 9 years ago

do i need to repeat the step?

ng Moneya Replied 9 years ago

what about adding multiple url?

ng Moneya Replied 9 years ago

cool
thank;s

Indonesian Arsalan Shah Replied 9 years ago
  ossn_extend_view('ossn/site/head', 'new_site_js');
  function new_site_js(){
     echo ossn_html_js(array('src' => 'http://site.com/jquery/files/jquery.js'));
  }
ng Moneya Replied 9 years ago

i meant calling a url to extend the head
like for example
http://jquery.org/jquery-ui-1.0.1.js
not a hosted file on an external server

ng Moneya Replied 9 years ago

i meant calling a url

Indonesian Arsalan Shah Replied 9 years ago

See Our hello world component:

https://github.com/opensource-socialnetwork/HelloWorld/blob/master/ossn_com.php#L34-L47

I think you need to change "css" to "js" in the code (see link above)