php mvc template asset path?

Discussion in 'PHP' started by nile1483, Sep 13, 2011.

  1. #1
    Hi,

    I am developing custom MVC application, in View folder i placed multiple templates, to access html asset(css and images), i have to write actual path every time (e.g. <?php $baseurl;./logo.jpg), plz let us know how can get path relative path in view/templatename folder.
     
    nile1483, Sep 13, 2011 IP
  2. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #2
    you should put your assets (js, css and images) in the web root directory.. so you can access them freely like /js/myjavascriptfile.js, /css/stylessheet.css or /images/logo.jpg
     
    JohnnySchultz, Sep 14, 2011 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    I wouldn't use the relative path, or the root (since the root assumes the script will always be running from the root path). Far better to set a constant with the path and preceed all your images, css, js etc. Then it can be easily re-configured if need be.
     
    mfscripts, Sep 14, 2011 IP