ThemeShaper Forums » Thematic


What exactly does adding a function do?

(4 posts)
  • Started 11 years ago by Robo
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. Robo

    I guess that Thematic is a bunch of PHP functions and css that provide a middle layer between the native WP code and the web designer?

    So, if a new function is added into the functions.php file and then activated, I guess it is overriding either a native WP function or a Thematic function?

    If that is the case, then we should have access to all the Thematic functions...

    If so, are these all stored in a common Thematic file?

    Posted 11 years ago #
  2. it is magic. :)

    i dont really know how to explain it. functions DO stuff. but i can tell you that all of thematic's functions (its guts) are located in the library/extensions folder. then for example if you open up the content extensions file you will see all of thematic's functions for creating the content... from the post-header (date, author,etc) to the post-footer (tags, categories, comments), the loops for all the different types of pages, etc.

    thematic has a bunch of "hooks" which are places you hang code. when the server processes all the php it goes in order through these hooks and processes whatever function is attached to them. to override a function, you actually first need to remove the thematic function from its hook. write your own and then add it back to the same (or a different one if you want) hook. this is why i spend a lot of time in the library folder. if i want to just tweak the postheader for instance, i will go and copy the entire thematic_postheader function into my functions.php. then i will make a minor tweak, rename the function, remove the original and add in mine.

    if a function returns a variable, you can use add_filter to change it w/o unhooking and rehooking a whole function.

    remove_action('hook where it is located', 'function you want to remove');
    echo "bacon";
    add_action('hook you want to the function to appear on','my_new_function');

    all that said, thematic does have several 'empty' hooks that you don't need to remove anything from before adding your own function.

    i'm gonna stop now b/c i am starting to confuse myself. but i always send people to this website as it helps visualize what is going on

    Posted 11 years ago #
  3. Robo

    Hey, thanks 4 that. It is as I suspected but had not got around to researching.

    Given the above, adding things like a graphic for the home button (as someone was asking recently) can presumably be done thru modifying the function that displays the menu bar, and with no need to locate anything -9999px out of sight, right?

    Posted 11 years ago #
  4. i think the home 'button' in the nav bar is a bit more complicated, b/c the structure, links and classes are often automatically generated. as far as i know there is no way to add images into the menu in place of the standard ul, li structure. well maybe with preg_replace?? but that stuff is voodoo.

    the CSS solution combo of background image and negative text indent is easiest for me. depending on your needs you could write a custom menu. or i just checked my local install and you can add custom classes (and ids) so you could give the home link something unique.

    or gene (er_hm) just posted a technique on image replacement that you may want to check out.

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.