Library item: out of date?
- Started
- Last post
- 15 Responses
- welded0
@PSYKHO: You could also use .htaccess to tell the server to parse html as php. Six of one, half a dozen of the other I suppose.
- moth0
Baby steps then Dancer. Loose the selected bit, and get the basics working.
Once you feel the power, you'll sooner of later delve into it further.
- Dancer0
I realise that and I may just ditch the selected bit. If you can really be bothered NB? I don't want you to break your back though...
As moth may know I have attempted PHP a few times but never had the patience or time to succeed. Recently I have found myself coming up against it more and more and feel I should really just give it a go. Perhaps this is what I need. I'm a print designer FFS!!!
So if you can really be arsed then that would be great – if not then I really do not mind.
thanks
- neverblink0
Alistair, that won't work or you will have to make an external navig.php file for each page.. which would defeat the meaning of making it as an external file..
If you want I can write a simple php script tonight which checks on which page it has been called and sets the navig accordingly.
- Dancer0
ok I will have a play.
I have not even checked if the host has php or not – as I have only been sent updates today.
Some of what you guys say makes sense – others I am a little confused.... eg the "selected" bit. I have a class called seletced and added the class to the relevant menu item when I am on that page.
thanks all though
- neverblink0
it's actually better to not use the shorthand php opening tag (because not all servers support those)..
<?php include("assets/php/navig.php"); ?>
(you could also just have navig.html / navig.txt / or whatever, aslong as it is valid markup inside)
and just save that as index.php (or any other page you want the navig to display on).
- moth0
"How do you get the selected / current nav item to display if you use an include?"
In Dancers case, I don't think the site would be set up to do this in an effective fashion.
However, what I would do, and it's kind of painful (but this is a static site), I would use a function to look at the name of the current page and change a menu style accordingly;
if ($myPage == 'location.php') {
echo 'style=\"selected\"';
}
- Dancer0
questions, questions....
I imagine it is quite easy, but I am a simple person: I assume you simply build the nav and save it out as mynav.php and then put
<? include 'mynav.php'; ?> in the div where the nav appears.
and save that out as index.php (if the index)is there more than that on the coding side?
we are actually talking about not as many as 60 pages, but the client does like to swap things around a lot – this is bread and butter work really so I am happy to do whatever she wants.
- That's all you need to do, there's just the issue of highlighting current pages if you want that.jamble
- PSYKHO0
Can we see the site you are talking about? I just want to see how much work you need to do? Also if you go down the php route then you need to use a 301 .htaccess to redirect users from mypage.html to mypage.php so they don't get an error on the .html pages.
Also does this site rank well on Google? Changing the file extension could effect rankings. But not sure about that...
- jamble0
How do you get the selected / current nav item to display if you use an include?
- moth0
It's easy dancer.
Does the server have php?
- moth0
Yeah - simple PHP will save you. It's more efficient than a DW library item.
It's easy too - you just need to call the file by an include;
<? include 'mynav.php'; ?>
or a require;
<? require 'mynav.php'; ?>
Require will fail if the file isn't found.
Include will just throw an error but the page will still load...
- Dancer0
I thought as much....
if only I knew php...
- neverblink0
can you use some backend programming language, like php? Then just cut the page into pieces (header / navig / footer) and make them individual php files which are included in the main page. This way you can have one file for the navigation on all pages.
- Dancer
I designed and built a site a few years ago and the client wishes to add some new nav items. the site has grown itself to be around 60 static pages – no database. and to update every nav bar is going to take a while – especially if I have a "selected" state on the nav item as well.
Are Library items still used today so in the future I just have to change one file instead of all 60 pages? or is there a better and more efficient way of updating a navigation
thanks