Before you ask please READ THIS

Overriding functions

edited August 2012 in Spaceship Posts: 25
I'm trying to override a function or two (mainly the post_info) and I'm trying to figure out how to do it exactly. I've looked up some examples, but it looks like you included some code to help out. So do I still have to remove the function in my functions.php and then re-state it? or can I just state the function and it will override? I saw some discussion of this on another theme's discussions, but I wasn't totally following.
functions.png
346 x 127 - 17K

Comments

  • AirAir
    Posts: 10,970

    I'm holding with answer for this one cause I'm not sure how to overwrite single function as these are mostly methods of class Apollo13. Anyway this code is for children theme purpose.

    //for child themes, so they could overwrite default behaviour
    if(!function_exists('lets_play_apollo_game')) {
        function lets_play_apollo_game(){
            global $apollo13;
            $apollo13->start();
        }
    }

    You don't have to delete anything from parent theme you just should create function lets_play_apollo_game in functions.php in child theme and then parent theme function will not fire. But I'm afraid that you will have to copy whole advance directory to child theme.

    I will check how to do it soon and then post it and write about it in documentation.

    With regards.

  • AirAir
    edited August 2012 Posts: 10,970
    I am a bit confused if making functions of theme in class was right choice, cause if we add new function(method) to Apollo class and child theme will be overwriting whole class, then you won't be able to use this new function after update, unless you copy it...

    Damn, I saw other Pro themes are using same technique, but it is kind of smelly when I think about it now;-) I must read more about this. Anyway I will try deploy sample child theme today. Maybe in next version I will decide to rewrite whole Apollo13 class to functions.
    Post edited by Air on
  • AirAir
    Posts: 10,970
    OK I found what spaceship was lacking to make adding child theme possible. I will now rewrite spaceship framework, so it may take some time. I think tomorrow we will release version with child theme possibility :-) Sorry for problems.

    With regards.
  • Posts: 25
    no rush! I found a workaround for my problem for the time being!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!