Page 1 of 1

template config changes

Posted: Sun Jan 25, 2015 10:46 pm
by Don Chambers
So, I'm trying to come up to speed on recent developments in templates and s9y 2.0. I see this in 2k11:

Code: Select all

@serendipity_plugin_api::load_language(dirname(__FILE__));
Did that replace this?

Code: Select all

$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';

if (file_exists($probelang)) {
    include $probelang;
}

Re: template config changes

Posted: Sun Jan 25, 2015 11:43 pm
by Don Chambers
Here's another one. In both BP, and 2k11, an option exists to insert a header image. The code in 2k11 looks like this:

Code: Select all

    array(
        'var' => 'header_img',
        'name' => TWOK11_HEADER_IMG,
        'type' => 'media',
        'default' => serendipity_getTemplateFile('header.jpg')
    ),
BP's looks substantially identical. However, neither template comes with a default header image, and when I try supplying a default image, it doesn't work. Is there actually a way to make an image within the template's img folder a default?

Re: template config changes

Posted: Mon Jan 26, 2015 12:30 pm
by garvinhicking
Hi!

About the first: Yes, that's what it replaces. I believe it got introduced in 1.6 or 1.7 already, not 100% sure ;)

About the second: The code call looks for "header.jpg" inside the template directory base; if you supply serendipity_getTemplateFile('img/header.jpg') instead you should be able to retrieve it from a img subdirectory...?!

HTH,
Garvin

Re: template config changes

Posted: Mon Jan 26, 2015 4:04 pm
by Don Chambers
garvinhicking wrote: About the second: The code call looks for "header.jpg" inside the template directory base; if you supply serendipity_getTemplateFile('img/header.jpg') instead you should be able to retrieve it from a img subdirectory...?!
It doesn't work from the template base director or subfolder.

Re: template config changes

Posted: Tue Jan 27, 2015 2:18 pm
by garvinhicking
Hi!

How exactly are you testing it? Remember once you saved your configuration, the line that was in the input field is saved in your database, it no longer gets "auto-detected". Auto-detection only works the first time when you have never saved the configuration of a theme. If you had i.e. getTemplateFile('bla.jpg') in there, then save config, it saves "/bla.jpg" (or an empty string). When you change the getTemplatEFile call in config.inc.php, this will never affect the display, because /bla.jpg is always read...

Regards,
Garvin

Re: template config changes

Posted: Tue Feb 03, 2015 12:45 am
by Don Chambers
garvinhicking wrote:Hi!

How exactly are you testing it? Remember once you saved your configuration, the line that was in the input field is saved in your database, it no longer gets "auto-detected". Auto-detection only works the first time when you have never saved the configuration of a theme. If you had i.e. getTemplateFile('bla.jpg') in there, then save config, it saves "/bla.jpg" (or an empty string). When you change the getTemplatEFile call in config.inc.php, this will never affect the display, because /bla.jpg is always read...

Regards,
Garvin
It works in < 2.0, but does not work in s9y 2.0.

An easy test: create a new theme folder which will contain a copy of 2k11. Copy 2k11 to this new folder. Modify info.txt so you can distinguish it from 2k11. Add an image, named header.jpg and place it in this folder. Change themes to this copy of 2k11. In the config options, before saving, the image SHOULD show up as a default, but does not.

Re: template config changes

Posted: Tue Feb 03, 2015 3:35 pm
by garvinhicking
Hi!

Please check if it works when you replace

getTemplateFile('bla.jpg')

to

getTemplateFile('bla.jpg', 'serendipityHTTPPath', true)

This is something similar like Ian had to patch for staticpages. The reason is that in s9y backend and frontend templates got seperated.

The properties will be read in the backend, but reference FRONTEND files, so inside the backend it might not get properly read when showing the configuration. By using that "true" parameter, the getTemplateFile tells s9y to reference a FRONTEND file, even when being called in the backend.

HTH,
Garvin

Re: template config changes

Posted: Tue Feb 03, 2015 7:25 pm
by Don Chambers
garvinhicking wrote:Hi!

Please check if it works when you replace

getTemplateFile('bla.jpg')

to

getTemplateFile('bla.jpg', 'serendipityHTTPPath', true)
Yes, this works. So should I keep this modification, or will something be changed in the core to not require this?

Re: template config changes

Posted: Wed Feb 04, 2015 11:31 am
by garvinhicking
You can add this to the file; it should work in s9y < 2.0 environments as well. The core sadly can't be changed, this parameter will now always be a requirement for plugins/themes that do something in the backend which requires frontend files; it cannot be deduced automagically (at least not safely).

Re: template config changes

Posted: Wed Feb 04, 2015 11:44 am
by Timbalu
Since 2k11 is an/the example copy or even custom change template, we should add this as default to its config.inc to avoid copy users to get into trouble; Even if it works without the 3rd param in 2k11 itself, while being the default backend template.

Re: template config changes

Posted: Wed Feb 04, 2015 2:29 pm
by garvinhicking
Timbalu wrote:Since 2k11 is an/the example copy or even custom change template, we should add this as default to its config.inc to avoid copy users to get into trouble; Even if it works without the 3rd param in 2k11 itself, while being the default backend template.
You are absolutely right, yes! Could you commit that?

Re: template config changes

Posted: Wed Feb 04, 2015 5:03 pm
by Don Chambers
You can add it to 2k11, but ..... although 2k11 specified a default image name, no header image exists in the 2k11 folder..... so, if you add the default image path, there will still be nothing to find.

Re: template config changes

Posted: Wed Feb 04, 2015 6:16 pm
by yellowled
Don Chambers wrote:no header image exists in the 2k11 folder
It will have to remain that way. A. I don't have an idea what to add there and B. all 2k11 users that don't use a header img now (which I would estimate to be something like 80-90%) would have to remove it when this update rolls in (wouldn't they?).
Don Chambers wrote:..... so, if you add the default image path, there will still be nothing to find.
Depends on what that returns for $template_option.header_img if $template_option.header_img throws a 404. Haven't test that, actually.

YL

Re: template config changes

Posted: Wed Feb 04, 2015 6:47 pm
by Don Chambers
yellowled wrote:
Don Chambers wrote:no header image exists in the 2k11 folder
It will have to remain that way. A. I don't have an idea what to add there and B. all 2k11 users that don't use a header img now (which I would estimate to be something like 80-90%) would have to remove it when this update rolls in (wouldn't they?).
No, the default image only works when the template is first configured. Once they save the template config with their previous blank value, it remains blank.
yellowled wrote:Depends on what that returns for $template_option.header_img if $template_option.header_img throws a 404. Haven't test that, actually.
Server log would likely show image not found (not sure thats a 404). I simply meant that even on future first time installations, there would be no default image, even though the fetch method is correct, unless a new image is now added to 2k11 going forward.

How about this for the new header: Image :lol: :lol: :lol:

Re: template config changes

Posted: Wed Feb 04, 2015 7:02 pm
by yellowled
Don Chambers wrote:Once they save the template config with their previous blank value, it remains blank.
Good, but still any new installation would get said default header, which leads us back to the point where I don't have a default header. Also, this is an option in 2k11, it should not be default to have to have a header image or to have to remove it.
Don Chambers wrote:How about this for the new header
Yeah, no; that would look stupid in multiple ways. :roll:

YL