Welcome, Guest
Username Password: Remember me

Conditional loading of JS script of specific Component View
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Conditional loading of JS script of specific Component View

Conditional loading of JS script of specific Component View 9 years, 9 months ago #18336

  • jabber
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Hi, i'm new to Joomla Mobile, i found it last week and i think it's a powerful extension.
I think i've understood (almost) everything ... or so it seems

> I'm working on J3.x.
> My Mobile Joomla package version is 1.2.11
> I still am working on localhost PHP 5.3.10 & MySql 5.5.4.1
> I'm working on iPhone 3GS

Like so many other joomla extensions, my component has many Views and for each view i load different JS files, i load them into "display()" View function.

Now i've installed Mobile Joomla and it works fine! but not all my JS files ( loaded in specific View) work on iPhone (and other devices too).
How can i load JS View files for the specific device ? I can't understand how/where do i have to select specific JS (of the Views) file in relation to specific Mobile device. In few words, i would like to know of a conditional JS View Script loading in according to devide detected, i mean something like:

  • if joomla detects desktop pc then it must load this file: /views/MY_VIEW/js/js_desktop.js
  • if joomla detects iPhone then it must load following file: /views/MY_VIEW/js/js_iphone.js
Last Edit: 9 years, 9 months ago by jabber.

Re: Conditional loading of JS script of specific Component View 9 years, 9 months ago #18340

  • jabber
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Hi,
I'm going on in my personal understanding of Mobile Joomla extension.
I've tried to do a simple test, in my View file (view.html.php) i've dumped "$MobileJoomla_Device" variable (i get it by MobileJoomla::getDevice() function ).
I've noticed that it also works fine even here, var dump is:

 
Array (9)
(
| ['markup'] = String(6) "iphone"
| ['real_markup'] = String(6) "iphone"
| ['screenwidth'] = Integer(3) 320
| ['screenheight'] = Integer(3) 480
| ['imageformats'] => Array (3)
| (
| | ['0'] = String(3) "png"
| | ['1'] = String(3) "jpg"
| | ['2'] = String(3) "gif"
| )
| ['mimetype'] = NULL(0) NULL
| ['param'] => Array (0)
| (
| )
| ['amdd'] Object
| (
| | type = String(6) "mobile"
| | markup = String(6) "iphone"
| | screenWidth = Integer(3) 320
| | screenHeight = Integer(3) 480
| | jsSupport = Integer(1) 1
| | imageFormats => Array (3)
| | (
| | | ['0'] = String(3) "png"
| | | ['1'] = String(3) "jpg"
| | | ['2'] = String(3) "gif"
| | )
| )
| ['default_markup'] = String(6) "iphone"
)


Now i know the type of mobile that is performing current request, therefore i can perform this task (see in previous post):
  • if joomla detects desktop pc then it must load this file: /views/MY_VIEW/js/js_desktop.js
  • if joomla detects iPhone then it must load following file: /views/MY_VIEW/js/js_iphone.js

I'd like to know from Mobile Joomla expert/staff if this is the correct way or if I have to be careful because I could create a disaster.
Last Edit: 9 years, 9 months ago by jabber.

Re: Conditional loading of JS script of specific Component View 9 years, 9 months ago #18343

  • jabber
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Really no one can help ?
Only I did to myself this question?

Strange ...
  • Page:
  • 1
Time to create page: 0.13 seconds

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.