Wednesday, October 21, 2009

PHP include and JavaScript

2 weeks to go...

Yesterday lecture was on more JavaScript and AJAX. There are alot of these fancy things that JavaScript can do which I still need to get my head around. I'm afraid time is running out for me to complete the final report and the project..=(

I'm planning to package the final report together and create a mini website with links to all the reports we need to hand in. I've learnt a few tricks of using PHP to include my navigation on every page so I can have my navigation in a separate file (e.g. nav.html) and use PHP command to include that file in every page. The advantages of this of course, if you decide you want to change your navigation, you only need to do it once in your navigation file. Alastair helped me with the code which actually pretty simple. All you need to do is to include the function called "include ("your file name here") inside the php tag.

And make sure you then save your file to .php files instead of .html file to make the code works.

The other thing I was trying to experiment with is to have a drop-down navigation menu or more like an accordion menu. Alastair showed similar behaviour I'm trying to recreate during the lecture, but it doesn't work for my menu. I'm going to do more research on the JQuery library and see if I can find something there to make them work.

As for the project, I think I'm happy with the state it was in now. I just need to figure out how to upload it and install it to the server.


So this week would mainly be finalising the project and trying to finish up my report as much as I can.

3 comments:

  1. For a while I was changing the menu on every single HTML page, and I had no idea that there was a better way to do it. After discovering "include" a while back, I have a lot of my code structured in that way now. Its a bit more confusing having these extra files to deal with, but in the big picture it has saved me a lot of time and also its better in terms of changing common elements of each page very easily.

    Regs
    Michael

    ReplyDelete
  2. Hi Vera. I'm doing the same thing - using little PHP files for my menu. I've also done the same thing for the header (or masthead) of the site. It just saves so much time if you need to make changes in the future! Yay!!

    Tammy

    PS. I took your advice on the side menu text colour. It's looking a lot better now.

    ReplyDelete
  3. Looks like this is something that I should have been doing from the start as well. Thanks for the tips on PHP and navigation. I am not sure if I will backtrack as it were at this point but it's certainly good to know for the future.
    Cheers
    Lisa

    ReplyDelete