[Feature request] Custom header image plug-in

Discussion corner for Developers of Serendipity.
Post Reply
Huhu
Regular
Posts: 157
Joined: Tue Oct 04, 2011 3:22 pm

[Feature request] Custom header image plug-in

Post by Huhu »

Hej!
I am very happy with Don Chamber's Clean Blog theme.
Clean Blog addresses an issue that is quite important to me: You can assign custom images to the header section. So I can build a "static" website using Clean Blog and assign fitting header images for each topic.
But when using another theme, this option is of course not present.

Now, it shouldn't be hard to make the feature available as a plug-in for every theme. It should work like "Extended properties for entries".

While I would be glad to help and support such a plug-in, I am not enough of a coder to be able to realize it.

Anyone capable and willing?
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [Feature request] Custom header image plug-in

Post by garvinhicking »

Hej!

I understand the wish, however I see a problem with this. The header area is very much dependant on the used template. I do not see a generic way to support this with a plugin, because it always depends on the used HTML layout of a template. So I think it would be better for each template to support the option instead...?!
# 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/
Huhu
Regular
Posts: 157
Joined: Tue Oct 04, 2011 3:22 pm

Re: [Feature request] Custom header image plug-in

Post by Huhu »

Hej!
Ah okay, thank. I'd love to isolate DonChambers Clean Blog entry head chooser and implement it, but for now I am just too overwhelmed by all those file references/dependencies that it does seem to carry with it.
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: [Feature request] Custom header image plug-in

Post by Don Chambers »

Am I understanding you correctly:

You want to use the timeline theme, but display a category specific sub header on entry pages instead of the same sub header on all pages?

If so, it might be fairly easy.

In index.tpl is this:

Code: Select all

{* SUBHEADER IMAGE *}    
{if $template_option.subheader_img}
    <style type="text/css">.subheader_image {ldelim}background-image: url('{$template_option.subheader_img}');{rdelim}</style>
{/if}
You could try changing that code to this (untested):

Code: Select all

{* SUBHEADER IMAGE *}
{if $template_option.subheader_img}
    {if $entry.categories}
        {foreach from=$entry.categories item="entry_category"}
            {if $entry_category.category_icon}
                <style type="text/css">.subheader_image {ldelim}background-image: url('{$entry_category.category_icon}');{rdelim}</style>
                {break}
            {/if}
        {/foreach}
    {else}
        <style type="text/css">.subheader_image {ldelim}background-image: url('{$template_option.subheader_img}');{rdelim}</style>
    {/if}
{/if}
That SHOULD emit the image for the first category that has a category image for entry views, then use the defined sub header image for everything else.

You will need to delete the category images from line 95 of entries.tpl:

Code: Select all

{if $entry.categories}{foreach from=$entry.categories item="entry_category"}{if $entry_category.category_icon}<a href="{$entry_category.category_link}"><img class="serendipity_entryIcon" title="{$entry_category.category_name|@escape}{$entry_category.category_description|@emptyPrefix}" alt="{$entry_category.category_name|@escape}" src="{$entry_category.category_icon}"></a>{/if}{/foreach}{/if}
I have not tested this, but it should work, or get you fairly close to what you want.
=Don=
Huhu
Regular
Posts: 157
Joined: Tue Oct 04, 2011 3:22 pm

Re: [Feature request] Custom header image plug-in

Post by Huhu »

Hej Don,

wow, that looks great. I'll try it out soon and report back.
Thanks a bunch and a brilliant week to both of you :)
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
Post Reply