e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Could you tell me how to correctly work with theme_shortcodes now? #4506

Closed Jimmi08 closed 2 years ago

Jimmi08 commented 3 years ago

I had to rewrite my themes because only init() worked, now it looks that only __construct() works with theme shortcodes. But it is possible that I got it wrong. So can you write me the correct way?

You can see at those issues that init() was recommended way, so I am struggling with this for some time. https://github.com/e107inc/e107/issues/4494 https://github.com/e107inc/e107/issues/4499

How to test this:

Try bootstrap5 theme. open theme_shortcodes.php file add this code:

    public function init()
    {
      define("JUST_TEST", 4);
      e107::getDebug()->log("in init of theme shortcodes: ".JUST_TEST );
    }

and

    function sc_header()
    {
        e107::getDebug()->log("in sc_header of theme shortcodes: ".JUST_TEST );

        return "<!-- Dynamic Header template -->\n";
    }

The only result is: Using HTML layout: home.html in sc_header of theme shortcodes: JUST_TEST

but if you add this code:

    public function __construct()
    {
      define("JUST_TEST", 4);
      e107::getDebug()->log("in construct of theme shortcodes: ".JUST_TEST );
    }
Using HTML layout: home.html 
in construct of theme shortcodes: 4 | theme_shortcodes->__construct()() | C:\xampp72\htdocs\e107\e107_handlers\shortcode_handler.php | 293
in sc_header of theme shortcodes: 4 | theme_shortcodes->sc_header()() | C:\xampp72\htdocs\e107\e107_handlers\shortcode_handler.php | 275
in sc_header of theme shortcodes: 4 | theme_shortcodes->sc_header()() | C:\xampp72\htdocs\e107\e107_handlers\shortcode_handler.php | 275
in construct of theme shortcodes: 4 | theme_shortcodes->__construct()() | C:\xampp72\htdocs\e107\e107_handlers\e107_class.php | 2931
in sc_header of theme shortcodes: 4

I need to know where to put something like this: $this->siteTheme = e107::getPref('sitetheme');

Is it possible that for new themes (theme.html) it should be in construct() but for PHP themes in init()? This is pretty important to know for sure. I don't know how it is called, but why is theme shortcodes class "created" 2x? you can see that construct is there 2x.

PHP 8, latest sync. no custom changes in the bootstrap5 theme.

Thanks

aducom commented 3 years ago

Just a kind remark as an old user of E107. I'm one of the users of the premium themes of Jimako. I recently could not upgrade E107, because of breaking the theme I used. It's fixed (due to excellent support from Jimako and Cameron) but a post like this brings me chills. I surely hope that the builders of this great cms (I'm using it since 0.5) will take into account that there are not so many theme and plugin builders out there. I surely hope that you stay in close contact with them if there are breaking changes. Some themes/plugins already are not available anymore (they are in the repository, but the links lead to nothing). If builders see their work go to pieces I fear that motivation might become an issue and then theming and creating plugins will become quite sparse. I would regret that very much.

Moc commented 3 years ago

Just noticing this: some of the the functionalities used in these themes were introduced very recently and have not been released yet.

This means that these functionalities are still not stable and may change over time until the stable release. In this case, it is the authors decision to use these functionalities, which includes the risk of having to change things over time as development progresses.

At the same time, core developers should document the functionalitities as much as possible (hence this issue asking for clarification) and surely when releasing the next stable version.

Until that time, the development version is simply not stable and thus it may not be wise to release themes based on a development version.

Having said that, of course the core developers will work with theme/plugin developers to make the best of e107 together! :)

Jimmi08 commented 2 years ago

The only way how to combine:

is to use {---FOOTER---} in theme.html and f.e. ParseTemplate can't be used here

        if (file_exists($footerpath)) {
            $text = file_get_contents($footerpath);
           // $text = e107::getParser()->parseTemplate($text);
        } else {
            $text = '';
        }

Any other way (custom shortcode for header) doesn't display menu areas in the Menu manager.