PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Links hierarchy maintenance
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Links hierarchy maintenance

Réponse
 
LinkBack Outils de la discussion
Vieux 08/03/2008, 18h23   #1
Adil Drissi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Links hierarchy maintenance

Hi,

I'm working on a site that is becoming more and more
bigger (containing more links). Now the problem of
links maintenance arises. An intuitive idea that i'm
trying to do right know is calling php functions that
will display every part of the site that is
repetitive. For example left side menu and footer. For
the left side menu with static HTML and CSS i'm
disabling the link to the actual page, like that the
user has a visual presentation allowing him to know
where he is exaclty in the site. This introduces more
difficulty for the function that will display the
menu. So i'm wondering if there is some efficient way
of modeling and implementing this.

All suggestions are welcome, and if some part of the
problem is not clear enough please feel free to ask me
more questions if necessary.

Thanks


__________________________________________________ __________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsea...egory=shopping

  Réponse avec citation
Vieux 08/03/2008, 19h24   #2
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

At 9:23 AM -0800 3/8/08, Adil Drissi wrote:
>I'm working on a site that is becoming more and more
>bigger (containing more links). Now the problem of
>links maintenance arises. An intuitive idea that i'm
>trying to do right know is calling php functions that
>will display every part of the site that is
>repetitive. For example left side menu and footer. For
>the left side menu with static HTML and CSS i'm
>disabling the link to the actual page, like that the
>user has a visual presentation allowing him to know
>where he is exaclty in the site. This introduces more
>difficulty for the function that will display the
>menu. So i'm wondering if there is some efficient way
>of modeling and implementing this.
>
>All suggestions are welcome, and if some part of the
>problem is not clear enough please feel free to ask me
>more questions if necessary.


In all of my pages, I use includes. I have one include for the
header, one for the footer and one for the navigation, which is
usually called by the header.

If something changes in navigation, I change one file and it's done
throughout the site.

Look into includes.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 08/03/2008, 23h09   #3
Adil Drissi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Hi,

Yes this is the correct way to do things. As i said,
i'm using different styles for the menus links
indicating the current page. Suppose my page has one
horiontal menu at the top and one vertical menu at the
left. In this case, one element of the horizontal menu
and one from the vertical menu will be displayed
differently from the other elements. So the function
that will be inluded will be more complex to handle
this. I was just wondering, how other poeple are
dealing with that. Of course it is feasable, but i
want to do it the best way.

I hope the problem i posted is clearer now

--- tedd <tedd.sperling@gmail.com> wrote:

> At 9:23 AM -0800 3/8/08, Adil Drissi wrote:
> >I'm working on a site that is becoming more and

> more
> >bigger (containing more links). Now the problem of
> >links maintenance arises. An intuitive idea that

> i'm
> >trying to do right know is calling php functions

> that
> >will display every part of the site that is
> >repetitive. For example left side menu and footer.

> For
> >the left side menu with static HTML and CSS i'm
> >disabling the link to the actual page, like that

> the
> >user has a visual presentation allowing him to know
> >where he is exaclty in the site. This introduces

> more
> >difficulty for the function that will display the
> >menu. So i'm wondering if there is some efficient

> way
> >of modeling and implementing this.
> >
> >All suggestions are welcome, and if some part of

> the
> >problem is not clear enough please feel free to ask

> me
> >more questions if necessary.

>
> In all of my pages, I use includes. I have one
> include for the
> header, one for the footer and one for the
> navigation, which is
> usually called by the header.
>
> If something changes in navigation, I change one
> file and it's done
> throughout the site.
>
> Look into includes.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com
> http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>




__________________________________________________ __________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

  Réponse avec citation
Vieux 09/03/2008, 08h59   #4
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Links hierarchy maintenance

Store the links in a tree. That way you can easily print the active
link using a different style.

This script below demonstrates how to create and print a simple nav
tree.

[nav.php]
<?

error_reporting(E_ALL);

class LinkNode
{
var $url;
var $title;
var $nodes;
var $parent;

function LinkNode($url = '', $title = '')
{
$this->url = $url;
$this->title = $title;
$this->nodes = array();
$this->parent = null;
}

function &add(& $node)
{
$node->parent =& $this;
$this->nodes[] =& $node;
return $node;
}

function &findUrl($url)
{
if ($this->url == $url) {
return $this;
}
foreach ($this->nodes as $node) {
$match =& $node->findUrl($url);
if (!is_null($match)) {
return $match;
}
}
$null = null;
return $null;
}
}

class MyNav
{
var $nav;
var $activeUrl = null;

function bind()
{
$this->nav = new LinkNode('/', 'Home');

$sv = new LinkNode('/services/', 'Services');

$bus = new LinkNode('/services/business/', 'Business');
$bus->add(new LinkNode('/services/business/construction.php',
'Construction'));
$sv->add($bus);

$res = new LinkNode('/services/residential/', 'Residential');
$res->add(new LinkNode('/services/residential/renovation.php',
'Renovation'));
$sv->add($res);

$this->nav->add($sv);

$this->nav->add(new LinkNode('/contact.php', 'Contact'));
}

function render()
{
if (is_null($this->activeUrl)) {
$this->activeUrl = $_SERVER['REQUEST_URI'];
}
$node =& $this->nav->findUrl($this->activeUrl);
if (is_null($node)) {
$node =& $this->nav;
}
$path[] =& $node;
if (!is_null($node->parent)) {
$path[] =& $node->parent;
if (!count($node->nodes) && !is_null($node->parent->parent)) {
$path[] =& $node->parent->parent;
}
}
$str = "<div id=\"navPart\">\n";
$str = "<ul id=\"nav\" class=\"level1\">\n";
$str .= $this->renderNode($path[count($path) - 1], $path);
$str .= "</ul>\n</div>\n";
return $str;
}

function renderNode(& $node, & $path, $max = 2, $level = 1)
{
$showChildren = false;
if ($level < $max) {
$showChildren = true;
} else {
for ($i = 0; $i < count($path); $i++) {
$el =& $path[$i];
if ($el->url == $node->url) {
$showChildren = true;
}
}
}

$str = '';
if ($node->title != '') {
$str .= "<li class=\"level${level}\"";
if ($node->url == $this->activeUrl) {
$str .= ' class="active"';
}
$str .= "><span class=\"level${level}\"><a";
if ($node->url == $this->activeUrl) {
$str .= ' class="active"';
}
$str .= " href=\"{$node->url}\">{$node->title}</a></span>\n";
}

if ($showChildren) {
$next = $level + 1;
$str .= "<ul class=\"level${next}\">\n";
foreach ($node->nodes as $child) {
$str .= $this->renderNode($child, $path, $max, $next);
}
$str .= "</ul>\n";
}

if ($node->title != '') {
$str .= "</li>\n";
}

return $str;
}
}

$nav = new MyNav;
$nav->bind();
$nav->activeUrl = '/services/';

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Wtcl</title>
<style type="text/css">
#nav {
width: 200px;
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, Sans-Serif;
font-size: 14px;
font-weight: normal;
}

#nav ul {
margin-left: 0;
padding-left: 0;
list-style-type: none;
}

#nav a {
display: block;
padding: 3px;
background-color: #003366;
border-bottom: 1px solid #eeeeee;
}

#nav a:link, #nav a:visited {
color: #eeeeee;
text-decoration: none;
}

#nav a:hover {
background-color: #336699;
color: #ffffff;
}

#nav span a.active {
color: #ffff00;
}

#nav span.level1 a {
background-color: #336699;
border-bottom: 1px solid #eeeeee;
color: #ffffff;
font-size: 14px;
}

#nav span.level2 a {
font-size: 14px;
}

#nav span.level3 a {
font-size: 12px;
padding-left: 17px;
}
</style>
<link rel="stylesheet" href="/site.css" type="text/css" />
</head>
<body>

<?= $nav->render(); ?>

</body>


On Mar 8, 5:09 pm, adil.dri...@yahoo.com (Adil Drissi) wrote:
> Hi,
>
> Yes this is the correct way to do things. As i said,
> i'm using different styles for the menus links
> indicating the current page. Suppose my page has one
> horiontal menu at the top and one vertical menu at the
> left. In this case, one element of the horizontal menu
> and one from the vertical menu will be displayed
> differently from the other elements. So the function
> that will be inluded will be more complex to handle
> this. I was just wondering, how other poeple are
> dealing with that. Of course it is feasable, but i
> want to do it the best way.
>
> I hope the problem i posted is clearer now
>
>
>
> --- tedd <tedd.sperl...@gmail.com> wrote:
> > At 9:23 AM -0800 3/8/08, Adil Drissi wrote:
> > >I'm working on a site that is becoming more and

> > more
> > >bigger (containing more links). Now the problem of
> > >links maintenance arises. An intuitive idea that

> > i'm
> > >trying to do right know is calling php functions

> > that
> > >will display every part of the site that is
> > >repetitive. For example left side menu and footer.

> > For
> > >the left side menu with static HTML and CSS i'm
> > >disabling the link to the actual page, like that

> > the
> > >user has a visual presentation allowing him to know
> > >where he is exaclty in the site. This introduces

> > more
> > >difficulty for the function that will display the
> > >menu. So i'm wondering if there is some efficient

> > way
> > >of modeling and implementing this.

>
> > >All suggestions are welcome, and if some part of

> > the
> > >problem is not clear enough please feel free to ask

> > me
> > >more questions if necessary.

>
> > In all of my pages, I use includes. I have one
> > include for the
> > header, one for the footer and one for the
> > navigation, which is
> > usually called by the header.

>
> > If something changes in navigation, I change one
> > file and it's done
> > throughout the site.

>
> > Look into includes.

>
> > Cheers,

>
> > tedd

>
> > --
> > -------
> >http://sperling.com http://ancientstones.com
> >http://earthstones.com

>
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:http://www.php.net/unsub.php

>
> __________________________________________________ __________________________________
> Never miss a thing. Make Yahoo your home page.http://www.yahoo.com/r/hs


  Réponse avec citation
Vieux 09/03/2008, 12h05   #5
Per Jessen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Adil Drissi wrote:

> Hi,
>
> Yes this is the correct way to do things. As i said,
> i'm using different styles for the menus links
> indicating the current page. Suppose my page has one
> horiontal menu at the top and one vertical menu at the
> left. In this case, one element of the horizontal menu
> and one from the vertical menu will be displayed
> differently from the other elements. So the function
> that will be inluded will be more complex to handle
> this. I was just wondering, how other poeple are
> dealing with that. Of course it is feasable, but i
> want to do it the best way.


CSS ? If that's not enough to alter the display, you need to make your
includes sensitive to or aware of the context they're being included
in.


/Per Jessen, Zürich

  Réponse avec citation
Vieux 09/03/2008, 17h03   #6
Adil Drissi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Hi Jessen,

The question is how to make it aware of the context.
Do you know any work dealing with that?

Thanks

--- Per Jessen <per@computer.org> wrote:

> Adil Drissi wrote:
>
> > Hi,
> >
> > Yes this is the correct way to do things. As i

> said,
> > i'm using different styles for the menus links
> > indicating the current page. Suppose my page has

> one
> > horiontal menu at the top and one vertical menu at

> the
> > left. In this case, one element of the horizontal

> menu
> > and one from the vertical menu will be displayed
> > differently from the other elements. So the

> function
> > that will be inluded will be more complex to

> handle
> > this. I was just wondering, how other poeple are
> > dealing with that. Of course it is feasable, but i
> > want to do it the best way.

>
> CSS ? If that's not enough to alter the display,
> you need to make your
> includes sensitive to or aware of the context
> they're being included
> in.
>
>
> /Per Jessen, Zürich
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>




__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i...Dypao8Wcj9tAcJ


  Réponse avec citation
Vieux 09/03/2008, 17h57   #7
Per Jessen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Adil Drissi wrote:

> Hi Jessen,
>
> The question is how to make it aware of the context.
> Do you know any work dealing with that?


Variables? Set a variable $context= before you include, then have your
include check on $context.


/Per Jessen, Zürich

  Réponse avec citation
Vieux 10/03/2008, 01h09   #8
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

>Yes this is the correct way to do things. As i said,
>i'm using different styles for the menus links
>indicating the current page. Suppose my page has one
>horiontal menu at the top and one vertical menu at the
>left. In this case, one element of the horizontal menu
>and one from the vertical menu will be displayed
>differently from the other elements. So the function
>that will be inluded will be more complex to handle
>this. I was just wondering, how other poeple are
>dealing with that. Of course it is feasable, but i
>want to do it the best way.
>
>I hope the problem i posted is clearer now


Two menus, do you mean like this:

http://webbytedd.com/clients/beckysc...ut-company.php

It's still just css and php -- simply a logic problem.

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 10/03/2008, 03h13   #9
Adil Drissi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Yes like that, but you can consider also that the
vertical menu has different style for the link of the
current page. Anyway it does not matter for this
problem. Can you show us how your php function looks
like? Or maybe you are just doing a test for each link
for your function to know if it is the link that
should be displayed differently. I was wondering if
there is a way to do the same thing without the
overhead of all that "if " statements.

--- tedd <tedd.sperling@gmail.com> wrote:

> >Yes this is the correct way to do things. As i

> said,
> >i'm using different styles for the menus links
> >indicating the current page. Suppose my page has

> one
> >horiontal menu at the top and one vertical menu at

> the
> >left. In this case, one element of the horizontal

> menu
> >and one from the vertical menu will be displayed
> >differently from the other elements. So the

> function
> >that will be inluded will be more complex to handle
> >this. I was just wondering, how other poeple are
> >dealing with that. Of course it is feasable, but i
> >want to do it the best way.
> >
> >I hope the problem i posted is clearer now

>
> Two menus, do you mean like this:
>
>

http://webbytedd.com/clients/beckysc...ut-company.php
>
> It's still just css and php -- simply a logic
> problem.
>
> Cheers,
>
> tedd
>
>
> --
> -------
> http://sperling.com http://ancientstones.com
> http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>




__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i...Dypao8Wcj9tAcJ


  Réponse avec citation
Vieux 10/03/2008, 10h57   #10
Per Jessen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

Adil Drissi wrote:

> should be displayed differently. I was wondering if
> there is a way to do the same thing without the
> overhead of all that "if " statements.


If you're using PHP (or any other interpreted language) overhead is a
fact of life, there's little you can do about it.


/Per Jessen, Zürich

  Réponse avec citation
Vieux 10/03/2008, 21h45   #11
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Links hierarchy maintenance

At 6:13 PM -0700 3/9/08, Adil Drissi wrote:
>Yes like that, but you can consider also that the
>vertical menu has different style for the link of the
>current page. Anyway it does not matter for this
>problem. Can you show us how your php function looks
>like? Or maybe you are just doing a test for each link
>for your function to know if it is the link that
>should be displayed differently. I was wondering if
>there is a way to do the same thing without the
>overhead of all that "if " statements.
> >
>> Two menus, do you mean like this:
>>
> >

>http://webbytedd.com/clients/beckysc...ut-company.php



No offense meant, but if you're concerned about the "if" overhead
then I question if you would understand how the double menu works.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h36.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,28714 seconds with 19 queries