Comments (8)
- Short php tags are generally discouraged because of things like xml starting with
<?xml
and ending with?>
as well, however I am not sure how that applies to the short echo tags, but I always do<?php echo $thing; ?>
for compatability and so I feel safe. We should probably make a decision on that. include_once
isn't a function, it's a control structure, so it should be formattedinclude_once 'header.php';
- I don't see why we'd want to stop the header being included twice, good code should do that. No need for PHP to keep track of it, that's for function declarations and the like.
from website.
I agree on 1. & 2., but not for 3. (or I misuderstood it)
let's imagine something like:
Pages
|- home.php
|- 404.php
|- [...].php
Parts
|- header.php
|- footer.php
In Pages we would have all the content + specific meta of the page (title and description) + 1 include at the top (header) and 1 include at the bottom (footer)
In Parts we would have ... parts !
So:
header.php
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="elementary LLC">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" media="all" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300">
<link rel="stylesheet" type="text/css" media="all" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
home.php
<meta name="description" content="elementary OS, a fast and open replacement for Windows and OS X">
<title>elementary OS</title>
</head>
<body>
<div id="content-container">
blablabla...
</div>
footer.php
<footer>
Copyright © 2015 elementary LLC.
<ul>
<li><a href="http://blog.elementaryos.org" target="_blank" title="Tumblr"><i class="fa fa-tumblr"></i></a></li>
<li><a href="https://twitter.com/elementary" target="_blank" title="Twitter"><i class="fa fa-twitter"></i></a></li>
<li><a href="http://reddit.com/r/elementaryos" target="_blank" title="Reddit"><i class="fa fa-reddit"></i></a></li>
<li><a href="https://plus.google.com/114635553671833442612" target="_blank" title="Google+"><i class="fa fa-google-plus"></i></a></li>
<li><a href="https://github.com/elementary/mvp" target="_blank" title="Github"><i class="fa fa-github"></i></a></li>
<li><a href="https://www.facebook.com/elementaryos" target="_blank" title="Facebook"><i class="fa fa-facebook"></i></a></li>
</ul>
</footer>
</body>
</html>
from website.
Yeah, I don't think there's any harm in include_once
. :P We definitely wouldn't ever want the header included more than once, so it makes sense.
@KeitIG, I think I prefer keeping the page's HTML to just within the <body>
tag. It's a lot easier to make sure all the opening/closing tags line up, and it also keeps the variables up top of each page's file so they can be used in several places within the head.
from website.
@lewisgoddard you're right about 1 and 2. Thanks for the heads up (I wrote that code without reference on my break).
from website.
I don't see how you guys disagree with 3.
I would use include 'part.php';
rather than include_once 'part.php';
, that's all. We should never be calling include twice on the header anyway, so PHP shouldn't be using memory keeping track of something that should never happen.
from website.
@lewisgoddard that's fair. If there's a performance benefit for using include
instead of include_once
I have no qualms.
from website.
There is a minor memory reduction, gut multiplied across thousands of release-day requests, it stacks up. A good general rule of thumb is to use it to stop functions and classes being re-declared (which is a fatal error), rather than template control.
from website.
@KeitIG I'm not sure if you've started work on this or not, but for a directory structure, I think this is pretty sensible:
- index.php
- 404.php
- [...any other pages].php
- images/
- [image files]
- styles/
- [css files]
- includes/
- header.php
- footer.php
Feel free to correct me if I'm wrong. :)
from website.
Related Issues (20)
- Upgrade Node HOT 7
- adding dark theme feature HOT 2
- ElementaryOS 6.1 ISO is marked as RC? HOT 2
- Migrate to the latest stripe checkout HOT 7
- Use Stripe Receipt Emails HOT 1
- Document refund policy
- Installation guide recommends Etcher, but Etcher only shows a white screen on elementary OS HOT 1
- Old documentation link in causes confusion in Get Involved (Design) section HOT 7
- HTML theme-color doesn't match the pages
- Create an easy setup with docker for those who contribute HOT 2
- The team page doesn't show any members HOT 4
- Allow verification of the OS download via the website itself HOT 4
- Unable to join slack HOT 6
- Header of website is not responsive HOT 1
- Icons need a minor updates HOT 2
- Buttons need pseudo classes HOT 2
- Facebook ad bundle
- Activating the Download button pops up options at the bottom of the page, but nothing is communicated to the screen reader about this HOT 3
- Remove Twitter functionality from quotes on bottom of elementary.io HOT 1
- 500 error when attempting to sign into builds.elementary.io using GitHub SSO HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website.