category-header: individual header image for each category

Skinning and designing Serendipity (CSS, HTML, Smarty)
User avatar
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 12:46 pm

Post by hgoor » Fri Nov 02, 2007 3:02 pm

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?serendipity[subpage]=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

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

Post by judebert » Fri Nov 02, 2007 3:03 pm

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

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

Post by Don Chambers » Fri Nov 02, 2007 3:26 pm

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! :)

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

Post by judebert » Fri Nov 02, 2007 3:42 pm

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

User avatar
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 12:46 pm

Post by hgoor » Fri Nov 02, 2007 5:09 pm

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

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

Post by Don Chambers » Fri Nov 02, 2007 5:56 pm

So did you install that plugin? Does it work with the images you uploaded?

User avatar
hgoor
Regular
Posts: 297
Joined: Thu Jan 06, 2005 12:46 pm

Post by hgoor » Fri Nov 02, 2007 6:05 pm

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: 120
Joined: Tue Oct 04, 2011 3:22 pm

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

Post by Huhu » Wed Jun 11, 2014 10:54 am

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.
Fan of post-apocalyptic Jugger: Free ebook on the sport

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

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

Post by garvinhicking » Thu Jun 12, 2014 3:19 pm

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: 120
Joined: Tue Oct 04, 2011 3:22 pm

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

Post by Huhu » Thu Jun 12, 2014 9:45 pm

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

Thanks a lot!
Fan of post-apocalyptic Jugger: Free ebook on the sport

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

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

Post by Timbalu » Fri Jun 13, 2014 9:29 am

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