1
bigwolf
How to connect xoopsDB in theme.html
  • 2006/9/11 14:51

  • bigwolf

  • Just popping in

  • Posts: 36

  • Since: 2002/4/20


I'd like to insert the texts and authors from random quote module in theme.html. Could anyone give me a hand? Thanks.

=========[my failure content in theme.html ]==============

$xoopsDB =& Database::getInstance();
$sql="select texto,autor from ".$xoopsDB->prefix("xoops_citas");
$result = $xoopsDB->query($sql) ; list($texto,$autor)=$xoopsDB->fetchRow($result);
echo "Quote:".$texto;
echo "Author ".$autor;





===========================================================

2
McNaz
Re: How to connect xoopsDB in theme.html
  • 2006/9/11 15:25

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


You will need to wrap that in PHP. IE


=& Database::getInstance();
$sql="select texto,autor from ".$xoopsDB->prefix("xoops_citas");
$result $xoopsDB->query($sql) ; list($texto,$autor)=$xoopsDB->fetchRow($result);
echo 
"Quote:".$texto;
echo 
"Author ".$autor?>

 




HTH.

3
rplima2004
Re: How to connect xoopsDB in theme.html
  • 2006/9/11 15:35

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Try to use this:

On the final of XOOPS_ROOT_PATH/header.php, before the
Quote:

}
?>


insert this code:
Quote:

global $xoopsDB;
$sql="select texto,autor from ".$xoopsDB->prefix("xoops_citas")." ORDER BY RAND() LIMIT 10";
$result = $xoopsDB->query($sql) ;
$i = 0;
while(list($texto,$autor)=$xoopsDB->fetchRow($result)){
$arr_quotes[$i]['text'] = $texto;
$arr_quotes[$i]['author'] = $autor;
$i++;
}
$xoopsTpl->assign('arr_quotes',$arr_quotes);


Now, on the theme.html put this code in the exact place that you want to show the quotes
Quote:


<{foreach item=quote from=$arr_quotes}>

<{$quote.text}>


<{$quote.author}>




<{/foreach}>



Soon, the code will return 10 quotes/authors and show on theme. To define the amount of quotes you want change the 10 on the sql query for the number you want.

att

Rodrigo

4
bigwolf
Re: How to connect xoopsDB in theme.html
  • 2006/9/12 4:42

  • bigwolf

  • Just popping in

  • Posts: 36

  • Since: 2002/4/20


Where can I insert your code? rplima2004
=========================================================
// $Id: header.php 185 2006-01-22 23:49:01Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}

// Ensure charset setting
if (!headers_sent()) {
header('Content-Type:text/html; charset='._CHARSET);
}

$GLOBALS['xoopsLogger']->context = "core";

// Get blocks
$block_handler =& xoops_gethandler('block');
$block_handler->assignBlocks();

$GLOBALS['xTheme']->checkCache();

if (!isset($GLOBALS['xoopsOption']['template_main'])) {
// new themes using Smarty does not have old functions that are required in old modules, so include them now
include XOOPS_ROOT_PATH.'/include/old_theme_functions.php';
// need this also
$xoopsTheme['thename'] = $GLOBALS['xoopsConfig']['theme_set'];


}
$GLOBALS['xoopsLogger']->context = "module";

?>

5
rplima2004
Re: How to connect xoopsDB in theme.html
  • 2006/9/12 5:36

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Sorry, my example are created on XOOPS 2015 and your version is 2.2.X

Insert the code on the final of file, before the tag ?>

Quote:

// $Id: header.php 185 2006-01-22 23:49:01Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}

// Ensure charset setting
if (!headers_sent()) {
header('Content-Type:text/html; charset='._CHARSET);
}

$GLOBALS['xoopsLogger']->context = "core";

// Get blocks
$block_handler =& xoops_gethandler('block');
$block_handler->assignBlocks();

$GLOBALS['xTheme']->checkCache();

if (!isset($GLOBALS['xoopsOption']['template_main'])) {
// new themes using Smarty does not have old functions that are required in old modules, so include them now
include XOOPS_ROOT_PATH.'/include/old_theme_functions.php';
// need this also
$xoopsTheme['thename'] = $GLOBALS['xoopsConfig']['theme_set'];


}
$GLOBALS['xoopsLogger']->context = "module";
/*
*Hack by rplima to show random quotes in the theme
*/
global $xoopsDB;
$sql="select texto,autor from ".$xoopsDB->prefix("xoops_citas")." ORDER BY RAND() LIMIT 10";
$result = $xoopsDB->query($sql) ;
$i = 0;
while(list($texto,$autor)=$xoopsDB->fetchRow($result)){
$arr_quotes[$i]['text'] = $texto;
$arr_quotes[$i]['author'] = $autor;
$i++;
}
$xoopsTpl->assign('arr_quotes',$arr_quotes);
/*
*End of hack
*/
?>

Login

Who's Online

445 user(s) are online (332 user(s) are browsing Support Forums)


Members: 0


Guests: 445


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits