Jump to content

Archived

This topic is now archived and is closed to further replies.

newb

How do you create your CMS

Recommended Posts

Well, I've been working on a CMS for quite some time. How do you guys create yours? Any previews?

Share this post


Link to post
Share on other sites
I download the script package from CMSMadeSimple and then configure it to suit.  I'm not sure that's exactly the kind of answer you were looking for.

Share this post


Link to post
Share on other sites
nope, im talking about actually coding it from scratch, not preconfiguring one, anyone can do that.

Share this post


Link to post
Share on other sites
personally, i think one should think very long and hard before deciding whether it's worth re-inventing the wheel, so to say.  And so far, i have not found it to be worth it. but that's just me.

Share this post


Link to post
Share on other sites
It very much depends on how generic you want it be.

If you want to create a CMS that is a [u]reusable[/u] 'module' for all your sites/applications, you'll need a framework of sorts.

You've probably, maybe even without knowing it, already created one!

The wikipedia definition of a framework:

[quote]In software development, a framework is [b]a defined support structure in which another software project can be organized and developed[/b]. A framework may include support programs, code libraries, a scripting language, or other software to help develop and [b]glue together the different components of a software project[/b].[/quote]

As for Crayon Violent's 're-inventing the wheel' comment, I disagree. Not only is there much to be learned from creating a custom framework and CMS, it also allows you to create/leave out components of YOUR choosing, something I cannot really recommend using 'ready to use' frameworks and CMS's.

Once you've got a framework (or more simply put an application 'environment'), you have to decide how reusable you really want this CMS to be.

A CMS is dependant of the database design. One thing you could do to make the design more reusable is use a common 'naming convention' for all databases (provided that you are allowed to create the database structure yourself). That way you can assemble queries based on these conventions. For example, in my own 'Query' class, it gets the fields names in a table, and if it finds a column with, for example 'cat_id' in it, it assumes the col to be a foreign key for table 'cat' and adjusts the query to join that table.

Share this post


Link to post
Share on other sites
I've made a custom CMS for the company I work for. It's a work in progress as they keep wanting me to add things to it. 

I started with the layout of the website, looked at how I wanted to display the content, then worked the backend into the way I wanted to display the content. Don't know if that makes any sense but it seems to work.

Share this post


Link to post
Share on other sites
it's always better to do it custom so when you later want to go back in and add/take away, you know exactly how the code works since it is your own.

Share this post


Link to post
Share on other sites
[quote author=steelmanronald06 link=topic=107859.msg436204#msg436204 date=1158524770]
it's always better to do it custom so when you later want to go back in and add/take away, you know exactly how the code works since it is your own.
[/quote]
yeah i'd mostly go with that. although the 'purists' will tell you that you need to document/structure your code in such a way that would allow any programmer to jump in and pick up where you left off.
me personally, i disagree slightly with these purists and code everything i do from scratch the way i choose to. the only 3rd party scripts i ever use are bits and pieces of javascript, but as i'm getting ok at that, i'm writing all that sort of stuff myself as i prefer to.

where's the fun in using other peoples scripts? yeah sure it saves time, but i never feel like i've done my own project and don't feel satisfied if i feel like i've made something that's a glued together, patch-up job of loads of 3rd party stuff.

Share this post


Link to post
Share on other sites
[quote author=redbullmarky link=topic=107859.msg436218#msg436218 date=1158527524]
. the only 3rd party scripts i ever use are bits and pieces of javascript, but as i'm getting ok at that, i'm writing all that sort of stuff myself as i prefer to.
[/quote]

Yeah, I use TinyMCE, because it would take me forever to create a WYSIWYG of that quality. I am doing my own Ajax though, and my Javascript skills are defenitaly improving because of it.

[quote author=redbullmarky link=topic=107859.msg436218#msg436218 date=1158527524]
where's the fun in using other peoples scripts? yeah sure it saves time, but i never feel like i've done my own project and don't feel satisfied if i feel like i've made something that's a glued together, patch-up job of loads of 3rd party stuff.
[/quote]

I agree! Coding should be fun! Writing an application that is completely of your own making is VERY satisfactory. It becomes your 'baby'... :P

Share this post


Link to post
Share on other sites
How many of you, in coding your own CMS worked to make the PHP separate from HTML?  Does anyone have any good resources that helped them with this?

I am running a news site that deals with Photography news, specifically for Digital Single Lens Reflex (D-SLR) cameras.  I am having a hard time implementing this, as I feel the html / css formatting is hard to strip from the functional PHP.

For example, when designing the posting of the news, the news is (for the moment) in a generic text box.  I am coding the formatting when I write the article (including links, images, etc).  (I am wanting to eventually move to a WYSIWYG editor, like many forums use, but have yet to find a good article that shows a good cross browser method and I haven't looked into any of the pre-made ones yet, as mentioned in an earlier reply.)

My current CMS code works like such...

[code]
<?PHP
Session check (see if the user is logged in)

include the "user_config" file

Basic starting html (such as <html> and <head>)

if ($act = "add") {

if (isset($_POST["content"])) {
mysql query to insert into DB

if($db->query("INSERT....")  {$post_msg = "Good"}
else {$post_msg = "Bad"}
}

if (isset($post_msg)) { code to display msg }

HTML Form

continuing to have an elseif for edit and a "catch all" else "clean up" display if neither is set.

?>
[/code]

In addition, I am expanding what I want to do with the site and I'm working to try to make the site modular. I'm beginning to see why people say the code should be separate from the design, as I feel the current code is "messy" and needs a restructuring.

Your help would be greatly appreciated.

Thanks,
Chris

Share this post


Link to post
Share on other sites
[quote author=Cell0518 link=topic=107859.msg437157#msg437157 date=1158669051]
How many of you, in coding your own CMS worked to make the PHP separate from HTML?  Does anyone have any good resources that helped them with this?
[/quote]

chris, i have written a couple CMSs from scratch and helped with the development of the CMS we're using here at the university for our intranet pages as well, and i can tell you from firsthand experience, it's not always the best bet to write one from scratch. i will say that i think every developer should have to write one from scratch, though. it's a great learning tool and an experience that will help in almost every other area of development.

now, concerning the quoted question above, i always separate my HTML from my PHP [b]if the site has a consistant look across the board[/b]. now, on things like the intranet at the school where certain departments have their own pages and can design their own look and things, a template doesn't help unless you allow them to define their own template. but, for sake of argument, [url=http://codewalkers.com/tutorials/58/]this tutorial from codewalkers[/url] is about one of the best to get you started. if you're interested in implementing any PEAR libraries, check out Smarty as a viable option for templating as well.

hope this is of some help.

Share this post


Link to post
Share on other sites
Hi, thanks for the article on the templating.  I've already read some of it and it looks very informative and very useful.

Now, I'm trying to figure out how to use this in a modular aspect, as in a url that is www.example.com/admin/index.php?module=news&action=add. (this is basically how my site works now, although it's currently kinda messy as mentioned in my first post)

What is interpreting the url and decifering what code needs to be pulled and processed and what is shown?  I understand that $_GET["module"] would be equal to the value in the url.  Is someone going to say
[code]
if ($module = "news")
{
code
}
elseif ($module = "settings") {
more code
}
else { generic error code / menu }
[/code]

or is there a better way?

Thanks,
Chris

Share this post


Link to post
Share on other sites
Hello
Cell0518, In response to obsidian, can I point you to this tutorial too: http://www.sitepoint.com/article/beyond-template-engine

whilst it's slightly irrelevent to your initial question, i think it's relevent on how the final project will be structured/coded, etc. For the reasons outlined in that link, as well as other similar articles, I wrote my own (very simple) template class based on the above, which uses PHP instead of its own syntax. Advantages being that it's very lightweight, you don't need an accelerator to compensate for drop in performance, easier to use, and you don't need to learn an entire new set of syntax to get going.

Share this post


Link to post
Share on other sites
In response to the "purist" statements. Those "purists" just happen to be more experienced, and usually better programmers than those who argue against well documented and reuseable code, even if it's 3rd party. These people are clearly showing they are still novice and have no experience. "Why reeinvent the wheel?" is something you will experience in everyday life of a developer.

There are so many valid reasons why reusable, well documented code is better than writing from scratch everytime round I won't list them all.. but here are a few:

1. Efficiency. If you write from scratch every time, you are wasting time. Time equals money. Client has asked for a new site. This site is nothing out of the ordinary. You've evaluated and quotes 25hours of work, because you are writing from scratch. Bob has quoted 4 hours, because he is using a solid framework. Who is going to get the job?

2. I challenge anyone, and I mean anyone, to write up a site, leave it undocumented, then 6months down the line come back to it and prove to me they can just pick it up and carry on with it. I also challenge anyone to do the same with someone elses code. Both of these situations happen ALL the time in the real world. Where I am working now, I was recently asked to make a change. I looked at the modified times on the files - last modified: 2nd August 1986. You think you can remember some code from 20 years ago?

Share this post


Link to post
Share on other sites
jenk, very good points. i would agree that lack of willingness to use pre-existing code does tend to lend itself to the mindset of inexperience. however, it's not always viable with the options that the client needs to try to modify code. i know you know this, but i'm just clarifying a bit for other readers, too. you have to get to the point where you can weigh what will be your best bet in the long haul. think of this scenario: i own a business, and i'm wanting an application written where i can control my intranet. there are two people i'm looking at to do my project for me, and i've asked them to write up a proposal:

1. person #1 - i'm going to write everything from scratch. i don't want to use anyone else's prewritten code because i don't want any extra bulk or overhead. due to the size of the CMS you're looking for, i'll quote you a 200 hour project at $25/hr. i can write and implement your entire CMS for you for $5000. obviously, i don't need to give my client all my details and reasoning, so i'll just write up a proposal for $5000.

2. person #2 - i found that joomla (or replace any major CMS you like here) will do 80% of what you're after with some modifications. i can write a couple basic mods that will add the additional functionality to the CMS that you're after. i figure all in all, it will take me about 80 hours to write it up and have it implemented. i charge $50/hr. since i don't need to give my client all my reasoning, i'll just write up a proposal for $4000.

now, here we have an interesting situation. the first person is going for broke on the project: writing everything from scratch. $25/hr really isn't a very high price to charge for this type of development work at all, so a $5000 price tag is pretty fair. as a businessman, i find this very appealing. however, when person #2 comes back with an offer at $1000 less and can have a turnaround time of half what my first option was, i have to reconsider.

plus, you have the bargaining tools of Joomla and other CMS systems being so widely used and supported. i mean, [i]support[/i] is [b]huge[/b] when it comes to CMS. if you write it from scratch, you're stuck doing all the support yourself if [i]anything[/i] goes wrong, and you very quickly may find that you were way under on your initial bid. on the other hand, if an issue comes up in a part of the CMS that's core to a build in Joomla, you can likely go to the community and find very quick solutions to allow you to support your clients quickly and efficiently. in a case like this, it would be much more beneficial to both parties (client and developer) to go with a premade CMS.

there are, of course, instances where i would rather build my own (or have one built from scratch for me), but i would definitely have to have a developer who had proved themselves over and over again and had a flawless reputation in the development community, because i wouldn't want someone to write a shoddy app and then disappear as soon as payment was made, either.

obviously, there are a lot of things to think about ;)

Share this post


Link to post
Share on other sites
[quote author=Jenk link=topic=107859.msg438742#msg438742 date=1158847490]
In response to the "purist" statements. Those "purists" just happen to be more experienced, and usually better programmers than those who argue against well documented and reuseable code, even if it's 3rd party. These people are clearly showing they are still novice and have no experience. "Why reeinvent the wheel?" is something you will experience in everyday life of a developer.
[/quote]
if that's aimed towards a comment I made about purists and preferring writing things from scratch, then you may have slightly misunderstood me.
When i first started getting properly into php, i downloaded a copy of phpBB (before i'd even heard of joomla/nuke/etc) to look at the code. it fried my brains a little, so i decided to do things myself based on what i already knew. this was great for what i wanted to do at the time (my own company website).
my past programming experience has always been 'procedural' rather than OOP, but regardless, I was always taught to keep libraries of re-usable code and to design/build with reusability in mind. so as i completed a few more things for myself, i was able to work quicker as i reused the code from before.
then i set myself a bit of a challenge, which led to my site (The DinnerTimes). the idea was to use everything i knew and do a bit of a mish-mash. What came out of that was scripts to deal with forums, blogs, users, graphics, databases, templates, etc. All written from scratch.
Needing more, and getting more into OOP, I 'class'ed many of these scripts and now have a nice little framework, fully commented, that can now pretty much deal with anything I personally need.
So when I say I prefer to write everything from scratch, I think you take me a little too literally (if indeed i was one of those you were indicating). I wrote my own scripts from scratch, and now I use them for everything I do. Sure, each project requires something that the framework doesnt have, so I add to it. But that's the same with many.

But in short, I don't personally get anything out of using other peoples code. Not saying it's wrong, but it's like music. One musician loves doing covers of other bands songs. Others like writing their own songs from scratch. It depends on the person and ultimately comes down to enjoyment. Some people just enjoy knowing they did it all by themselves - not just with coding, but with any 'art'. Some dont.

So Jenk/obsidian, you're both correct. Time IS money. But for me, "re-inventing the wheel" was probably what made me learn alot quicker than I could have, and now I have a nice little framework, fully documented, ever improving and to be honest I'm pretty proud of it because it's mine - so from that point of view, I'm correct too, because it works for me.

Cheers
Mark

Share this post


Link to post
Share on other sites
[quote author=redbullmarky link=topic=107859.msg438797#msg438797 date=1158855224]
But for me, "re-inventing the wheel" was probably what made me learn alot quicker than I could have...
[/quote]

and don't ever let anyone discourage you from doing what you need to learn. i'll clarify my very first statement in this thread: i think that every developer should [i]reinvent the wheel[/i] from time to time simply to get a broader knowledge of underlying coding techniques if nothing else. however, the wise coder will also know where to draw the line for himself as to when and where to be open to using good, solid, open-source (or pre-written) code. ;)

Share this post


Link to post
Share on other sites
I have been fighting with this for months.  I can't decide.
Below is a link to a post I made where I was having the same issue this whole time deciding.
http://www.phpfreaks.com/forums/index.php/topic,110739.0.html

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.