Switch pmx grundsystem Jquery version [1.12.3]

Begonnen von shorty, 13 Mai 2015, 15:49:22

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 1 Gast betrachten dieses Thema.

shorty

 Hello @ all PragmaMx community.
I enjoy to use the best cms of the world ! So thanks to all develloppers and Team.
For increase user experience, i need to use scripts with different javascript version on different parts of the website. for it i need to create  something like :


    if ( mxModuleActive('Feedback') && (MX_MODULE == 'Feedback') )
   {
         pmxHeader::add_script( 'folders/file.js');
    }   
   elseif ( mxModuleActive('blank_Home') && (MX_MODULE == 'blank_Home') )
    {
         pmxHeader::add_script( 'folders/file.js');
    }   
  ...



But i really don't know where in pragmamx files put this kind of code.
The system alrways take jquery.min.js in pmx headers and i wan't it ctake another file by default or not do it. Find a way to PragmaMx not call jquery by default (disable javascript) and only call it by settings.php can be a way do to it maybe.

Thanks for your support
Best regards @ all community

Webfan

Hello shorty,
take a look at the class  pmxHeader ( includes/classes/Header.php )
Watch the methods
get_jquery()
get_script_code()
add_script_code($code)
add_script($src, $if_for_ie = '')
add_jquery()

and the property
    private static $__jquery = array(/* jQuery Details */
        'required' => false,
        'loaded' => false,
        'main' => 'jquery.js',
        'path' => 'includes/javascript/jquery/',
        'files' => array(),
        'ui_required' => false,
        'ui_loaded' => false,
        'ui_theme' => 'base',
        'ui_theme_path' => 'layout/jquery/ui/',
        );


I suggest to add a method simillar to the following function
<?php

 
public function set_jquery($name$value null){
     if(
null === $value && is_array($name)){
         
self::$__jquery $name;
     }elseif(isset(
self::$__jquery[$name])){
         
$__jquery[$name] = $value;
      }
     return 
self
  }


Now you could change just the jquery path anywhere (e.g. in the Hooks):


<?php

    
if ( mxModuleActive('Feedback') && (MX_MODULE == 'Feedback') ) 
   {
         
pmxHeader::set_jquery'path',  'includes/javascript/jquery/modules/Feedback/');
    }   
   elseif ( 
mxModuleActive('blank_Home') && (MX_MODULE == 'blank_Home') ) 
    {
         
pmxHeader::set_jquery'path',  'includes/javascript/jquery/modules/blank_Home/');
    }   


@Team:
I also suggest to change private methods to protected to allow inheritance.
Further, the filenames does not support the modern PSR Autoloading specifications:
inlcudes/classes/pragmamx/wasweissich/pmxHeader.php
!?
:bye:

Webfan

There is an error in the code of the last post:
Search:
public function set_jquery($name, $value = null)
replace with
public static function set_jquery($name, $value = null)

shorty

Thanks for your Support Webfan  :)

re, sorry for late response
I try to do it but without success
i try to put this code at line 513 (file attached) inside header.php


public function set_jquery($name, $value = null){
     if(null === $value && is_array($name)){
         self::$__jquery = $name;
     }elseif(isset(self::$__jquery[$name])){
         $__jquery[$name] = $value;
      }
     return self;
  }

and to put this one at the end of my settings file
    if ( mxModuleActive('Feedback') && (MX_MODULE == 'Feedback') )
   {
         pmxHeader::set_jquery( 'path',  'includes/javascript/jquery/modules/Feedback/');
    }   
   elseif ( mxModuleActive('blank_Home') && (MX_MODULE == 'blank_Home') )
    {
         pmxHeader::set_jquery( 'path',  'includes/javascript/jquery/modules/blank_Home/');
    }   


Thanks for your support
best regards

Webfan

Hello shorty,
please note my last post:
ZitatThere is an error in the code of the last post:
Search:
Code:

public function set_jquery($name, $value = null)

replace with
Code:

public static function set_jquery($name, $value = null)

So it should look like:
public static function set_jquery($name, $value = null){
     if(null === $value && is_array($name)){
         self::$__jquery = $name;
     }elseif(isset(self::$__jquery[$name])){
         $__jquery[$name] = $value;
      }
     return self;
  }


With this method you can change e.g. the jquery path or the jquery file:

pmxHeader::set_jquery( 'path',  'includes/javascript/jquery/modules/Feedback/');


pmxHeader::set_jquery( 'main',  'jquery-v123.js');

regards
Till

Webfan

Hello shorty,
if still have any issues, please let me know.

It is important to set the jquery settings by this function BEFORE calling header.php
Maybe a good place to set it could be a modul hook.

I did not test the code, so please specify the error if any.
Maybe the team has a more convenient solution?

regards,
Till

Smithson

doch komplexer ist, als das Frontend, heben wir das derzeit noch