Jump to content
Violet

[SOLVED] How to disable by default the automatic append of _main.php in templates?

Recommended Posts

Posted (edited)

I know that we can disable the append of _main.php by clicking the box in the template file. However, is there a way to disable it by default, so that new templates created do not append _main.php? For those of us that never use _main.php, it's something that needs to be clicked every time a new template is created. Not a big deal, but is there a way to set it up in the settings to default to NOT appending? I tried different searches on the forum and haven't come up with anything yet.

I understand more the default automatic prepend of _init.php because most people have variables to populate there before the rest of the page loads. Anyway, if there is no solution to my question, it's a minor thing, but thought I'd ask as I'm in the process of moving several of my sites to ProcessWire and this is a question that I think of often.

Edited by Violet
Marked as solved

Share this post


Link to post
Share on other sites

Either add $useMain = false; to your templates, and / or alter your site/config.php file:

$config->appendTemplateFile = '';

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Wow! This is perfect! 😍 Thanks for the different options of solutions you offered @dragan. I will go with this one you suggested:

8 minutes ago, dragan said:

$config->appendTemplateFile = '';

I am about to switch over one of my other sites. Am thrilled that with altering 1 line in the .config file I will save some clicking, and to be honest it's not just the clicking; I forgot to do it on one template, and then it took me awhile to figure out what was the problem when the rendered page looked weird. So this will save me quite a bit of time. Thanks again!

Share this post


Link to post
Share on other sites

You can also change settings via API:

$tpl = $templates->get("location");
$tpl->noAppendTemplateFile = 1;
$tpl->appendFile = "";
$tpl->save();

 

  • Like 3

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...