1
phillipd
Smarty templates and xoops forms in a function (Admin)
  • 2005/4/3 6:06

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Has anyone got smarty templates and XOOPS form code (Admin side) to work in a PHP function? If so, what problems, if any did you have?

Thanks

2
zoullou
Re: Smarty templates and xoops forms in a function (Admin)
  • 2005/4/3 8:54

  • zoullou

  • Quite a regular

  • Posts: 250

  • Since: 2004/3/2 0


It think it have to work

3
phillipd
Re: Smarty templates and xoops forms in a function (Admin)
  • 2005/4/3 16:18

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


That answer wasn't much help. Do you have any sample or know of a module that does this?

Thanks

Doug P

4
phillipd
Re: Smarty templates and xoops forms in a function (Admin)
  • 2005/4/3 18:44

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Figured it out, simpler than I thought:

//
// Creates a menu derived from the Database
//  Pulls the template, and everything required to make a menu from MySQL
//
function myMenu($which) {
    global 
$xoopsDB;
    require_once 
XOOPS_ROOT_PATH."/class/template.php";
    
$xoopsTpl = new XoopsTpl;
    require 
XOOPS_ROOT_PATH."/class/xoopsformloader.php";
    
$form = new XoopsThemeForm("""buttonmenuform""index.php");
    
//
    // Read the menu options from the db and make an array of associative arrays (idx)
    //   then shove the array into a template container for use by a template script
    //
    
$sql 'SELECT id,label,op,file,template, title
            FROM '
.$xoopsDB->prefix('bdr_buttons').'
            WHERE grp = '
.$which.'
            ORDER BY id'
;
    
$result $xoopsDB->query($sql);
    
$i 0;
    
$row = array();
    
$idx = array();
    while(list(
$id,$label,$op,$file,$template$title) = $xoopsDB->fetchRow($result)) {
        
$row['label'] = $label;
        
$row['op'] = $op;
        
$row['source'] = $file;
        
$idx[$i] = $row;
        
$i++;
        
$xoopsOption['template_main'] = $template;
        
$xoopsTpl->assign('title',$title);
    }
    
$xoopsTpl->append('idx',$idx);

    
$form->assign($xoopsTpl);
    
$xoopsTpl->display('db:'.$xoopsOption['template_main']);
}

Login

Who's Online

265 user(s) are online (145 user(s) are browsing Support Forums)


Members: 0


Guests: 265


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