Make changes to core function

We need to make some changes to the function elgg_format_element, which is in /vendor/elgg/elgg/engine/lib/output.php 

We'd appreciate any guidance how to write the plugin.

Thank you very much

 

  • The question is how you want to change it? What are you trying to change?

  • The purpose is to give the user some "Loading ... " indication when loading time of the HTML editor (TinyMCE in this case) is too long.

    We want to add a div with "Loading ... " indication just before the textarea, with class elgg-input-longtext, and position it with css. We remove this div with jquery when oninit of TinyMCE fires.

    All this will go to a plugin which extend extended_tinymce plugin. In this new plugin we also change some of the tools of TinyMCE and css of images.

    We have tested all this through direct changes to the elgg_format_element function and the extended_tinymce plugin. Now we want to consolidate all the changes in a new plugin.

    Thank you for your help

     

  • Why not simply extend (on priority < 500) the input/longtext view and output your desired div?

    http://learn.elgg.org/en/stable/guides/views.html#extending-views

  • Thank you Jeome,

    Since I'm quite an Elgg beginner, I'm not understand fully your suggestion. However, we need this div to be visible immediately when the page loads, before the long loading time of the jquery and TinyMCE.

    Maybe you give us a code example and we'll test it. 

    Thank you very much

  • in your start.php

    elgg_extend_view('input/longtext', 'myplugin/someview', 400);

    in views/default/myplugin/someview.php

    echo elgg_format_element('div', ['class' => 'some-class-for-jquery'], '');
    

    You can use you current jquery code to remove the div when loading is done

  • Is the Tinymce editor really so slow for you? If you have all caching options of Elgg enabled on the advanced settings page and created the cache symlink it should load really fast (maybe not the first time after flushing the cache but on all further requests). If it loads slow for you, the question is if you have some other plugin with some js code that slows down your site.

  • Thank you Jerome - works perfect!

    iionly - Usually it is very fast, even without the caching options. However, I'm working in a university network which sometimes is very slow.

    Anyway, I'm happy that we noticed this problem and have a solution. We are helping a charity organisation, (which support educational projects in 100+ countries) to build its own social media network. In some of the developing countries the internet is very slow.

    Thank you guys very much - your fast and professional responses prove to us that we have made right choice with Elgg.

  • Question

    Does removing several tools from TinyMCE speed up the download process?

    Thank you

  • The tinymce core script has a size of about 120 kByte compressed (if you have enabled compresing of JS files, otherwise it's about 350 kByte). There's no way to reduce this size. You could disable some functionality that is provided by tinymce plugins. But each of the plugins is only a kByte of size at maximum. And already on viewing the second page with a longtext input the tinymce files are taken from the browser cache.

  • Good to know - thank you iionly.

    Regarding the browser cache - I'm not sure browsers cache JS files from https sites. According to a test that I've made and reported earlier, only Opera caches, while Chrome, FF and IE not.