Showing posts with label XHTML. Show all posts
Showing posts with label XHTML. Show all posts

Friday, July 11, 2008

Draw Your UIs Completely Up Front

I've come to realize now that one of the fastest things I can do on a project is to draw up the XHTML/CSS stuff first, drawing out every page and admin page, before I even start work. Of course, if the client has a designer in mind, or can use who I recommend, that's great. But if they're cheap and cannot, then it's best if I start on every page.

I had this all wrong, really. I used to draw each part of the site as I went along, and then have these painful discoveries with the client where, once they visualized something, they would either have feature creep or explain that they messed up in the functional spec or were not clear enough or that I interpreted thing completely wrong. By drawing a UI all the way through and presenting it to the client, it makes the functional spec that much more clear.

At that point, building the site moves along much faster because it's just a matter of plugging in items into the backend database.

Wednesday, July 9, 2008

Latest Development Style

I've revised my development style after a lot of thought. Now, don't get me wrong, I make exceptions to this when I have a client with certain tastes, but this is the style I will use when the client leaves it up to me.

First, if I can use small packages to achieve what I need, I'll definitely consider them. I'm not a big fan of big elaborate systems except things that are well established and which fit a need very well. For example, WordPress and phpBB are great fits on some projects -- no need to rewrite those unless something special comes up.

Now, if I need to build something custom, then I don't like spaghetti code, so I need a framework. I don't like the learning curve of other frameworks, and I have learned a few, but they are either too cumbersome, too slow, too inflexible, or just generally are a plain in the rear to use.

Therefore, we have to separate out the PHP from the MySQL from the XHTML, so here's how I do it.

First, I used to use Smarty, and will still use it if a client wants it. However, now that I know Smarty, I've realized that it's actually slower, as well as redundant to, just using XHTML files saved as PHP pages with inside. I stick these in a subfolder called templates and load them with require_once instead of $smarty->display.

Second, to handle the MySQL, I use either Outlet ORM with PDO or Propel ORM with PDO, depending on client need. And if I have something special, some special SQL besides this, I do a straight PDO call by using parameterized SQL stored in a central conf file. (BTW, my conf files are actually PHP class files with public variables.) Parameterized SQL means I have SQL statements with ^ caret symbols inside where variables would go, and I use a Pack() function that I created to insert the variables inside those places.

Third, to handle the PHP page logic, I don't use MVC. Instead, I use PHP pages for each individual need, and each PHP page is started with a commented template where I insert my PHP logic. I call these "PHP Logic Templates".

Fourth, instead of a "Model" from MVC, I use a classes subfolder with my object classes inside.

Fifth, I use Blueprint CSS on difficult CSS projects, but now I often may go straight CSS based on things I learned from Blueprint. It makes for cleaner code to go without Blueprint, but it's not always possible.

Sixth, I still use everything else such as ProperCase() function naming, $sAdaptedHungarian for my variable naming, initial curly braces { on the same line as the statement where they are used (not on a new line), and everything else you see in previous posts besides the stuff about the database logic, which has changed a great deal now.

Wednesday, July 2, 2008

Get Rich Edit Controls On Your Website in 5 Seconds




Check this out. Create a folder on your desktop called test. Drop a text file in called editor.html and make it look like this:

<html>
<head>
<title>TinyMCE Test</title>
<script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,bold,italic,|,forecolor,backcolor,|,
justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,
blockquote,|,link,image,hr,|,code,removeformat",
theme_advanced_buttons2: "",
theme_advanced_buttons3: ""
});
</script>
</head>
<body>
<!-- form sends content to moxiecode's demo page -->
<form method="post" action="http://tinymce.moxiecode.com/dump.php?example=true">
<textarea id="content" name="content" cols="50" rows="15">This is some content that will be editable with TinyMCE.</textarea>
<input type="submit" value="Save" />
</form>
</body>
</html>

Now download TinyMCE from http:///moxiecode.com. Unzip it such that you find the jscripts folder inside. Open that up and it contains "tiny_mce". Copy that "tiny_mce" folder into your "test" folder on your desktop. Now view editor.html in your web browser. Click Save. Watch it post to the moxiecode.com website. You could just as easily have posted that to your own PHP pages. Now open editor.html in any text editor. Note how few lines of code were used. The way I've got it set up is that it takes any textarea on the given page and converts it into a rich editor control.

Cool factor is high, right?

P.S. If you don't like the default font size, just edit the file in the path:

tiny_mce/themes/advanced/skins/default/content.css

Change the first line where it says 10px into 11 or 12px, or any font size you want.

Wednesday, June 11, 2008

Cool New Service -- CushyCMS

 



A PHP associate shared this with me. This was a really cool new product on the web. It's free unless you want to brand the editor as your own, and then it's $28/mo USD (June 2008 prices).

http://www.cushycms.com/

Basically it lets you take any PHP page that may contain HTML or XHTML content inside, or any XHTML or HTML page, any Javascript file -- basically any text file that has HTML or XHTML tags inside. Then, you can add some class attributes on some existing tags, or wrap something in a DIV or SPAN or other tag and add the class attribute. Once you add that in and connect it to this FREE service and give it your FTP username and password, you can then export an interface to your client that's easy to use so that they can publish content to their own sites.

Now, here's a few catches where some of your clients may not like this:
  • If they are concerned about the FTP security. Although it encrypts the FTP information it stores in its database, it still could be a risk that a hacker could get this information and the way to unencrypt it.
  • If the service becomes extremely popular, can it scale to handle the load?
  • If the service runs out of cash and needs to start charging for stuff it gives away for free.
  • If the service is down and you are powerless to get it operational again for your client.
  • If your client wants excerpts for articles on their home page, and then the ability to create new article pages with a given page layout.
  • If your client wants an article archive with links for Previous and Newer entries, or a calendar to pick articles on certain dates.
  • If your client wants to be able to search for content based on title, author, categories or tags, or content.
  • If your client wants to view an image gallery for his entire site and see which images were used where on the site.
  • If you want paginated articles when they are too long.
  • If your client wants the power to create new page tabs on the site and add that content.
So, for those, you'll need a full-blown CMS, and my favorite one to recommend is TextPattern CMS (TXP, as it is called for short). Now, TXP has a lousy admin interface, and doesn't support standard markup of articles by default. However, two hacks have been created called Aeron MyAdmin and hak_tinymce. The first one, Aeron, takes the ugly CMS admin interface of TXP and makes it beautiful. The second takes the article editor and gives it a richeditor WYSIWYG editor.

And next to that, for ease of use, I recommend WordPress CMS, hands down.

TXP is great when you have a given XHTML template and you need to paste it on the site with not much fuss and then plug in CMS tags into it.

WordPress CMS is great when you don't have a given XHTML template and are willing to either purchase or download one from the web custom-made for WordPress, or to export the default one, edit it, and re-upload something geared just for WordPress CMS.