
![]() |
perkiset
Well, it doesn’t, but people can really make it suck.
I’m writing this because I just tackled my first blog – I have many clients that want a deeply-customized blog and I needed to know the methods behind this. So, I grabbed WordPress, got familiar with it then started looking at how to build custom themes from the ground up. You can find my efforts here: http://www.perkiset.org/politics/ But now, back to WordPress: IT SUCKS. Why, you may ask? Because the WP people used the oldest and least-strong form of PHPprogrammatic structure there is, and the very thing that Nutballs doesn’t care for: a complete blending of the presentation and actuary code.Now we all know that PHPcame from the days when a page was 98% HTML and you wanted to add a little tag for the counter, or the date or something. The format for that was simple: in the middle of an HTML page, you’d just add a littlePHPtag:<font size="3"><? phpecho date('m/d/Y', time()); ?></font>This was a clever “add” to the language of the then-newfangled World Wide Web. But it's shit on a biscuit now. There are two essential ways of programmingwithPHP: HTML withPHPtags interspersed – I’ll call things HTML+PHPfor the rest of this post, andPHPoutputting HTML chunks – which I’ll call TRWTC from now. (The Right Way To Code).Consider this snippet: <? phpget_header(); ?><div id="middle"> <div id="content"> <? phpif (have_posts()) : ?><? phpwhile (have_posts()) : the_post(); ?><div class="title"> <h2><a href="<? phpthe_permalink() ?>" rel="bookmark" title="Permanent Link to <?phpthe_title(); ?>"><?phpthe_title(); ?></a></h2></div> <div class="post" id="post-<? phpthe_ID(); ?>"><p class="small">posted by <? phpthe_author() ?> on <?phpthe_time('M') ?> <?phpthe_time('j') ?></p><div class="clear"></div> <div class="entry"> <? phpthe_content('Read the rest of this entry »'); ?></div> </div> <div class="postfooter"> <p class="postmetadata alignleft">Posted in <? phpthe_category(', ') ?></p><p class="alignright"><? phpedit_post_link('Edit', '', ' | '); ?> <?phpcomments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p><div class="clear"></div> </div> <? phpendwhile; ?><div class="navigation"> <div class="alignleft"><? phpnext_posts_link('« Previous Entries') ?></div><div class="alignright"><? phpprevious_posts_link('Next Entries »') ?></div><div class="clear"></div> </div> <? phpelse : ?><h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <? phpinclude (TEMPLATEPATH . "/searchform.php"); ?><? phpendif; ?></div> <? phpget_sidebar(); ?><div class="clear"></div> </div> <? phpget_footer(); ?>Notice how they have actually created loops with inserted PHPtags! It’s HORRIBLE! There are 3 fundamental problems with this sort ofprogramming– particularly when you’re building some big and nasty like WordPress:• HTML looks alright, but your programminglanguage is chunked up and difficult to follow. There is no flow and the language is interspersed with non-actuary code. It’s terribly difficult to follow, particularly if it hasn't been nicely indented as it is here.• There is no going back: once you’ve output something, it’s streamed to the user. Without getting deeply into output control functions, in the immortal words of Sally, “It’s out there. You can’t take it back once it’s out there.” This is a problem with the PHPmechanism in general if you’re not careful: any text characters outside of the <? ?> tags are output IMMEDIATELY to the surfer. This means that if you have a space or CR/LF in the front or back of a pure-phpfile, that will go out EVEN BEFORE YOUR CODE, meaning that if you call header() to do something special it wont work, because it’s already out there. The notion of flow control is right out. This is just entirely bad form, because what if, during the course of constructing your page, you decide that the TITLE tag must be different – well, you can.t It’s gone.• Lastly, there is no simply way to “blend” the two styles of PHPprogramming(HTML+PHPor TRWTC) – once you’re on the track of HTML+PHPyou’re done.In a system like WordPress, particularly since they’re at version 2.2.3 or something like that now, you’d expect that they’d moved beyond the ancient and antiquated HTML+ PHPmodel, but the truth about coders wins: Ugly coders write ugly code, regardless of language. And the WordPress folks wrote some DAMN ugly code. SMF is the opposite. Completely TRWTC, even though it is pretty unattractive. But the difference could not be more stark.In WordPress they even do profoundly stupid things like echoing the return value of a function rather than returning it – this means that you are FORCED into the HTML+ PHPmodel even if you want to modify it, because the functions you’re calling are streaming to the surfer RIGHT NOW. And worse, some function assume that the <currentPHPtag> is inside of a <ul><li> arrangement and add LI tags around the output and some don’t - the inconsistency and lack of flexibility is just amazingly poor.So: I’ll be completely rewriting WordPress from the ground up this afternoon ![]() In any case, take heed: Friends don’t let friends code HTML+ PHP.jairez
HTML+
PHP... please don't take away my editor?!?!Kind of funny ... I've typically seeded my sites this way with the intention of fleshing them out, but typically only "functional" pages get the TRWTC treatment. But ... guilty as charged ![]() /me perkiset
Wasn't a shot at you at all J, just a thought in general. The WordPress folks should *really* not be doing this... it's a different way of thinking, particularly for someone who came from HTML into
PHPrather than a coder that came to the web.Doesn't take anything from you at all, just a restructuring of the way that you build a site. As SMSd, a good place to see the difference is to download and look at the entire Dynamic Site Example I posted here a bit ago. /p nutballs
I agree! lol
actually, I do think you can intermingle, i just don't think you should. The only time it is appropriate is for a self contained drop-in. Such as the same way you drop in an Adsense block, or any other remotely hosted JS file that handles some completely compartmentalized display object. i too have been considering the shortcomings of wordpress and have been thinking of writing my own blog solution. In some respects WP is great, all the plugins, and templates. In other respects, it sucks, trying to be everything to everyone. I have considered making a system that is bare bones. write to draft publish users comments tags/categories and an easy as shit template system. the reason I haven't is because there is WP. It already exists, and frankly does what I want, though with more fat that I would ever want or need. Also, the day is not long enough. perkiset
While grumbling about it a while ago, I thought that, rather than rewrite, perhaps an addition would work - here's my thought:
WP does a fine job of managing a user, and the back-office component is good enough. It's the front-end stuff that pisses me off. So I was thinking about building a WP API that essentially wraps the same code into an object or functional structure so that I could write what and how I wanted to. (Of course, there's another VASTLY more important API in front of that one ![]() I dunno, I agree - the day is just not long enough. arms
thank you for saying it.
i was looking at using drupal as a cms and i was impressed until i looked into making a theme. wordpress too. fishing html+ phpdiarrhea.in the time it would take me to learnhow to theme either one i (mostly) wrote my own blog inpython+django.ffs what the hell do they have against using some kind of templating? for me TRWTC would be MVCish with the logic completely seperate from the view, using some kind of templating engine. i was about to disagree with your TRWTC, then i read it before ran my mouth off. almost the same thing. perkiset
quote author=arms link=topic=524.msg3411#msg3411 date=1190851345 fishing html+ phpdiarrhea.in the time it would take me to learnhow to theme either one i (mostly) wrote my own blog inpython+django.I totally get it... every frigging keystroke I made working through my blog on WP just made me itch to do it all myself... however, I have clients that want it done in WP so I must learnit.Worse: the templates I downloaded that were all tricky CSS had MAJOR discrepancies between IE, FF and Safari. Predominantely, if they worked on FF and Saf then they looked nasty on IE and vice versa. So I stepped way back to a table structure and it looks nice no matter what. And the completely bullshit way that WP was written certainly made that an interesting exercise... Shittah, the more cool and tricky things get the more they are unmanageable. jairez
This has been a very enlightening thread, as I downloaded WP about 6 months ago and just left the printed intro dox rotting on my nightstand.
I guess unconscious decisions may have value as well. Then again, I'll probably have to learnit at some point, then I can join you blokes at the bar crying in our bloggers' beer ... all because you guys couldn't find enough time in the day.![]() perkiset
quote author=jairez link=topic=524.msg3419#msg3419 date=1190871706 This has been a very enlightening thread, as I downloaded WP about 6 months ago and just left the printed intro dox rotting on my nightstand. ![]() ![]() ![]() I did the same, like 3 times. It was like pulling teeth to finally get my butt into gear on it. quote author=jairez link=topic=524.msg3419#msg3419 date=1190871706 Then again, I'll probably have to learnit at some point, then I can join you blokes at the bar crying in our bloggers' beer ... all because you guys couldn't find enough time in the day.![]() Given what you're currently up to, I think you'd do well simply to understand how to use and set it up for others... there are so many themes out there that you could get a *long* way on "stock" stuff and then begin to learnto tweak as you go. My suggestion:learnWordPress config/setup, SMF config/setup andphpCollab config/setup and you'll have a quite healthy rack of new tools for clients. Read, fantastically high-return looking but low-time-investment billable hours...![]() ![]() /p jairez
Great idea. Maybe I'll dust it off and see if I can get that dog to hunt. After all,
quote fantastically high-return looking but low-time-investment billable hours... Wink kaCHING! ... me likey-likey the sound of the cache register ![]() freedom1972
I admit it - I am guilty. I used to write DB/Applications in
Perl, and there was really on TRWTC options for integrating the two. When I first came acorssPHP, it "Seemed" to make building out web apps so much easier because of allowing HTML andPHPto be mixed. And yes, for quick DB insertions or passing variables ot my pages for simplistic dynamic page creation I lovePHP. Like you clearly pointed out, the challenge comes when people take "![]() That has always been the double edged sword for me with scripting languages. I can crank out some down and dirty code to get something done. Pretty soon, thats all you do, and your 50% into taping an application together when the idea strikes you: "Perhaps this needs a better design!" perkiset
I REALLY understand the hatred of "refactoring" and starting from scratch... I've done things like that so many times it's just not even funny.
But I've also been one to really benefit from taking the time (and enduring the headache) of stepping back and saying, you know - I'm gonna type the fingerprints off my hands to do this, but it is the right thing to do... and rewrite. The WordPress folks should take the time to see just how craqppy their codebase is and give it an update. They would *really* dominate then. MP
Would be a nice idea to mail this thread to the people at WP, would especially love it if sits posted on matt's blog.
Shoot a mail out prof.. I really need to learnphp... |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads