Brainstorming: What do we "need" template-wise?

Skinning and designing Serendipity (CSS, HTML, Smarty)
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

yellowled wrote:However, I'm starting to lose patience, and will therefore probably try to figure the code out on my own. Wish me luck.
Hrmpf. We really need to get Abdussamad (or someone who understands his code - I don't) in here. Unfortunately, Abdussamad seems to be missing in action ... I emailed him right after he released Beautiful Day, and I'm still waiting for a response :?

So here are the two problems (I put this down here so I don't forget it :)):

1. Adbussamad's code is too "complicated" for our purpose. I figure we need only one header image, which could either be a banner or a tiled image (horizontally, vertically, or both).
2. At the very end of functions.custom_imgsel.inc.php, there's a hardcoded template path - ouch. That won't work with the framework concept for BP. Once people rename the template folder from bulletproof to something else, the image selection won't work anymore, so that needs to be fixed.

I'll see if I can get some help in here.

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I have not even looked at the code for this header image. I still have a partially resolved issue with that green colorset of Dave's to attack once I can get back. But HEY - at least I am checking posts here again! Have to start somewhere!!! :lol: Can someone please remind me how I got sucked into this black hole to begin with?!!!! LMAO!!!
=Don=
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

Hi Guys

back on the bulletproof trail again! The snooker has been taking up a bit of my time too.

And I notice we've got no volunteers to help with the header code.

I've added a few more classes to the coloursets but that's about it from me just now- I've not found anymore problems so lets hope we get a coding helper for the header.

cheers

Dave
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

d_cee wrote:
And I notice we've got no volunteers to help with the header code.
Sure we do - it's Judebert - he just doesn't know it yet!!! :lol:
=Don=
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Hey, I resemble that remark!

Actually, I'm finding Abdussamad's code not too difficult to understand. The idea here is to make a portable way to allow users to choose images from the Media Center, right? It needs to be as simple as possible, so template designers can understand it before they add it to a config.inc.php. And that's it, right? (Right?)

I think it can be done. We might even get Garvin to accept a "Media Center" type for all configuration forms, just like we currently have radio buttons and text areas.
Judebert
---
Website | Wishlist | PayPal
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
I think it can be done. We might even get Garvin to accept a "Media Center" type for all configuration forms, just like we currently have radio buttons and text areas.
Garvin would be fine with that, in fact he considers this to be of great value :-)

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

Post by yellowled »

Sorry I've been out for a couple of days, someone had to celebrate his birthday properly. No singing, please.
judebert wrote:Actually, I'm finding Abdussamad's code not too difficult to understand.
That's probably because you understand PHP code a lot better than I do :wink:
judebert wrote:The idea here is to make a portable way to allow users to choose images from the Media Center, right? It needs to be as simple as possible, so template designers can understand it before they add it to a config.inc.php. And that's it, right? (Right?)
Basically, yes. (Right.)

Here's what I have figured out on my own: We need Abdussamad's functions.custom_imgsel.inc.php and custom_imgsel.js in the template folder, and we need to add some code to our config.inc.php. But there's one line in the functions-file which needs to be changed:

Code: Select all

<script type="text/javascript" language="JavaScript" src="{$serendipity['baseURL']}{$serendipity['templatePath']}bulletproof/custom_imgsel.js"></script>
You'll notice I have already changed the hardcoded template path to bulletproof, but it would be nicer to have some sort of variable which automagically picks the template directory 'cause this isn't going to work anymore once people rename their bulletproof-based template's directory to something else (unless they change the hardcoded path, too, but that doesn't really fit with the rest of BP which is meant to be simple to customize and configure). Oh, and I've just realized that this path is also hardcoded in the config.inc.php, which shouldn't remain that way, either.

(Sorry I'm starting to create those endless sentences which are rather common in German :))

Plus, I'd like to simplify (is that even a word?) Abdussmad's code to use just one header image. Basically, the best way to use this in BP would be something like this (in the theme options):

Code: Select all

Use custom header image? [x] Yes [ ] No
Select custom header image: [select box for media db]
Header type: [not tiled|horizontally tiled|vertically tiled|tiled both h. + v.]
The first and last option I can do, but I'm struggling with the middle one. CSS code is no problem, either.

YL
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Actually, the majority of what's in custom_imgsel.js is to create a preview window and make certain the text box is editable. All you really need to spawn a Media Center chooser for a text box with a particular ID is the last two lines:

document.getElementById(target_txt_box).disabled=false;
window.open('serendipity_admin_image_selector.php?serendipity[htmltarget]=' + target_txt_box + '&serendipity[filename_only]=true', 'ImageSel', 'width=800, height=600, toolbar=no, scrollbars=1, scrollbars, resize=1, resizable=1');

Note that I haven't tried this on my blog yet, but that's all the required code from a programmer's point of view. Just assign that as the 'onClick' of button or link, and it'll pop up a Media Center chooser to populate target_txt_box.

In the template, you can change that path to {serendipity_getFile file="custom_imgsel.js"}, which looks through the current template directory, the default template directory, the default/ directory, and the Serendipity root directory for the named file.

In the PHP, you can use serendipity_getTemplateFile('custom_imgsel.js'), which does the same thing from PHP.

Hmmm... maybe I can clean all this stuff up a little. Meanwhile, this should give you something to experiment with.
Judebert
---
Website | Wishlist | PayPal
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Indeed, it looks like getting an 'image' type added to the functions_plugins_admin.inc.php is our best bet. I'll try to write up some code for that and submit it to Garvin. Meanwhile, I think I can make things reasonably easy with a 'custom' type. I'll need a little while longer.
Judebert
---
Website | Wishlist | PayPal
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I have no idea as to what you guys are working on now, but I did want to say "thanks" go Judebert for picking up this issue and running with it!!!
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

Jude, first of all: Thanks for chiming in on this :)
judebert wrote:Note that I haven't tried this on my blog yet, but that's all the required code from a programmer's point of view. Just assign that as the 'onClick' of button or link, and it'll pop up a Media Center chooser to populate target_txt_box.
Well, I have tried it just now, and unfortunately, it's not working (yet). Here's what I currently have in my config.inc.php (just the parts necessary for this):

Code: Select all

$header_html="<input type="text" id="target_txt_box" />";
$header_html.="  <a href="#" onclick="document.getElementById(target_txt_box).disabled=false; window.open('serendipity_admin_image_selector.php?serendipity[htmltarget]=' + target_txt_box + '&serendipity[filename_only]=true', 'ImageSel', 'width=800, height=600, toolbar=no, scrollbars=1, scrollbars, resize=1, resizable=1');">BP_MEDIA_LIBRARY</a>";
[...]
    array(
        'var'           => 'bpheaderpath',
        'type'          => "content",
        'default'       => $header_html
    ),
Everything's displayed properly in the theme options, but it's not working, i.e. there's no media db popup when I click that link. Firefox's firebug extension also says: "document.getElementById(target_txt_box) has no properties". Hope this gives you any hints ...

Oh, and to clear that up for Don: We're working on simplifying Abdussamad's code to be able to insert a custom header image from the media database :)

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

yellowled wrote:Oh, and to clear that up for Don: We're working on simplifying Abdussamad's code to be able to insert a custom header image from the media database :)

YL
I know what you are working on, just do not have the mental capacity to digest it right now!! LOL!!! I have gotten sidetracked into another project outisde of BP... This time for my kid's school. Another hobby of mine is video editing, and they need me to put something together in the next 2 weeks. Damn - so much I want to do with BP, and that last experiment I had, but I am getting set back again! Hope you guys understand! Thanks again to Judebert for looking at this header image stuff! Cannot say I like the JS requirement, but those of you who know me already know I hate JS, but if it is necessary, so be it. I do, however, appreciate Judebert's willingness to help! I will never understand it, but it is great to see a guy dig in and help when such help is so needed!

Dead tired. Going to sleep now. Sorry I have been so pathetic lately. I promise - I will get back into this game as quickly as I can.... which will not be as quickly as I want!!!!!!!
=Don=
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Grumble, grumble...

Thanks, YellowLed. I'll get that figured out.

My time has been severely restricted by the onset of a huge RL workload, but I thought I'd let you know what I'm doing with this.

First off, since Garvin has endorsed the idea of a "media" type, I'm going to implement it. Unfortunately, since that's handled in the S9Y core, it'll require a new version of Serendipity before it starts working.

But I don't want your templates to need more "if version" code. Luckily, Garvin was way ahead of this on this one: if S9Y can't figure out what the type is supposed to be, it hands it off to the plugins! So, I can program a quick "Advanced configuration types" plugin to handle the "media" type.

Then the template code should look like:

Code: Select all

$template_options = array(
  array(var => 'header_img',
           name => 'Header Image',
           description => 'The image that goes in the header',
           type => 'media',
           default=> serendipity_getTemplateFile('header.png')),
);
If the version of Serendipity is sufficient, or the plugin is installed, you'll get a text box to enter an image location, with a link to pop up the Media Center. I'd like it to include a preview image, but I need to take one step at a time. The image location will be available just like any other template variable, in t_header_img.

If there's no plugin, and the Serendipity version is too old, nothing will show up.

The advantage is that you don't have to change the templates after we get the new 'media' type in, you don't have to include another version check, and we can add as many new tag types as we want. The disadvantage is that the user needs to upgrade, or install the advanced configuration types plugin, before anything is displayed.

Everybody think this is a good direction? Comments?
Judebert
---
Website | Wishlist | PayPal
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

Hi Judebert

good to be working with you again too Jude!

this sounds like the ideal way to implement this feature to me - providing you've time to do it of course :-)

I'm sure most users of <v1.2 wouldn't mind installing a plugin to get this extra functionality - and after v1.2 it won't be necessary.

cheers

Dave
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Okay, I've got v0.1 ready for use. I tested it on my own blog to make sure I wasn't just handing you a dud.

Get it from http://judebert.com/wasted_youth/media/ ... vtypes.zip while it's hot!

What you'll be downloading is a plugin that provides the 'media' type for your template configuration options. (It might work for plugins, too, but I'm not guaranteeing anything!) Included in the same directory is an "index.tpl" derived from Carl Galloway and YellowLed's "One True Layout". (Sorry, guys. I don't have anything against you, but that's the theme I use for my blog, so that's the one I butchered for testing.)

The index.tpl is not actually used. It merely demonstrates how to access the media field to set the background of the header. For testing, I also added a 'media' option called 'header_img' to the config.inc.php. I tried it out, and it worked just fine.

The media option includes a picture, a text entry field, and a "Media library" link. Clicking the link opens the Media Library / Media Center so the user can choose an image. When a picture is chosen, it populates the text entry field. The image is not modified until you save the options.

The plugin uses serendipity_getTemplateFile() to find the image. This searches the template directory, the default directory, and the current directory. The upshot is, you can also type in your own image name directly, and it'll still be found and used.

Problems/Suggestions:
The image should change when a new image is selected.
The image should use the thumbnail instead of the big image.
Clicking the image should bring up the Media Library, too.
Provide text (instead of broken image) when an image cannot be found.

Garvin, is there any way to search in the plugin directories, like getTemplateFile, but getPluginFile? Could I use __FILE__ or something?
Judebert
---
Website | Wishlist | PayPal
Post Reply