6 Replies - 545 Views - Last Post: 26 February 2011 - 03:39 PM Rate Topic: -----

#1 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

[Theory]create/edit/delete files.

Posted 25 February 2011 - 02:36 PM

Hey,

I am looking to build a simple CMS, but i have got stuck on the part of managing pages, and haven't been able to find what im after through google.

Basically, as part of the admin, i want to be able to create new pages, edit them, and delete them, but i'm not sure how to go about this. Would i store the websites 'pages' in a database , but how would i put them to use? or would i physically create the .php file for a page, and have it added to a menu, but how would i automatically add this to a menu?

Or would i be best using a mixture of both?

Itcase it seems that way, i'm not after the code, just the best way to do this, so i can have a go myself.
Thanks :)

Is This A Good Question/Topic? 0
  • +

Replies To: [Theory]create/edit/delete files.

#2 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: [Theory]create/edit/delete files.

Posted 25 February 2011 - 02:44 PM

Create a few PHP pages that read the database and are dynamically driven.

Create a Site Menu by reading the pages in the DB.

It can be very complex or very simple, depends on your style of coding and security standards.

DB
{
tblPages
|- PageTitle
|- MenuTitle
|- MetaKeys
|- MetaDesc
|- PageContent

tblSiteSettings
|- HeaderCode
|- FooterCode
|- SideCode
}

Idk, whatever you want, I am boerd so I am throwing it out there.
Was This Post Helpful? 2
  • +
  • -

#3 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: [Theory]create/edit/delete files.

Posted 25 February 2011 - 03:06 PM

Hey, Basically i'm starting this around a template system, using:
$page->replace_tags(array(
  "title" => "page_title",
  "descript" => "page_description",
  "main" => "page_main_area",
  "menu" => "page_menu",
  "left" => "page_left_column",
  "right" => "page_right_column",
  "footer" => "page_footer"
));


to replace {} tags in the template with what i want there.

So for a blog, "main" would call /lib/blog.php (whereas this would be in blog.php in root). Whereas most the tags will be the same for every page, main will change, and its the part that will go into main that i'm wanting to be able to change via a 'create/edit/delete pages' section of the admin area.

I was thinking i should store the 'main' code to go elsewhere, as there will be a fair amount, which is why i have /lib, to put the frontend files. So would i use a wysigg editor to save "main" as a link to where the main content would be, and add the page to a database, using the databse to build a menu? Or am i going about this in completely the wrong way?
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: [Theory]create/edit/delete files.

Posted 25 February 2011 - 05:21 PM

The way that most CMSes work is, as mentioned, via the database.

You'd generally have a core file, or a landing file which will handle the request. All requests sent to the server go to this page via means of a .htaccess, so /blablabla.htm is rewritten to go via your core (I'll assume it's just index.php).

On index.php, you'll have code that will scan the database for a page named 'blablabla' or 'blablabla.htm', and it will pull out the content accordingly.

Building the menu would be fine, since all of your pages are stored in the database using this method, you can simply build it dynamically on each page load (or cache it, but we're just talking theory here!). All you need to do is a basic SELECT * on the pages and output a good old <ul><li> tree for your pages.

Does this make sense at all?? I'm not really very good at explaining and it's 00:21! Sorry if it doesn't.
Was This Post Helpful? 1
  • +
  • -

#5 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: [Theory]create/edit/delete files.

Posted 26 February 2011 - 04:18 AM

It makes perfect sense, to me atleast, i have the general idea of what i'm driving for now thankyou.

On another note, i'm also aiming for a module system. Each module would have the same layout, so modulename/modulename.php would be the main file, modulenameadmin.php if it requires any setup, and a modulename.sql if theirs a table needed.

Its the admin part i'm having a bit of diffculty with, as i would use an modules_menu_admin table to hold the module admin area links to build a admin menu, the same was as for the pages. I was then thinking of having an admin_header.php which would check for authentication, and have it required in each module, using a function to check that the admin_header.php is required in the modulenameadmin.php file, or it would exit the script.

Is this possible? If so, where should i be looking?

By the way, thanks for helping me out of multiple topics Rudivisser :)
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: [Theory]create/edit/delete files.

Posted 26 February 2011 - 04:40 AM

I'm not sure I understand, is it the authentication you're having an issue with??

If so then you can always have an 'Auth' class with a static method on it.. This static method can then confirm if you're authenticated or not, rather than including a file. The problem with including a file is you can only really do one thing with it.. If you have a class you can do other things such as check for access to that module.

Sorry if I'm not making sense, but I mean you can restrict access to individual modules etc using something like this:
<?php
require_once 'lib/Auth.php';
if(!Auth::isLoggedIn() || !Auth::hasAccessToModule('Pages')) {
    die('You do not have access!');
}
// You do have access! woop


.. and you're welcome, glad I can help... Lost my touch recently :D
Was This Post Helpful? 1
  • +
  • -

#7 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: [Theory]create/edit/delete files.

Posted 26 February 2011 - 03:39 PM

Ah, not what i was directly saying but i think i've got some answers from it.
I'll try and explain another way, say i have a file called blogadmin.php, and wanted to ensure a user was authenticated before it was access, could i do this without any code in blogadmin.php ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1