WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: vark on December 07, 2008, 09:11:35 PM

Title: Include CSS, JS etc by Page
Post by: vark on December 07, 2008, 09:11:35 PM
I'm a complete neophyte when it comes to php, so it took me months to figure this out.  For those who haven't got this already, here's a solution:

<?php if (PAGE_ID  ==  '2') { ?>
    <link href="<?php echo WB_URL; ?>/styles/home.css" rel="stylesheet" type="text/css" media="screen" />

<?php } else if (PAGE_ID  ==  '3') { ?>
    <link href="<?php echo WB_URL; ?>/styles/page2.css" rel="stylesheet" type="text/css" media="screen" />
   
<?php } else  $list = array('4', '5', '6');
              if (in_array (PAGE_ID, $list)) { ?>
    <link href="<?php echo WB_URL; ?>/styles/pages4to6.css" rel="stylesheet" type="text/css" media="screen" />

<?php } ?>

Page_id can be found in the web address of a given page during an edit session in WB admin (http://yourpage.org/admin/pages/modify.php?page_id=2).
Title: Re: Include CSS, JS etc by Page
Post by: Bramus on December 07, 2008, 09:31:27 PM
Thanks for posting, but i think this has already been posted here a few times only for a different header, a simple edit by that script would have done the same as you posted here, so you could save a month of work by searching a bit or asking for help :P

Btw can you place the code in the code tag?
Title: Re: Include CSS, JS etc by Page
Post by: vark on December 07, 2008, 09:38:59 PM
Hi Bramus,
Sorry to have recapitulated something already posted.  Could you point me towards the other post?  Thanks.
Title: Re: Include CSS, JS etc by Page
Post by: doc on December 07, 2008, 10:33:09 PM
@vark:
Some of the hits mentioned by Bramus could be found by using the advanced forum search and keywords: CSS page_id

Regards Christian