template config changes

Discussion corner for Developers of Serendipity.
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

template config changes

Post 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;
}
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post 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).
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: template config changes

Post 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.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post 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?
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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.
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: template config changes

Post 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
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post 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:
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: template config changes

Post 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
Post Reply