Reply to Re: 'nested conditional' that can identify parent page?

Your name:

Reply:


Posted by Alan Jones on 05/14/07 02:09

On 13 May 2007 18:42:28 -0700, shimmyshack <matt.farey@gmail.com>
wrote:

>if you will need signature included for a set of files you know in
>advance you could do this
>(this example works for all index.php filenames because it uses
>basename, if you need/want to specify filenames by their paths then
>remove the basename part, and specify the files in the array including
>their paths
>$arrFileNamesWhereSignatureShouldAppear = array(
>'index.php',
>'contact.php'
>);
>if( in_array(basename($_SERVER['PHP_SELF']),
>$arrFileNamesWhereSignatureShouldAppear) )
>{
> include('signature.php');
>}
>
>remember that this is NOT the simple way. All this might appear
>simple, but the rub comes later when you relise you have to rewrite
>everything to do something that would have been simple if you had
>committed to the learning curve earlier.
>You are encouraged to look at best practise examples and follow along,
>before thinking you can rewrite the book with "5 minute home brew
>architecture" trust me I learned this way too!
>
>for instance here's a better way to include stuff. (still old style
>non Object Oriented)
>
>mainpage.php
><?php
>#find page you are on from request uri
>include('functions.php');
>$arrayPageParts = get_page_info( $_SERVER['REQUEST_URI'] );
>?>
><?php
>#css just for this page
>echo $arrayPageParts['css'];
>'js just for this page
>echo $arrayPageParts['js'];
>?>
>styles/js for everypage go here
><html><head>
><title><?php echo $arrayPageParts['title']; ?></title>
><?php echo output_meta_tag( $arrayPageParts['description']; ?>
><meta tags: language, description, keywords, etc...
><!--some comment-->
></head><body>
><?php
>#this ['body'] could instead be
>['menu']
>more html...
>['content']
>etc.. so that more html is in the template, and content elsewhere
>try to make as little php and html mix as possible, have a template
>which is all the html you need, and fill with pure content
>echo $arrayPageParts['body']; ?>
><?php echo $arrayPageParts['signature'];
>#which of course is not there if the $page leads to this being null
> ?></body></html>
>
>I mean this is by no means the right way of coding, but it is a very
>simple "template"
>
>the idea of includes can be useful but not as usefule as functions
>which get the data and return it into an array
>
>Once again, this might be arguably better, its no OO hMVC pattern but
>hey it's better than writing condition includes in the main page, keep
>on abstracting away your code into functions and return a array of
>paragraphs, menu content etc.. free of html, and use while loops and
>so on..
>this way if you redesign the site, you just redesign the template, and
>the content can come from a db or flat files or another website, you
>dont care, and that makes it easy to add pages...
>
>anyway matt out.

Thanks, I'll digest all that over time, as I continue learning. :)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация