Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Dynamiczne ścieżki do plików
Forum PHP.pl > Forum > PHP
Cliassi
Witam,

Posiadam serwis zrobiony z rewrite'ami a index.php ma częściowo taki kod:

  1. $arrParams = array();
  2. $strDefaultPath = '/';
  3.  
  4.  
  5. $_SERVER['REQUEST_URI'] = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : $strDefaultPath;
  6.  
  7. $arrParams =explode( '/', substr( $_SERVER['REQUEST_URI'], 1) );


moj problem polega na tym, że gdy wejdę na example.com/product/klawiatura_usb to wtedy linki do css(o dziwo się ładują) a js nie. mam ustawiony base url a gdy sprawdzam scieżkę do js to wychodzi example.com/product/js/plik_js.js

Wie ktoś jak dynamicznie generować scieżkę ?
mis
pokaż jak wczytujesz te pliki *.js oraz .htaccess
Cliassi
struktura plików:

/view
/includes
/class


index.php (/view/index.php)

  1. include_once('layout/header.php');



header.php (/view/layout/header.php)
  1. <base href="http://eample.com/">
  2.  
  3. <!-- Stylesheets -->
  4. <link href="style/bootstrap.css" rel="stylesheet">
  5. <link rel="stylesheet" href="style/font-awesome.css">
  6. <link href="style/prettyPhoto.css" rel="stylesheet">
  7. <!-- Parallax slider -->
  8. <link rel="stylesheet" href="style/slider.css">
  9. <!-- Flexslider -->
  10. <link rel="stylesheet" href="style/flexslider.css">
  11.  
  12. <link href="style/style.css" rel="stylesheet">
  13.  
  14. <!-- Colors - Orange, Purple, Light Blue (lblue), Red, Green and Blue -->
  15. <link href="style/black.css" rel="stylesheet">
  16.  
  17. <script type="text/javascript" src="layout/whcookies.js"></script>



footer.php (/view/layout/footer.php)
  1. <!-- JS -->
  2. <script src="js/jquery.js"></script>
  3. <script src="js/bootstrap.js"></script>
  4. <script src="js/jquery.isotope.js"></script> <!-- Isotope for gallery -->
  5. <script src="js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto for images -->
  6. <script src="js/jquery.cslider.js"></script> <!-- Parallax slider -->
  7. <script src="js/modernizr.custom.28468.js"></script>
  8. <script src="js/filter.js"></script> <!-- Filter for support page -->
  9. <script src="js/cycle.js"></script> <!-- Cycle slider -->
  10. <script src="js/jquery.flexslider-min.js"></script> <!-- Flex slider -->
  11.  
  12. <script src="js/easing.js"></script> <!-- Easing -->
  13. <script src="js/custom.js"></script>
  14. </body>
  15. </html>
mis
daj / przed każdym js:
  1. <script src="/js/custom.js"></script>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.