Custom Fields within Page Layouts

I have a custom field "image_selector" which works fine in standard modules. It uses an advanced module with its own CSS and JS in Fuel v1.51.

If I try to use it in a Page layout (MY_fuel_layouts.php), when triggered, it gets all the paths to my advanced module wrong and therefore fails.

For example:
http://localhost/parishhall/fuel/pages/edit/skins/kama/host.css
should point to:
http://localhost/parishhall/fuel/modules/myselector/assets/js/skins/kama/host.css

And an XHR call to GET:
http://localhost/parishhall/fuel/pages/edit/core/connector/php/connector.php?command=Init
should point to:
http://localhost/parishhall/fuel/modules/myselector/assets/js/core/connector/php/connector.php?command=Init

Seems like the built-in Pages module is doing something different to the module code?

Comments

  • What does your configuration look like for the custom field?

  • $fields['image_selector'] = array(
       'class'     => 'MY_custom_fields',  //library file
       'function'  => 'image_selector',
       'css'       => '',
       'js'        => array(),
       'represents' => array('name' => 'image')
    );
    

    It points to an Advanced Module that I use to replace the Assets feature in Fuel (CK_Finder). The function in the my_custom_fields library adds the necessary JS to pop up the tool.

    The field and CKFinder works 100% everywhere else in Fuel.

  • It looks like the paths are relative. When you view source, what do you see for the paths? Is there a reason you didn't use the css and js properties in the image_selector array? In your case, you should be able to do something like the following:

    $fields['image_selector'] = array(
       'class'     => 'MY_custom_fields',  //library file
       'function'  => 'image_selector',
       'css'       => array(MY_ADVANCED_MODULE_FOLDER => array('host.css')),
       'js'        => array(MY_ADVANCED_MODULE_FOLDER => array('my_js')),
       'represents' => array('name' => 'image')
    );
    
  • The CSS is loaded automatically by the main CK_Finder tool.
    The library function is rendering the JS since there's PHP involved in setting up the script to work. eg. flagging the CK_Finder tool use as authorised by Fuel permissions and making the JS unique to the field in question (eg. CK_Finder can be used for images or PDFs, it need to be told which and where in the assets directory tree to start from).

    From the layouts functionality, the internal paths to the CSS and the path to the main launcher has a root of
    http://localhost/parishhall/fuel/pages/edit
    This doesn't happen in simple modules.
    I suspect that if we can sort out the path to the main CK_Finder launcher, the CCS paths it uses will fall in line...
    The main parent script seems to load correctly, it just can't find the launcher (the XHR GET call in my OP)

  • Did either of you manage to figure this out?

  • I did but it's been a while.

    I think in my custom field library, I added

    var mybasePath = realpath(jqx_config.assetsPath+\'../fuel/modules/ckf_assets/assets/js/\');
    var finder = new CKFinder();
    finder.basePath = mybasePath;
    

    ...to the js I add to the form. Basically, hard-coding the path I needed for ck_finder to pick up.

Sign In or Register to comment.