Hello
I'm designing my first dynamic website with a simple cms for adding news, articles and products, not so complex. also, my intention is not to use any framework or pre-made cms(like poor man's), just html, css, js and php(this is why I'm here!).
What I'm looking for is simplicity, security and the right approach to design my directory structure and connections. I'm looking for good easy methodology.My website pages (except home page and products), follows cutcodedown layout design, but some pages has no extras(like contact or about pages), and some pages has just one extra in left or right(news and articles pages) and some pages has both side(single article,news,product);
so I made this template to repeat for all pages:
page.php<?php include("header.php");?>
<div class="heightWrapper" id="top">
<?php include("pageHeader.php");?>
<div class="hasLeftExtra mainSection widthWrapper"> // "hasLeftExtra/hasRightExtra" will be added by php if condition
<div id="contentWrapper"><div id="content">
<div class="subSection" id="">
// content will be included here, such as blog.php
<!-- # .subSection --></div>
// php if condition comes here if pagination needed
<div class="pagination">
.
.
.
<!-- .pagination --></div>
<!-- #content, #contentWrapper --></div></div>
// php if condition comes here if extra needed
<div id="extras">
// php if condition comes here for "leftSection"
<div class="leftSection">
// php foreach on each left section extra
<div id="" class="subSection">
// content
<!-- # .subSection --></div>
<!-- .leftSection --></div>
// php if condition comes here for "rightSection"
<div class="rightSection">
// php foreach on each right section extra
<div id="" class="subSection">
// content
<!-- # .subSection --></div>
<!-- .rightSection--></div>
<!-- #extra --></div>
<!-- .mainSection.widthWrapper --></div>
<!-- #top.heightWrapper --></div>
<?php include("footer.html");?>
As it is a multi-language website(
not the cms), the appropriate and easy approach seems to me is to store static commands and contents in separate sql tables. Each part in one table, for example:
all menu items in one table for all language, or:
all articles in one table for all languages, as for other static commands and contents(It has 3 languages). and the url can be same for all languages. let me know about cons of this approach!
The other way is to store all static commands in a php file inside arrays, and for content is to store them in different directory in a file as text.(It seems a nasty way to me!)
so the url could be:
Which one is better?
For cms, I go for few static pages without storing them in sql tables, it is not necessary for a simple cms. There is no complexity and many options in cms. For short cms should be able to add/edit/delete news, articles and products, also reporting about sold products.
Finally, this is the directory I made using Jason Knight outline on
digitalpoint forums answer, the directory of
cutcodedown and a tutorial in
dcblog:
Directory:/theme/themeName/ -- another approach would be removing theme and themeName, putting all theme files(not admin section) in root directory, but I didn't because of what Jason Knight said in
digitalpoint forums answer:
First and foremost is to have a logical directory structure so I don't have to "up-tree" link and to maintain a separation between "content" and "theme" -- just as the HTML and CSS are separation of presentation from content. Having a plan for WHERE you are going to put things can work wonders.
/theme/themeName/template/fonts//theme/themeName/template/images/ -- presentational images
/theme/themeName/template/screen.css/theme/themeName/scripts//theme/themeName/images/ -- content images
/theme/themeName/header.php/theme/themeName/footer.php/theme/themeName/pageHeader.php/theme/themeName/home.php/theme/themeName/products.php/theme/themeName/page.php -- this is the layout for all other pages. bellow files will be included inside main subSection:
/theme/themeName/model/card.php/theme/themeName/model/checkout.php/theme/themeName/model/singleProduct.php/theme/themeName/model/blog.php -- articles and news has same layout for displaying list of posts,
blog.php will be used for both
for example,
blog.php will be something like this:
<h2><?php echo $title ?></h2>
<ul>
<?php foreach ($posts as $post) { ?>
<li><!-- echo post title and summary --></li>
<?php } ?>
</ul>
and for articles page, the
page.php will be used as follows:
page.php<?php include("header.php");?>
<div class="heightWrapper" id="top">
<?php include("pageHeader.php");?>
<div class="hasLeftExtra mainSection widthWrapper">
<div id="contentWrapper"><div id="content">
<div class="subSection" id="articles">
<?php
if ($pageModal == "blog") include("blog.php");
elseif ($pageModal == "singleProduct") include("singleProduct.php");
.
.
.
else echo $pageContent; // for page that totally stored in DB and don't need a model, like contact, about, single article and etc.
?>
<!-- #articles .subSection --></div>
<!-- #content, #contentWrapper --></div></div>
...
sql tables scheme is something like this:
Pages News========= =========
id id
language language
modal modal(
for example: blog, card or none)
url url
title title
content content
leftExtra leftExtra (
for example: Articles, Products)
rightExtra rightExtra (
for example: News)
date
/admin/login.php/admin/index.php/admin/template//admin/... -- other static pages to add/edit/list news, articles, products and etc.
/sources/config.php/sources/functions.php -- functions such as: login, logout, DB connection , DB insert+update+delete(I can also create class for articles,news and products)
/index.php -- what
index.php does is getting url and detect what page should be loaded and what functions should be called to get data from DB.
/setup.phpApologies for length.