I'm wondering if perhaps I am doing this all wrong.. see for yourself:
Question:
Does my OOP suck?
is running multiple methods on a value {ie: strip_tags($copy->truncateString($articles[$i]['body'], 250, " "))} a terrible way to manage resources?
Should I create seperate methods to use for the following line: {echo '' . $articles[$i]['title'] . ' (' . $articles[$i]['date'] . ')' .strip_tags($copy->truncateString($articles[$i]['body'], 250, " ")) . '
Read more ';}?
Notes:
pageTemplate is a class which will contain all html templats for this particular site
Two static classes take care of site wide configuration variables (not seen here) and tracking the url (BreadCrumbs:
.
Calling BreadCrumbs::getCrumb(x) retrieves the 'value' at the x position of the url (ie: domain.com/"pos 1"/"pos 2"/"pos 3"). The values are managed at the top of the page and are checked if empty and replaced with a default value if they are.
GetCopy is a class which has a number of functions designed to run a query (based on various parameters) and retrieves an array (or mulch-dimensional array). The function used below retrieves a mulch-dimensional array with each second level array containing a whole article.
GetCopy has a parent. It extends a class called CopyMan which contains various functions such as adding paragraphs to a block of text, truncating, converting date forms, and pagination tools. Called through the GetCopy object.
/**
* homePage :: ()
* PUBLIC method
* = lay out the home page content
*
*/
public static function homePage() {
// initialize GetCopy class
$copy = new GetCopy();
// special feature container
echo '<div id="special_box"><div class="special_header"><img src="/images/layout/special_header.png"></div><div class="special_container">';
$articles = $copy->getRows('articles', 'date', 0, 2);
//print_r($articles);
for ($i = 0; $i < count($articles); $i++) {
echo '<div class="special_summary"><a href="/' . BreadCrumbs::getCrumb(1) . '/'. BreadCrumbs::getCrumb(2) . '/article/' . $articles[$i]['id'] . '"><h5>' . $articles[$i]['title'] . '</h5></a> (' . $articles[$i]['date'] . ')<p>' . strip_tags($copy->truncateString($articles[$i]['body'], 250, " ")) . '</p><p><a href="/' . BreadCrumbs::getCrumb(1) . '/'. BreadCrumbs::getCrumb(2) . '/article/' . $articles[$i]['id'] . '"> Read more</a></p></div>';
}
echo '</div></div>';
}
Please keep in mind that I taught myself PHP on my own.. no mentors, or corporate structure, classes, or any theory.. just learned as I need to learn how to do things. So please offer constructive criticism, I'm sure I need it.