category-header: individual header image for each category

Skinning and designing Serendipity (CSS, HTML, Smarty)
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 11:46 am

Post by hgoor »

Don Chambers wrote:Bulletproof 1.1 is never going to be in spartacus... bulletproof is one of s9y's core templates. There will be 2 ways to get bp updates. First, if s9y is updated (ie, 1.2.x or 1.3), the latest bp will be in that release. Second, we are maintaining a download location for interim bp releases so we do not have to wait for s9y to be updated when we want to update bp. BP updates, including 1.1, can be downloaded here:

http://s9y-bulletproof.com/index.php?se ... ]=download

BP does use a banner ID of serendipity_banner, but I have not tried this plugin Garvin mentions so I cannot be sure if it will work or not... but I suspect it will.
Ah, OK. I understand. So, coming back to my question: rotaing banners randomly should be build in to the BP template as there is no other option I guess that will work for sure....
"If life is worth living, it's worth documenting" -- Adam Curry ("Podfather")

Bloggers@large: http://www.vandegoor.com
iLounge Radio: http://www.hostingperfect.net:8004/listen.pls
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Knowing Don, probably. But the plugin, now named "Template Header/Logo Image" in SPARTACUS, supports three different header types, and is easy to configure and test. Just install it, specify the path to your image directory, save the configuration, and try your blog. If nothing happens, reconfigure for one of the other header types.

If you get it to work, come back and tell us so others will know what to do. If you can't get it to work, let us know so we can update it for BulletProof.
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 »

judebert wrote:Knowing Don, probably. But the plugin, now named "Template Header/Logo Image" in SPARTACUS, supports three different header types, and is easy to configure and test. Just install it, specify the path to your image directory, save the configuration, and try your blog. If nothing happens, reconfigure for one of the other header types.

If you get it to work, come back and tell us so others will know what to do. If you can't get it to work, let us know so we can update it for BulletProof.
Jude - you seem to be the resident expert on banners & the media library.... perhaps that plugin could be updated to offer an option to load images from a particular folder in the media library??? Not sure if that is pandora's box though... specifying the wrong folder, or the entire media library could have some fairly nasty results! :)
=Don=
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Bingo! I figured that I'd better leave it restricted it so people could verify their banner images were the correct size and format.

You could set it to a media library directory; you'd just have to type the right path. Then you could manage the banner images with the media library controls. But I didn't want to add a media selector, because that would just lead to trouble.
Judebert
---
Website | Wishlist | PayPal
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 11:46 am

Post by hgoor »

judebert wrote:Bingo! I figured that I'd better leave it restricted it so people could verify their banner images were the correct size and format.

You could set it to a media library directory; you'd just have to type the right path. Then you could manage the banner images with the media library controls. But I didn't want to add a media selector, because that would just lead to trouble.
I have put all my headers in a Media Library directory as this is the way Bulletproof works: you can assign a header using the media library, so I figured I make a directory just for that....

btw: if anyone is interested I can share those headers for people to use... I think I have a few nice ones (if I say so myself)..
"If life is worth living, it's worth documenting" -- Adam Curry ("Podfather")

Bloggers@large: http://www.vandegoor.com
iLounge Radio: http://www.hostingperfect.net:8004/listen.pls
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

So did you install that plugin? Does it work with the images you uploaded?
=Don=
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 11:46 am

Post by hgoor »

Don Chambers wrote:So did you install that plugin? Does it work with the images you uploaded?
No haven't had the time yet will do so probably this Sunday...
"If life is worth living, it's worth documenting" -- Adam Curry ("Podfather")

Bloggers@large: http://www.vandegoor.com
iLounge Radio: http://www.hostingperfect.net:8004/listen.pls
Huhu
Regular
Posts: 157
Joined: Tue Oct 04, 2011 3:22 pm

Re: category-header: individual header image for each catego

Post by Huhu »

Hej!

I tried the plug-in, though with no success (here). The DIV has the appropriate ID.

Now I would just choose a workaround by implementing a

Code: Select all

<!--#include virtual="randompicture.php" -->
to a simple PHP code snippet that would do the job (or better insert the code snippet directly into the index.tpl). Problem is to get that PHP snippet to work with the parser ... any hints?

Example for the php script, just for the show (it works fine if interpreted)

Code: Select all

<?php
   // Randompic
 srand ((double) microtime() * 1000000);
 $random = rand(1,4);
 
  if($random=="1")
  {
  echo "<div id=\"header\" style=\"background: url(headers/h_1.jpg) ;
  	 \" />";
 }  etc.
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: category-header: individual header image for each catego

Post by garvinhicking »

Hi!

You can edit your index.tpl file of the template (ideally you should create your own template). Then, inside your template directory you can edit/create a config.inc.php file:

Code: Select all

<?php
function randomPicture() {
 srand ((double) microtime() * 1000000);
 $random = rand(1,4);
 
 echo "<div id=\"header\" style=\"background: url(headers/h_" . $random . ".jpg) . "\" />";
}

$serendipity['smarty']->register_function('randomPicture', 'randomPicture');
then in your index.tpl you could call:

Code: Select all

{randomPicture}
which would call said PHP function.

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/
Huhu
Regular
Posts: 157
Joined: Tue Oct 04, 2011 3:22 pm

Re: category-header: individual header image for each catego

Post by Huhu »

GREAT! And again a big step (for me) to customizing templates, now with understanding the logic behind smarty, finally ;)

Thanks a lot!
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: category-header: individual header image for each catego

Post by Timbalu »

S9y does include workarounds for this old Smarty2 syntax to not break with older Plugins

Code: Select all

$serendipity['smarty']->register_function('randomPicture', 'randomPicture');
But for sure it is better to learn the new Smarty 3 syntax, since we don't know at when these helper compat functions will be removed, eg

Code: Select all

$smarty->registerPlugin("function",'randomPicture', 'fncRandomPicture'));
http://www.smarty.net/docs/en/api.regis ... dp16782656
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply