homepage Welcome to WebmasterWorld Guest from 23.20.19.131
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

    
Site Navigation Using Server Side Includes
Thinking through SSI and HTML duplicity question
Jetgirl




msg:3538267
 5:10 am on Jan 1, 2008 (gmt 0)

I text/hand edit my sites, and have been looking to make some smart changes that will allow me to centralize site navigation should the day come I need to change my global navigation links (aka change site navigation link order, or add/hide navigation links, etc.). Server side includes seem to be the way to go based on all my research - I have even tested it out and made sure it will work on my server.

My question is based on the way I currently display contextual awareness of location on the site in the navigational structure. I have been using CSS to have an additional style that is triggered by a class or id tag that is flagged for the page the user is on. I don't want to have an SSI page for every page on my site (the goal here is to simplify!), so the only way I can currently think of keeping this feature is to have a duplicate HTML call for the tag that needs to be called as active still reside in the native page HTML.

I believe that even with this duplicity, if a global navigation change is made, the number of actual HTML pages touched would be greatly reduced, but I'm just trying to think as much ahead as I can before I roll out any big changes (including the implementation of SSI).

Generic Example:

SSI would call
<a class="location1" href="example.com/subdirectory1">Subdirectory1</a>
<a class="location2" href="example.com/subdirectory2">Subdirectory2</a>

but HTML would recall
<a id="current" class="location1" href="example.com/subdirectory1">Subdirectory1</a>

thus the navigation as seen by a bot would be
<a class="location1" href="example.com/subdirectory1">Subdirectory1</a>
<a class="location2" href="example.com/subdirectory2">Subdirectory2</a>
<a id="current" class="location1" href="example.com/subdirectory1">Subdirectory1</a>

So, I guess I have 2 questions about this:
1) Would the search bots be upset to see this kind of duplicity in the HTML (which is all they will see), and
2) Is there something clever that I'm missing that would help provide contextual awareness in a more meaningful and less repeatitive manner?

 

Marcia




msg:3538274
 5:48 am on Jan 1, 2008 (gmt 0)

What I'd suggest is looking into using PHP includes rather than SSI. They work the same way, but you have the additional benefit of being able to add functionality to pages & sites - and different sections - with some conditional programming logic. And add a number of oher automated features also, without being a "programmer" as such.

To be perfectly honest, I haven't see much in the way of discussion on SSI for a long, long time; but there is a huge amount on PHP; in fact, there's a whole forum here dedicated to PHP that's very active and helpful.

>contextual awareness in a more meaningful and less repetitive manner?

If it's section one, do "this."
If it's section two, do "that."
If it's section three, do "the other thing."

No repetition, it can be section specific for each one.

Marcia




msg:3538279
 6:21 am on Jan 1, 2008 (gmt 0)

SSI would call
<a class="location1" href="example.com/subdirectory1">Subdirectory1</a>
<a class="location2" href="example.com/subdirectory2">Subdirectory2</a>

but HTML would recall
<a id="current" class="location1" href="example.com/subdirectory1">Subdirectory1</a>


HTML has no way to recall something in particular for different pages unless it's put onto the pages by the coder or some programming is used. HTML is just markup, there's no conditional processing or programming logic to HTML that would know where to put the id=.

Here, take a look at this post about using includes for meta tags

[webmasterworld.com...]

You can have the styles for navigation that varies from section to section in a separate stylesheet, and "include" the proper one right after the tag including your global stylesheet.

>>first thing on the page, before even the DOCTYPE declaration, you would put:

<?php
$sectionstyle1="where the section 1 navigation styles are";
// Other variables you need for the page
?>

Then you either use $sectionstyle1 with a PHP statement to include the proper stylesheet (just like you link to filename.css now, or print the section's styles as imbedded styles right into the <head> section of those pages.

However, I think it's getting mixed up here between CSS (for styling) and using includes (SSI or PHP) for the HTML in navigation for different sections (I am anyway). They're two different things.

I have a site now being re-worked for both CSS and with adding bits of PHP for automating a number of routine tasks, that has different "section" navigation for each of the different sections. Let's say one site section is seo and another is design. I just put this up and it works just fine.

Very first thing on the page - the HTML page itself, which still has its .html file extension, is

<?php
$sectionnav = "seoNav.php";
?>

Then, exactly in the spot where I want that navigation to be I put

<?php include "$sectionnav";?>

The HTML code for the navigation, including id and class selectors, is in seoNav.php and gets put on the page server-side before it's ever delivered to a browser or a bot. The formatting for styling is done in the CSS. For the design section, it'll be "designNav.php" instead of "seoNav.php" - and I can't think of anything simpler. I don't think this can be done using SSI.

[edited by: Marcia at 7:10 am (utc) on Jan. 1, 2008]

coopster




msg:3538338
 1:51 pm on Jan 1, 2008 (gmt 0)

My question is based on the way I currently display contextual awareness of location on the site in the navigational structure. I have been using CSS to have an additional style that is triggered by a class or id tag that is flagged for the page the user is on.

PHP (or any server-side language) makes this an easy job. You don't have to modify code, you don't have to add special id's to the <body> element, ... you won't even have to modify your CSS! Have a look at the concept introduced in this old thread:
Hiding hyperlinks for page displayed [webmasterworld.com].

Jetgirl




msg:3538458
 7:01 pm on Jan 1, 2008 (gmt 0)

Thank you!

I am not sure just what I though PHP was, but I had been avoiding looking into it... PHP is, however, perfect for what I want to do. Thanks for the push over the edge - I even have it implemented and working!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved