Allow the user to look at a list of the quotes.
Logged In: YES user_id=1933823 Originator: NO
Here's a function to do this (add to class/Quotes.php):
function _list() { $sql = "SELECT label, quote FROM mod_quotes_items WHERE hidden = 0 ORDER BY RAND()"; $results = $GLOBALS["core"]->getAllAssoc($sql, TRUE); $listTags = array(); $rowCounter = 0; foreach($results as $result) { $rowTags = array(); $rowTags["ROW_CLASS"] = ($rowCounter % 2 ? " class=\"bg_light\"" : " class=\"bg_medium\""); $rowTags['LABEL'] = $result['label']; $rowTags['QUOTE'] = stripslashes($result['quote']); $listTags["LIST_ITEMS"] .= PHPWS_Template::processTemplate($rowTags, "quotes", "row.tpl"); $rowCounter++; } $title = $_SESSION["translate"]->it("Quotes"); PHPWS_Layout::addPageTitle($title); $content = PHPWS_Template::processTemplate($listTags, "quotes", "list.tpl"); $GLOBALS['CNT_quotes_list']['title'] = $title; $GLOBALS["CNT_quotes_list"]["content"] .= $content; }// END FUNC _list
The action() function in class/Quotes.php also needs to be updated. Add this to the switch():
case "list": $content .= $this->_list(); break;
Then, to view the list, use this link:
http://\{YOUR_WEBSITE}/index.php?module=quotes"ES_OP=list
Log in to post a comment.
Logged In: YES
user_id=1933823
Originator: NO
Here's a function to do this (add to class/Quotes.php):
function _list() {
$sql = "SELECT label, quote FROM mod_quotes_items WHERE hidden = 0 ORDER BY RAND()";
$results = $GLOBALS["core"]->getAllAssoc($sql, TRUE);
$listTags = array();
$rowCounter = 0;
foreach($results as $result) {
$rowTags = array();
$rowTags["ROW_CLASS"] = ($rowCounter % 2 ? " class=\"bg_light\"" : " class=\"bg_medium\"");
$rowTags['LABEL'] = $result['label'];
$rowTags['QUOTE'] = stripslashes($result['quote']);
$listTags["LIST_ITEMS"] .= PHPWS_Template::processTemplate($rowTags, "quotes", "row.tpl");
$rowCounter++;
}
$title = $_SESSION["translate"]->it("Quotes");
PHPWS_Layout::addPageTitle($title);
$content = PHPWS_Template::processTemplate($listTags, "quotes", "list.tpl");
$GLOBALS['CNT_quotes_list']['title'] = $title;
$GLOBALS["CNT_quotes_list"]["content"] .= $content;
}// END FUNC _list
The action() function in class/Quotes.php also needs to be updated. Add this to the switch():
case "list":
$content .= $this->_list();
break;
Then, to view the list, use this link:
http://\{YOUR_WEBSITE}/index.php?module=quotes"ES_OP=list