Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Movable type - any experiences??

Posted by admin (Graham Ellis), 6 August 2004
Hi folks ... I'm an inveterate writer and I've been persuaded to start a diary / daily log (the in term is "Blog") and I'm at the early stages of experimenting with "Movable Type".   Thoughts, readers, comments, feedback welcome.  Anyone else blogging??

http://www.wellho.net/horse/

Posted by Caitlinn (Caitlinn), 9 August 2004
Movable Type is a good product.  Stable, not too hard to install, documentation is well written, loads of plugins, easy to build templates and huge community support.

I had two personal gripes with MT:

1.  Done in Perl which I can't hack as easily as I can hack a PHP system.

2.  Their recent licensing fiasco which -- until they cleared it up -- put one of my clients behind schedule.

Whatever blogging system you decide upon, you will have to think about comment spam and how you'd like to handle it.  The spammers may not target you at first, but believe me, they will eventually get you.

I'm still on MT 2.64 which doesn't have some of the comment spam enhancements as 3.0, so to manage most of my spam I just issue a few mySQL commands and delete it from the database.  I know that there is a black-list for MT, but I can't be bothered to install it because I'm converting my blogs from MT to ExpressionEngine.

Welcome to the wonderful world of blogging!

Posted by admin (Graham Ellis), 10 August 2004
Thanks, Cait ... you've spotted already that I'm having fun elsewhere.   It's good to be forwarned about the spam issue, and Perl isn't such a problem for me  

By the way - this may be a case of shutting the stable door after the horse has bolted ... but I've already written a PHP page that presents the MT Blog information in a different format.  Main page at http://www.wellho.net/horse and the archive special (via PHP) at http://www.wellho.net/net/mouth.html.  Let me know if you would like a copy!

Posted by Caitlinn (Caitlinn), 10 August 2004
Quote:
Perl isn't such a problem for me


I'm coming to realise that you are the God of Code!

Quote:
I've already written a PHP page that presents the MT Blog information in a different format


Yes, I'd love to see it, thank you!

But I'm curious ...

Why would you need to write something in PHP rather designing an archive template to handle that?

For instance, it looks like your archive page follows the standard design of your main site.  So I would have thought that creating an archive template that outputs, say your last x articles, and then name the output as recent.html. Then PHP include it in your main site template.

Either way, I'd love to see what you've written.  I'm one of those learn-by-example kinda gals.  

Posted by admin (Graham Ellis), 11 August 2004
on 08/10/04 at 22:05:50, Caitlinn wrote:
But I'm curious ...

Why would you need to write something in PHP rather designing an archive template to handle that?

For instance, it looks like your archive page follows the standard design of your main site.  So I would have thought that creating an archive template that outputs, say your last x articles, and then name the output as recent.html. Then PHP include it in your main site template.



That's an excellent question. I think I did it that way because it was the easiest way for me to visualise the solution, because I wanted to get some knowledge experience of what the internal tables in MT contained, because I wanted to have something that produced search-friendly pages, and because it fitted in well with our current templating system without the need to add a "wart" onto the system or duplicate a template.

Whether these points are valid reasons is open to debate and employing an MT template to generate an include file might have worked better. Didn't fully research the option once I csme up with my navigation scheme (you'll find it beaks out into a "recent posts" and "page 1 .... page n" type scheme once there are over a 25 entries).

Now ... the code ...

I've had a look and I'm NOT proud of the lack of comments in there; I fully expect to be the lifetim maintainer and to me the code is self-commenting using my standard conventions and included files, etc.

Firstly, although there's apparently a list-of-contents page at /net/mouth.html and a directory of articles, it's really all the same script, using Apache httpd rewrites:

Code:
RewriteEngine On
RewriteRule ^(.*)\.html ../net/mouth.html?headline=$1


Then there's a PHP page that looks all the messier because it's generated by a Perl script.  We're moving toward content management / XML approaches but at the moment the main section of the site uses older scripts that work from files of parameters tagged in a different style to XML - it's simply that we came up with a different format for our tagging

Here's the PHP at the top of the page ... f.y.i. .... I will knock out a few things that aren't relevant / would compromise our security to have them published.

Code:
<?php include_once ("$_SERVER[DOCUMENT_ROOT]/../include/stdphp.inc"); ?><?php function cook ($text) {
       $cooked = preg_replace('/[\x80-\xff]/',' ',$text);
       return $cooked;
       }

$dbh = mysql_connect("some.database.co.uk","wellho","summat");
mysql_select_db("wellho",$dbh);
$startat = 0;
$word = "Recent";

if (ereg('^[[:digit:]]+',$_REQUEST[headline],$gotten)) {
       $result = mysql_query("select * from mt_entry where entry_id = $gotten[0]",$dbh);
       $row = mysql_fetch_assoc($result);
       $bodder = nl2br(cook($row[entry_text]));
       $title = $header = $row[entry_title];

       $result = mysql_query("select * from mt_comment where comment_entry_id = $gotten[0]",$dbh);
       $sez = "";
       while ($row = mysql_fetch_assoc($result)) {
               $sez .= "<tr><td class=body valign=top>$row[comment_author]:</td><td class=body valign=top>"
               .nl2br(cook($row[comment_text]));
               $sez .= "</td></tr>";
       }
       if ($sez) {
               $sez = "<table><td class=body><b>Commentator</b></td><td class=body><b>says ...</b></td></tr>$sez</table>";
       } else {
               # $sez = "<i>No comments added to this entry</i><br>";
               $sez = " ";
       }


} else {
       $entry = "";
       $title = "Horse's Mouth online magazine";
       $header = "The Horse's Mouth - Ezine reader's index";
$bodder = '"The Horse's Mouth" is an online magazine - the ramblings of Graham Ellis.  I'm very fortunate to ';
$bodder .= 'come across a lot of interesting people in my work, and they inspire me to think, to write.  And the beauty of the ';
$bodder .= 'net is that you can search and read as much - or as little - as you like.  Free of charge.  Free of being identified. ';
$bodder .= 'You can even <a href=http://www.wellho.net/horse>add your comments</a> if you wish; although we can't offer you the ';
$bodder .= 'same anonimity nor a "freedom of speech", I'm going to encourage you to post of views that don't agree with mine and ';
$bodder .= 'only in what I consider to be exceptional circumstances will I remove or modify your material.';
$sez = "";

if (ereg('[[:digit:]]+',$_REQUEST[headline],$gotten)) {
       $startat = $gotten[0];
       if ($startat > 0) $word = "Selected";
       }

}

$result = mysql_query("select count(entry_id) from mt_entry",$dbh);
$row = mysql_fetch_array($result);
$record_count = $row[0];

$groupsize = 25;

$result = mysql_query("select * from mt_entry order by entry_created_on desc limit $startat,$groupsize",$dbh);
while ($row = mysql_fetch_assoc($result)) {
       $pagename = $row[entry_id]."_".preg_replace('/[^a-z0-9]+/i','-',$row[entry_title]);
     
               $index .= "<a href=/mouth/$pagename.html>".htmlspecialchars($row[entry_title])."</a><br>";
               
       }
?>


Within the main page, it's then broadly a case of just printing out the PHP variables where the snippets of HTML they include are wanted. There is an interesting extra bit there for generating links to multiple pages of contents which you'll see in action once the 26th entry has been written:

Code:
if ($record_count > $groupsize) {
       $extra = "Link to page ... ";
       $page = 1;
       for ($k=0; $k<$record_count; $k+=$groupsize) {
               if ($page > 1) $extra .= ", ";
     
               $extra .= "<a href=/mouth/_$k.html>$page</a>";
               
               $page++;
       }
       print "$extra at $groupsize posts per page<br><br>";
       }


Posted by Caitlinn (Caitlinn), 11 August 2004
Thanks, Graham.  Your code was easy to follow -- no need for comments.  And with pagination too!  That's pretty slick and something that MT doesn't offer natively.

As far as search engine friendly, MT does offer a way of titling your archives, categories and individual posts in a more search engine friendly manner that the default method.

Under Weblog Config, Archiving ...

For Individual Archives:

Code:
<$MTArchiveDate format="%B_%Y"$>/<$MTEntryTitle dirify="1"$>.php


Output: August_2004/Your_Entry_Title_Here.php

For Monthly Archives (list of all entries for that month):

Code:
<$MTArchiveDate format="%B_%Y"$>/index.php


Output: August_2004/index.php

For Category Archives (listing of all entries in a specific category):

Code:
<MTArchiveCategory dirify="1">/index.php


Output: Your_Category_Name/index.php

Of course the problem with dirify is that you have no option for the replacement of the whitespace character (unless you hack the Perl).  You are stuck with an underscore.  In some recent reading, I found that Google prefers a dash to underscore as a potential whitespace character.

Posted by admin (Graham Ellis), 11 August 2004
I just wish I had more time to do all these things!  No doubt I'll be learning and tuning MT more over coming weeks and months and adjusting things to push up the placement - but I think I had better write some content now  

P.S. I heard that about G preferring - to _ ... personally I try to take account of these things but also make especially sure that we provide good content that's worth indexing!

Posted by Caitlinn (Caitlinn), 11 August 2004
Quote:
personally I try to take account of these things but also make especially sure that we provide good content that's worth indexing!


I suspect you are!  I was Googling the other day for the answer to a PHP question (can't remember the question now, though I suspect it had something to do with $_GET), and lo and behold, a wellho.net page was the second (or third) site it brought up.

Posted by admin (Graham Ellis), 11 August 2004




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho