4

Should be a quick one for the EE add-on devs out there.

Most add-ons do support having:

$config['path_third_themes']    = $base_path . "/assets/third_themes/";
$config['url_third_themes']     = $base_url . "/assets/third_themes/";

in the config file.

I've noticed that Field Editor and Redactee don't.

I popped open those add-ons to replace instances of theme_folder_url with url_third_themes but they still don't want to load the appropriate styling.

Any ideas?

Thanks, Steven

3 Answers 3

4

Can you copy/paste a code snippet?

Basically, what you have to do is search for theme_folder_url and replace it with url_third_themes - plus you also have to remember to drop the third_party on the path.

so:

$this->EE->config->item('theme_folder_url').'third_party/field_editor/css/field_editor.css

becomes:

$this->EE->config->item('url_third_themes').'field_editor/css/field_editor.css

I have to do it on a lot of add-ons, which is mildly annoying as it should be sorted by now.

5
  • so in the instances where I've changed that and still the add-on images are missing, what would be the issue? Commented Jan 14, 2013 at 10:13
  • I'd need to see some code examples to be honest Steve. The change as above should work, but if it isn't it might be somewhere else the reference is being called. Commented Jan 14, 2013 at 10:22
  • here's mcp.field_editor.php d.pr/n/otCI and here's field_row.php d.pr/n/lRH7 for that particular add-on Commented Jan 14, 2013 at 10:30
  • so your mcp.field_editor.php still has lots of references to theme_folder_url - you need to replace it as follows: $this->EE->cp->add_to_head('<link rel="stylesheet" href="'.$this->EE->config->item('url_third_themes').'field_editor/css/field_editor.css" type="text/css" media="screen" />'); Commented Jan 14, 2013 at 10:42
  • as Sheldon Cooper would say "Bazinga" Commented Jan 14, 2013 at 11:01
2

According the Core.php EE library, the config needs to be:

$config['theme_folder_url']     = $base_url . "/assets/third_themes/";

But latest versions of EE add the new third_party themes var:

$config['url_third_themes']     = $base_url . "/assets/third_themes/";

But also keep in mind that EE will automatically append "third_party" to this. So for example the final URL will be "example.com/assets/third_themes/third_party/redactee/".

Changing folder structure for 100% compatibility

If you want to make things compatible for addons that do and dont support the new variable you can structure your assets folder to the following:

/assets/themes/third_party/redactee/
/assets/themes/third_party/field_editor/

And then set both the config vars to the following:

$config['theme_folder_url']     = $base_url . "/assets/themes/";
$config['url_third_themes']     = $base_url . "/assets/themes/third_party/";

This should ensure all addons work with the new third_party themes location, regardless of supporting the url_third_themes var.

Note: This solution will involve moving the EE CP theme folders into the assets folder as well, but thats the price you pay to ensure 100% compatibility without editing 3rd party addons.

2
  • is that at odds with ellislab.com/expressionengine/user-guide/general/… then? Commented Jan 14, 2013 at 10:16
  • Just checked and it seems they've added the config var you describe in the latest versions of EE. I was looking at 2.5.2. There is a conditional that uses 'url_third_themes' if set, but if not it falls back to 'theme_folder_url' as I describe above. Commented Jan 14, 2013 at 10:32
2

For Field Editor you can add this:

$this->theme_url = defined('URL_THIRD_THEMES') ? URL_THIRD_THEMES . '/field_editor/' : $this->EE->config->item('theme_folder_url') . 'third_party/field_editor/';

inside the public function __construct() method.

And then swap out the instances of:

$this->EE->config->item('theme_folder_url') and $this->EE->config->slash_item('theme_folder_url')

for

$this->theme_url

don't forget protected $theme_url; somewhere after the start of the class itself.

For example on line 238 of mcp.field_editor.php (v1.0.3) the following:

$this->EE->cp->add_to_head('<link rel="stylesheet" href="'.$this->EE->config->item('theme_folder_url').'third_party/field_editor/css/field_editor.css" type="text/css" media="screen" />');

would be changed to:

$this->EE->cp->add_to_head('<link rel="stylesheet" href="' . $this->theme_url . 'css/field_editor.css" type="text/css" media="screen" />');

Note: this is a bit rough and you'll have to work through each add-on accordingly though, probably something similar will need to happen for Redactee as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.