Skip to:
Content
Pages
Categories
Search
Top
Bottom

Different Backgrounds


  • Craig
    Member

    @mckrazie

    Hello,

    I am currently in developement of a theme for a gaming group’s website that I maintain. We play multiple games and I wanted to have different backgrounds get picked randomly for the site and then if you select one of the games in their given section … it would pick that game background for that page. Perhaps, if I could for that game’s forum also on bbPress.

    I know this may be a lot to ask of a PHP script but is there anything out there?

    To help aid in any responces here is my idea overviewed:

    Parent Link – Randomly picked background from backgrounds database

    Games > Warcraft – Warcraft background

    Forums – Randomly picked background from backgrounds database

    Warcraft Forums – Warcraft background

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

  • chrishajer
    Participant

    @chrishajer

    It can be done with PHP.

    I’ve never done the random thing, but the Cutline theme for WordPress offers this functionality. You can read about it here:

    http://cutline.tubetorial.com/totally-random-header-images-for-cutline/

    I think you could adapt that for your uses.

    In WordPress, for a specific background tied to a specific page, I just do something like this in header.php:

    <div id="container" style="background: #fff url('<?php bloginfo('template_directory'); ?>/images/<?php echo $post->ID; ?>.jpg') left top no-repeat;">

    That gives the container div the background image of the post ID.jpg, so if you were viewing post 52, you would have a background image of 52.jpg. You could easily adapt this to bbPress calls by using the forum number and $forum_id, whichever div you want a background for (#wrapper or #main?) and then the proper location of your images (whether they are stored in your template folder or your forum root or something.) It fails OK too since there is a color code for the background and that is used if the image cannot be found (I think that’s what happens anyway.)

    Let me know if that makes sense. This is how I’ve done it in WordPress, but the same approach will work for bbPress I think.


    Sam Bauers
    Participant

    @sambauers

    This would be pretty easy to do within a theme.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.