#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    364
    Rep Power
    12

    Question PHP to Javascript


    Presently a site consists of htm pages. These pages now need to run a PHP script to dynamically create a table of contents. However this means that the site pages have to be converted from htm pages to php pages. The problem with that is the template connectivity is lost in doing so.

    I was wondering if the same script could be written using Javascript, since the htm pages already use a shopping cart in JS and donot need conversion to run the script.

    I havent coded in JS before and dont know if there are JS equivalents to PHP's fgetcsv(), ImageCopyResampled()...etc functions which are needed to read the contents of a csv file and thunbnail an image.

    Would appreciate all suggestions. Thanks.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Italy, EU
    Posts
    517
    Rep Power
    12
    I'm not sure you can use JS to do the same thing... A problem I can fix at a first sight is that the PHP function fgetcsv() uses a file pointer to access a file resident on the server while JS, being client-side, cannot operate on files on the server...

    Good luck, Magma
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Right, magma brought up the biggest sticking point: client-side versus server side.

    You can though generate a functional table of contents in javascript. It's actually quite simple, but the caveat is all the information needs to somehow be available to the client-side scripts. Either somehow embed on the html page, or make it downloadable through other pages. Making the information available may just as easily break your 'template connectivity' though.
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    364
    Rep Power
    12
    Thanks magma , MJEggertson. I think PHP would be the easier way to go to do what needs to be done for the table of conrents (resize image...etc) . Template connectivity will have to be sacrificed for this.

    Guess only other way is to generate the ENTIRE page using php, includung the standard sitewide elemsnts. Thus the php script that does such generating would be the 'template' so to speak and there will be only one script. Any alterations would be site wide if done on this script.

    Unless there is ANY other was of doing a site with php and maintianing the templates?????
    Last edited by PHPme; May 31st, 2003 at 05:10 PM.

IMN logo majestic logo threadwatch logo seochat tools logo