New Landing How can we help? Cardinal Child Theme usage?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Posted in: Cardinal
  • #139793
    Tekguild
    Member
    Post count: 171

    I’m working on customizations of this theme for a client and one thing they’d like done is to remove the ‘Posts tagged with’ text from archive pages.

    Usually this is simply done by copying the page template to the child theme, editing the text and done.

    However, that doesn’t seem to be the case here. The file used is in swift-framework>core>sf-page-heading.php. Copying the file structure to the child theme and editing the file does nothing.

    What am I missing?

    #139875
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Any files beginning with sf- are framework files, and can’t be overwritten using that method.

    You have to replace the function, by adding the whole function starting from the conditional statement, to you child theme’s functions.php file:

    /* PAGE HEADING
        ================================================== */
        if ( ! function_exists( 'sf_page_heading' ) ) {
            function sf_page_heading() {

    Make sure you copy the whole function

    – Kyle

    #146488
    Tekguild
    Member
    Post count: 171

    I have to ask – why would you do it this way, instead of putting it in the base functions file?

    #146595
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Because when you update the theme your change will be lost

    – Kyle

    #146627
    Tekguild
    Member
    Post count: 171

    No, no I wouldn’t. Putting the function in the root functions file, rather than nesting it in folders, would only make it easier to trace where functions are being generated.

    If I copy that function to the Child theme function and modify it, then update the primary theme, the function is still there and nothing is lost.

    So I’m a bit unclear where your answer came from. I guess I need to be more clear – why are these functions in nested folders, rather than in the root functions file? I’m really curious, as it seems to add an unnecessary level of complexity.

    #146630
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Sorry I thought you were asking me why to add it to the functions.php file in the child theme instead of the parent theme.

    The answer to your question is organization. Adding all of the theme functions to the functions.php file would not be well organised at all and unless people knew the name of the function they wanted to change, then they would struggle to find it. We have different functionality for the theme, such as the swift framework, the theme options, the custom post types etc. It’s much better for us to organize this into folders

    – Kyle

    #183375
    Tekguild
    Member
    Post count: 171

    I’m going to politely disagree with you. Your method makes it extremely difficult to trace file origins, much less being able to alter functions.

    Putting all functions in the top level functions.php file and commenting to designate how and where they are used should be just as easy as ‘organizing’ them into separate files and subfolders.

    You say

    “unless people knew the name of the function they wanted to change, then they would struggle to find it. “

    Well, I think it’s MORE of a struggle to find functions when they’re NOT in the functions.php file. If you have a single functions file, someone looking for a function has several options for searching (by function name, by parameter, by keywords they can find using web dev tools, etc) AND they have the confidence of knowing the function they’re looking for is in that file. Not only that, but they can easily change the function in the child theme.

    As it is now, you have to use a tool like EasyFind (for Mac) to search through all the theme files to locate the function you’re looking for.

    In any case – I wanted to reply to this with my own thoughts so that others may see there are different and possibly better approaches to doing things than what theme developers deem ‘right’.

    #183473
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi @grokism,

    I can see your points, but for us it’s just not maintainable to have what would likely be a 30-40k line functions.php file. We share most functions across all of our latest themes so that we maintain a single codebase for the most part. This saves us a lot of time.

    There are of course pros and cons for both methods, but for now this is the method that works best for how we are set up. I appreciate you taking the time to give some feedback.

    – Ed

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.