Return to Snippet

Revision: 51148
at September 16, 2011 00:32 by jose_506


Initial Code
<?php
    
    function switchlibrary($controllerName = null){
           if(isset($controllerName)){

                $styles;
                $scripts;

                $returnScripts='';
                $returnStyles='';

                $jquery = 'public/js/jquery.min.js';
                $cufon = 'public/js/cufon.yui.js';
                $quicksand ='public/js/quicksand.js';
                $custom = 'public/js/custom.js';
                $fancybox = 'public/js/fancybox/jquery.fancybox-1.3.0.pack.js';
                $slider = 'public/js/jquery.anythingslider.js';

                $style = 'public/css/style.css';
                $slidercss = 'public/css/anythingslider.css';
                $fancyboxcss = 'public/js/fancybox/jquery.fancybox-1.3.0.css';
                $twitter = 'public/js/twitter.min.js';

                switch($controllerName){
                    case 'Home':
                        $scripts=array($jquery,$cufon,$quicksand,$custom);
                        $styles=array($style);
                    break;
                    case 'Portfolio':
                        $scripts=array($jquery,$cufon,$quicksand,$fancybox,$slider,$custom);
                        $styles=array($style,$slidercss,$fancyboxcss);
                    break;
                    case 'Social':
                        $scripts=array($jquery,$cufon,$quicksand,$twitter,$custom);
                        $styles=array($style,$slidercss,$fancyboxcss);
                    break;
                    case 'Skills':
                        $scripts=array($jquery,$cufon,$quicksand,$custom);
                        $styles=array($style);
                    break;
                    case 'Contact':
                        $scripts=array($jquery,$cufon,$quicksand,$custom);
                        $styles=array($style);
                    break;
                }

                for($sc=0;$sc<count($scripts);$sc++){
                    $returnScripts.=link_script($scripts[$sc]);
                }

                for($st=0;$st<count($styles);$st++){
                    $returnStyles.=link_tag($styles[$st]);
                }

                return $returnStyles.$returnScripts;
            }else{
                return false;
            }
    }

?>

Initial URL

                                

Initial Description

                                

Initial Title
Switch libraries current page

Initial Tags
php, page

Initial Language
PHP