Support » Plugin: Business Directory Plugin - Easy Listing Directories for WordPress » i want to overwrite default template files

  • Resolved Rasel

    (@12345adgj)


    as per your doc references, i have to create a “subfolder” named {business-directory} and inside of this folder i need to keep the template file what i need to edit as like “single.tpl.php” i did that but it is not working.
    one thing i noticed, on your doc site “business-directory” plugin has a folder name “core” but i haven’t seen any folder named on “core” in your business directory plugin!
    may i know the correct way to re-write template code with my active theme folder?

    Thanks
    Rasel

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi Rasel,

    Sorry for any confusion here!

    As the docs indicate here:

    http://docs.businessdirectoryplugin.com/themes/customization.html#how-to-implement-a-template-override

    This is the proper way to do a template override:

    1) Locate the template you want to override. It can be a template from the core plugin (business-directory-plugin/core/templates), from a premium module or a Business Directory theme (theme templates are under wp-content/businessdirectory-themes/<active theme>/templates/).

    2) Copy the template to your active WordPress theme directory under the business-directory subfolder. You might need to create this folder. The final file should be located at wp-content/themes/<active WP theme>/business-directory/<template name>.tpl.php.

    3) Use the copied version of the template to have a grasp of how the Business Directory functionality works inside the template.

    4) Use your theme’s file and the BD default’s to build your own definitive template. Read the subsection in Core templates and variables that applies to the template you’re overriding. This gives you information about the PHP variables and methods that are available inside the template.

    5) Test your changes. If you have a lot of trouble, remember that you can just remove the file from your theme folder or copy the Business Directory Plugin original template verbatim and start over again.

    Example.

    Let’s assume that you wnat to change how the “single” listing view looks like. As per the documentation below, you’ll find that the template is called single.tpl.php and it is located in business-directory-plugin/core/templates/single.tpl.php. Assuming your current WordPress theme is “Twenty Fifteen”, you should copy this file to wp-content/themes/twentyfifteen/business-directory/single.tpl.php and make your changes here. ∎

    Does that make more sense?

    In your case, can you tell me the specifics of:
    – What template you’re overriding
    – What is the full path you’re using to put it under?
    – What is the name of your theme?
    – Did you create the required directory as noted above?

    Knowing that, we can probably pinpoint the issue. Please let me know.

    Thread Starter Rasel

    (@12345adgj)

    Thanks for your reply. but the main concern is not yet solved. let me clear it more to you.

    i want to put some extra content before filling up some data. so, that file is located business-directory-plugin>templates>submit-listing>listing-fields.tpl.php

    i don’t want to edit the main file. i am using Twenty Fifteen theme so i make a folder named business-directory as you mentioned and edit that file on there but not working 🙁

    but work when i copy any file business-directory-plugin>templates>anything.tpl.php but not work when i go one more step deep folder like earlier i said business-directory-plugin>templates>submit-listing>listing-fields.tpl.php

    Hope you understand what i mean.
    Thanks in advance 🙂

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi Rasel,

    Sorry for the delay–it was a holiday weekend in the US here.

    Not all files from the plugin can be overridden. The specific list of files that we allow for overrides are here:

    http://docs.businessdirectoryplugin.com/themes/customization.html#how-to-implement-a-template-override

    You are trying to override a file that isn’t one of those: listing-fields.tpl.php

    That’s OK–you can do changes to it, they just aren’t going to be saved the way overrides are. We can’t make every file overridable in the plugin as that’s a lot of work and it also introduces the possibility that small changes can break everything in the plugin’s complex behavior, so we have to retain some control in that case.

    You can customize things, but that comes with it’s own cost: http://businessdirectoryplugin.com/docs/customization-guide/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘i want to overwrite default template files’ is closed to new replies.