RE: How can I?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What's the lowest common factor in how changes are applied?   If
everything created in "/company/" is going to have the same style, same
left hand navigation, etc... And everything in "/clients/" is going to
have the same style, same left hand navigation, etc...  Then I'd
recommend something like this:

/company/
--> index.php
--> contact.php
--> stylesheet.css
--> navigation.php

/customer/
--> index.php
--> profile.php
--> stylesheet.css
--> navigation.php

/tips/
--> index.php
--> stylesheet.css
--> navigation.php




And have each index.php just point to "stylesheet.css" and
"navigation.php".  I'm assuming your navigation is in a frame, but even
if it isn't, you can do an include() or something to pull the
navigation.php file into your main script.

Any changes made to navigation.php will affect all files within that
folder since they're all going to point to "navigation.php", a relative
reference to the local navigation.php file.

Same with stylesheet.css.  Any changes made to the one in that folder
will apply to all files in that folder.


So when you dynamically create stuff via PHP (or even if they manually
create regular HTML files), just give them a template to use.  Say
"start with this, don't change anything in it, just add content where it
says ti add content".  Or if they create pages dynamically via PHP, then
take the data they enter and insert it into the PHP via your script.


Another option would be to store a config file either in your root
folder or in each sub-folder.  If it was in INI style format, it might
be something like this:


[Company]
Style="/stylesheets/companystyle.css
"Nav=companynav.php
HeaderText="<h1>Company</h1>"

[Customers]
Style="/stylesheets/customerstyle.css"
Nav=customernav.php
HeaderText="<h1>Customers</h1>"



Or create your own custom config file:


[Company]
--Style
<style> ....  Take everything after "--Style" and before the next "--"
tag and insert it as style information</style>
--Navigation
<table>
  <tr>
    <td>Some navigation links maybe in a table or something</td>
  </tr>
</table>
--Header
<h1> Some company header text</h1>



Then you could have all the styles, headers, navigation information,
etc... All in one file and you just parse the data using PHP looking for
the [Tag] that matches the folder name.




I'd probably just put individual "stylesheet.css" and "navigation.php"
and "headerinclude.inc.php" files in the individual folders myself.  If
I needed to be able to edit them all in one place, I'd write a PHP
configuration management script that got a list of all the folders in
the root folder, then looked for the config files in each folder.


If you make it dynamic, by just making all your scripts look for a
"navigation.php" in the current folder, then you can copy a whole
folder, make a couple of little changes, and it all works just fine.
If you have all your configuration stuff in one file, you can copy a
section, but what if you make a typo in the name.  Or what if you forget
to put a closing "]" on a section heading, or mis-paste something.  Then
it could affect all the other style sheets and navigation page
information for all the sections after the typo (depending on how you
parse the config file).

What happens if someone else is called in to work on your stuff.... Or
you leave your job and another programmer has to pick up where you left
off.  If they don't notice that you have a config file somewhere and
they just move the folders, they may not figure out right away what's
wrong.  I like the idea of a folder being as self contained as possible.
I only use root folder config files or things when it's something that's
reused for the entire site.    Like I use an "/includes/" folder that
has some commonly used PHP scripts for date conversion, activity
logging, database abstraction stuff, etc.  I also tend to use a
"/images/" folder for commonly used navigation images, logos, etc.
Anything specific to a certain section or folder, I put within that
folder.

I like to my make my scripts kind of dumb and modular.


Now going back to the question I asked at the beginning of this email.
How specific are these changes you're talking about?   Are they specific
to the folder or will there be files within the folder that have
different stylesheets, navigation, headers, etc?   It doesn't sound like
it.  Sounds like each folder has it's own set of nav, style and header
that is used for all files/scripts within that folder.


I want to point out that this is becoming a question of style and
preference.  This is how I'd do it, but it may not be the best way for
YOU to do it for YOUR style.  Don't take my statements as "I'm right,
you're wrong" type stuff.  Just trying to point out why I would do it
the way I'd do it.  But there are a ton of ways to do what it sounds
like you need.  I'm trying to present as many options as I can for you
to consider.  But there's definitely a method that I think is 'best',
but that's my style and my opinion.


Get creative!  PHP is so powerful and flexible that just about any
scheme you come up with can be made to work.  If you decide later that
you want to do it a different way, then you can always go back and
update it.

We grow and learn by experimenting and failing and trying new things.
Don't be afraid to just pick a method and go with it.  If you find out
later that you don't like it or that it doesn't work the way you need it
to, go back and try something else. :)

-TG



> -----Original Message-----
> From: Tony Devlin [mailto:tdevlin@xxxxxxxxxxxxx] 
> Sent: Monday, November 22, 2004 12:16 PM
> To: Php-Windows
> Subject: RE:  How can I?
> 
> 
> Well it's not "just" stylesheet changes.  We have links that 
> are different
> for the different folders.  For example we have a left navigation bar,
> those links displayed there will change based on the 
> directory, as well as a
> couple H1 tags that display some basic info that differs directory
> to directory.   It's awhole lot easier to have all this in 
> one file and then
> switch the output based on the directory location, then it is to have
> seperate files for each, not to mention in an dynamic page 
> where everything
> on that page is changeable, how do you add the proper link to
> that stylesheet or function page? .. Sure you could fopen the 
> page after
> it's been created and then fwrite the link in, but you'd still need a
> switch to know what link to fwrite in and opening sockets 
> like that is just
> an invite to trouble.
> 
> Atleast thats my opinion on the matter.  Remember they can 
> create pages on
> the fly, and these people who create the pages are how do we
> say, HTML challenged?  I think thats the politically correct term.
> 
> Thanks,
> 
> Tony D.
> 
> -----Original Message-----
> From: Gryffyn, Trevor [mailto:TGryffyn@xxxxxxxxxxxxxxxxx]
> Sent: Monday, November 22, 2004 11:48 AM
> To: Php-Windows
> Cc: tdevlin@xxxxxxxxxxxxx
> Subject: RE:  How can I?
> 
> 
> I think you're over-thinking this one or maybe doing it the hard way.
> 
> If everything in a particular folder is always going to have the same
> theme, then just put the stylesheet in that folder and 
> references it in
> the HTML you output.
> 
> "localstyle.css"
> 
> Something like that.
> 
> If you want to be able to have 'themes', then dynically alter the
> filename vial PHP:
> 
> 
> "$themename-localstyle.css"
> 
> 
> You could do the same thing with getting the directory name and using
> that like you'd use a $themename.
> 
> Anyway, that's what I'd do instead of worrying about switch statements
> and all.
> 
> Would that work for what you're trying to do?
> 
> -TG
> 
> > -----Original Message-----
> > From: Tony Devlin [mailto:tdevlin@xxxxxxxxxxxxx]
> > Sent: Monday, November 22, 2004 11:20 AM
> > To: Php-Windows
> > Subject: RE:  How can I?
> >
> >
> > The reasoning for this is so that I can apply different
> > stylesheets and
> > formatting to different pages inside a specific site.  The
> > entire site is
> > dynamic and changeable, they can add pages/subtract pages,
> > etc.. so the
> > layout information needs to be controlled on the header 
> page, the only
> > static/untouchable page.
> >
> > Let's say everything in compayn folder is blue text, but I
> > want everything
> > in the customer folder to be green text.  How do you control
> > that when you
> > have dynamic pages? .. easy you find a way to establish what
> > your path is,
> > check it against known paths, if it exists use a certain
> > stylesheet.  There
> > may be an easier way to do this than switches, but I have yet
> > to find one.
> >
> > Tony
> >
> >
> > -----Original Message-----
> > From: Gryffyn, Trevor [mailto:TGryffyn@xxxxxxxxxxxxxxxxx]
> > Sent: Monday, November 22, 2004 11:11 AM
> > To: Php-Windows
> > Cc: tdevlin@xxxxxxxxxxxxx
> > Subject: RE:  How can I?
> >
> >
> > I'm not quite sure what you're asking for here, but let me
> > take a shot:
> >
> > Do you want the scripts in, say, your index.php's to know 
> what folder
> > they're in and act accordingly?
> >
> > So you'd essentially have exactly the same index.php in 
> every folder,
> > but they would do different things depending on if they were in
> > /company/ or in /customer/ or in /tips/?
> >
> > If so, you could get the SCRIPT_NAME from the server
> > variables, then use
> > the dirname() function and some parsing to get the last 
> directory name
> > in the path.  But that seems to lead to the "too many SWITCH
> > statements"
> > thing that you're trying to avoid.
> >
> > Maybe if you could clarify what you're trying to do, it 
> might help us
> > determine the best course of action.
> >
> > -TG
> >
> > > -----Original Message-----
> > > From: Tony Devlin [mailto:tdevlin@xxxxxxxxxxxxx]
> > > Sent: Monday, November 22, 2004 9:20 AM
> > >
> > > Onto the real question.  I'm trying to make a switch
> > > statement that switches a header file based upon
> > > what folder you are in...
> > >
> > > An example:
> > >
> > > Let's say I have 3 folders with some files inside.
> > >
> > > /company/
> > >  --> index.php
> > >  --> contact.php
> > >
> > > /customer/
> > >  --> index.php
> > >  --> profile.php
> > >
> > > /tips/
> > >  --> index.php
> > >
> > >
> > > Basically instead of building a huge switch with EVERY full
> > > path file name included,  I want to just make a switch based
> > > on folder, then every file inside that folder will have
> > > the switch applied to it.  I am sure this is
> > > possible, anyone have any ideas about how to do this?
> > >
> > > Greatly appreciated,
> > >
> > > Tony Devlin

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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux