template config changes

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

template config changes

Post by Don Chambers » Sun Jan 25, 2015 10:46 pm

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;
}

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Sun Jan 25, 2015 11:43 pm

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?

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post by garvinhicking » Mon Jan 26, 2015 12:30 pm

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/

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Mon Jan 26, 2015 4:04 pm

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.

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post by garvinhicking » Tue Jan 27, 2015 2:18 pm

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/

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Tue Feb 03, 2015 12:45 am

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.

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post by garvinhicking » Tue Feb 03, 2015 3:35 pm

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/

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Tue Feb 03, 2015 7:25 pm

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?

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post by garvinhicking » Wed Feb 04, 2015 11:31 am

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/

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: template config changes

Post by Timbalu » Wed Feb 04, 2015 11:44 am

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

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: template config changes

Post by garvinhicking » Wed Feb 04, 2015 2:29 pm

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/

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Wed Feb 04, 2015 5:03 pm

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.

User avatar
yellowled
Regular
Posts: 7017
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: template config changes

Post by yellowled » Wed Feb 04, 2015 6:16 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
Don Chambers
Regular
Posts: 3633
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: template config changes

Post by Don Chambers » Wed Feb 04, 2015 6:47 pm

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:

User avatar
yellowled
Regular
Posts: 7017
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: template config changes

Post by yellowled » Wed Feb 04, 2015 7:02 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

Post Reply