Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
726 views
in Plugins by

Why the following is impossible in my layer plugin?

<?php

class qa_html_theme_layer extends qa_html_theme
{

...

}

Class for layer must be declared as "class qa_html_theme_layer extends qa_html_theme_base"

I have a method html() redefined in the plugin, and I want to redefine the same method in my theme. The plugin would call qa_html_theme::html();

Q2A version: 1.5.1
by
In your code you've put "qa_html_theme" instead of "qa_html_theme_base".

1 Answer

0 votes
by
If you just follow the instructions in the error message, it should be fine. Q2A automatically renames the classes as necessary.
by
Fine? What do u mean? :) If I have a theme and a plugin with head(), what should happen? Or, if it's a couple of plugins?

class qa_html_theme extends qa_html_theme_base
{
    function head()
    {
        // head theme
    }
}
    
class qa_html_theme_layer extends qa_html_theme_base
{
    function head()
    {
        // head layer 1
    }
}

class qa_html_theme_layer extends qa_html_theme_base
{
    function head()
    {
        // head layer 2
    }
}
by
I can't get it... in the above example, how Q2A engine chooses one of the head()s to execute?

        // head theme
or
        // head layer 1
or
        // head layer 1
?

(I didn't even test it because I want to know WHY it works so)
by
If you don't use inheritance in your function definitions, it will use the last loaded layer. But the whole point of this system is to use inheritance if it makes sense to do so, i.e. call qa_html_theme_base::head(); in each function. Q2A will rename and bulid the inheritance chain as appropriate.
...