ThemeShaper Forums » Thematic

[closed]

child overide

(13 posts)
  • Started 4 years ago by Jonny Janiero
  • Latest reply from teamA
  • This topic is resolved
  1. i use the child overides a lot.

    lets say i use overide category_loop to change the layout of my category loop.

    have i got to overide index, archive, tag, search individually or can i change the lot by combining the overides?

    hope this makes any sense

    Posted 4 years ago #
  2. have wondered this myself. it is sort of a pain (and code bloat) to have to override ALL the loops if you'd like them to all be the same.

    Posted 4 years ago #
  3. glad you understand the situation.
    it is a code bloat. in basic themes, you could style the main loop and if category, tag loops dont exist, the index loops run through.
    is there a way to bypass loops?

    Posted 4 years ago #
  4. Vasudeva Adiga
    Member

    I guess you could do this if you want all of them to use the same loop:

    add_action('thematic_categoryloop', 'xyz_loop');
    add_action('thematic_tagloop', 'xyz_loop');
    add_action('thematic_archiveloop', 'xyz_loop');
    add_action('thematic_indexloop', 'xyz_loop');

    Posted 4 years ago #
  5. neat idea. i think you'd also have to remove the current loops from those hooks OR define each override as xyz_loop, but i think it could work

    Posted 4 years ago #
  6. Ok .. will take a look at this one :)

    Chris

    Posted 4 years ago #
  7. Vasudeva Adiga
    Member

    You will have to remove the default actions hooks before replacing them with new ones:

    remove_action('thematic_categoryloop', 'thematic_category_loop');
    remove_action('thematic_tagloop', 'thematic_tag_loop');
    remove_action('thematic_archiveloop', 'thematic_archive_loop');
    remove_action('thematic_indexloop', 'thematic_index_loop');

    Posted 4 years ago #
  8. @Vasudeva Adiga
    i'll give that a whirl.

    Posted 4 years ago #
  9. @vasudeva
    although, in theory that should have worked for me (but does go back to removing/adding functions, when overides seemed like forward progress). it didn't in this particular case. maybe if i was using it in a standard set-up. for some reason, it messed with my archive() tags() statements.
    i'm pulling archive and tag display via an options panel conditional. i was getting a lot of duplicate posts. tried resets to no avail.
    its a little difficult to explain.
    reverted back to my overides and all was good. i'll keep the bloat knowing all is working correctly.
    thanks for you help.

    @chris, had any luck?

    Posted 4 years ago #
  10. i suppose you could do

    childtheme_override_archive_loop(){
       default_loop();
    }

    if you don't want to add and remove actions. i am going to try this tomorrow (errrr later today when i wake up) as i just modded my index loop.

    Posted 4 years ago #
  11. this seems to work for me:

    function default_loop(){
      //loopy stuff
    }
    function childtheme_override_archive_loop(){
    	default_loop();
    }
    function childtheme_override_author_loop(){
    	default_loop();
    }
    function childtheme_override_category_loop(){
    	default_loop();
    }
    function childtheme_override_index_loop(){
    	default_loop();
    }
    function childtheme_override_search_loop(){
    	default_loop();
    }
    function childtheme_override_tag_loop(){
    	default_loop();
    }
    Posted 4 years ago #
  12. worked a charm miss viking!
    thanks

    Posted 4 years ago #
  13. I would recommend that the solution from Helga and this topic in general become an article in the documentation. I spent quite a while making incorrect code before coming across this simple, lean solution. It's something I knew must exist - but laying it out in a nice tutorial / example would really help folks who are just getting up to speed (like me).

    Who do we suggest that to?

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.