41
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



42
phillipd
Re: Using forms in functions
  • 2005/4/3 6:03

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I do notice that in other modules, admin functions are included from one dir back (include ../functions.php). This seems to have solved the permissions problem but I'm still working on getting forms to work. I can't find a module with Smarty templates/forms in admin modules to compare code from. I'm doing Smarty easily in admin modules now but would like to automate some menu/template stuff by putting the form code in functions with callable parameters. The explanation below really doesn't matter. I just need to get smarty/forms to work in a PHP function. I'll keep hammerng at it but I'm just not having any luck.

I put my menu button (URL) text, ops, etc in the DB and have a general routine to display anything in the DB table as a menu. To change the menu text or operation called when the link is pressed, you change the DB rather than the code. I.E.


CREATE TABLE bdr_buttons (
id int(10) unsigned NOT NULL auto_increment,
grp int(10) unsigned NOT NULL default '0',
label varchar(255) NOT NULL default '',
op varchar(255) NOT NULL default '',
file varchar(255) NOT NULL default '',
template varchar(255) NOT NULL default '',
title varchar(255) NOT NULL default '',

PRIMARY KEY (id)
) TYPE=MyISAM;

INSERT INTO bdr_buttons VALUES (1,1,'Publish','publish','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');
INSERT INTO bdr_buttons VALUES (2,1,'Issues','issues','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');
INSERT INTO bdr_buttons VALUES (3,1,'Readyness','readyness','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');
INSERT INTO bdr_buttons VALUES (4,1,'Site Stats','stats','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');
INSERT INTO bdr_buttons VALUES (5,1,'Site Participation','participate','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');
INSERT INTO bdr_buttons VALUES (6,1,'Site Admin','admin','index.php','bdr_menu.html','Bechtel Daily Report Admin Functions');

INSERT INTO bdr_buttons VALUES (7,2,'Manage Sites','mansites','index.php','bdr_menu.html','Misc Admin Functions');
INSERT INTO bdr_buttons VALUES (8,2,'Manage Colors','mancolors','index.php','bdr_menu.html','Misc Admin Functions');
INSERT INTO bdr_buttons VALUES (9,2,'Manage issues','manissues','index.php','bdr_menu.html','Misc Admin Functions');
INSERT INTO bdr_buttons VALUES (10,2,'Return to Main Menu','datechanged','index.php','bdr_menu.html','Misc Admin Functions');

INSERT INTO bdr_buttons VALUES (11,3,'Add a site','addsite','index.php','bdr_menu.html','Site Admin Functions');
INSERT INTO bdr_buttons VALUES (12,3,'Edit a site','editsite','index.php','bdr_menu.html','Site Admin Functions');
INSERT INTO bdr_buttons VALUES (13,3,'Delete a site','deletesite','index.php','bdr_menu.html','Site Admin Functions');


Doug P



43
phillipd
Re: Using forms in functions
  • 2005/4/3 5:24

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Thanks for the tip but smarty and XOOPS form stuff still doesn't work in a function even with those changes. Any other suggestions? Has anyone done this? What might I be missing?

Doug P



44
phillipd
Using forms in functions
  • 2005/4/3 3:11

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


When I put my XOOPS form code in a separate file and simply execute it like this it works fine:

if ($op == "whatever) {

include menu.php

}

But when I try to make a function out of what is in "menu.php" nothing seems to work. I then included:
include '../../../mainfile.php';
include '../../../include/cp_header.php';

This is "admin" code and I get a "You don't have permission to access this area" message.

Is it unusual to put smarty and XOOPS form code in a function? What might I be doing wrong?

Thanks

Doug P

Here is sample code of function which doesn't work but does when NOT a function:

function menu($which) {
global xoopsDB;
require_once SMARTY_DIR.'Smarty.class.php';
$xoopsTpl = new Smarty;
include XOOPS_ROOT_PATH."/header.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$form = new XoopsThemeForm("", "buttonmenuform", "index.php");

$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++;
}
echo " Which = $which Template = $template<br>";
$xoopsOption['template_main'] = $template;
$xoopsTpl->append('idx',$idx);
$xoopsTpl->assign('title',$title);

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

}



45
phillipd
What does <{$searchform.javascript}> do?
  • 2005/3/18 19:39

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm looking at some sample code in the xoops_members module and in one of the template files, xoopsmembers_searchform.html, there is the following code:

What exactly does the first line do? Please be very verbose.

<{$searchform.javascript}> <== This line, what does it do?
<b><{$searchform.title}></b>
<br /><br />
<form name="<{$searchform.name}>" action="<{$searchform.action}>" method="<{$searchform.method}>" <{$searchform.extra}>>
<table class="outer" cellpadding="4" cellspacing="1">
<!-- start of form elements loop -->
<{foreach item=element from=$searchform.elements}>
<{if $element.hidden != true}>
<tr>
<td class="head"><b><{$element.caption}></b></td>
<td class="<{cycle values="even,odd"}>"><{$element.body}></td>
</tr>
<{else}>
<{$element.body}>
<{/if}>
<{/foreach}>
<!-- end of form elements loop -->
</table>
</form>



46
phillipd
Re: Of apostrophes
  • 2005/3/4 21:56

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


OK, I found a work around with the text sanitizer. Should I have to do that?

Doug P



47
phillipd
Of apostrophes
  • 2005/3/4 21:39

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm still having trouble with apostrophes in XOOPS objects. I can instantiate a XoopsFormTextArea() with some default text including text with an apostrophe and that works fine. But when I instantiate a XoopsFormText() with text containing an apostrophe, the apostrophe and all text to the right of it just disappear. I'm obviously missing something very basic. Can someone please clue me in?

Works:

$contents = new XoopsFormTextArea("Report","report","Some default text's that contain apostrophes",12,60);

Doesn't display anything at or after the apostrophe:

$contents = new XoopsFormText("Report","report",60,255,"Some default text's that contain apostrophes");


Thanks

Doug P



48
phillipd
xoopsformtext seems to strip single quotes '
  • 2005/3/4 4:26

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


OK, well it's simpler than I thought. It appears that you can't put an "apostrophe" in a xoopsformtext gadget.

A xoopsformtextarea works ok. Why is this? No doubt it's something stupidly simple I'm missing. I note a "apostrophe" works in this forum on the "Subject" line. What am I doing wrong? Even a simple line like this doesn't show the apostrophe or anything after it:


$subtext = new XoopsFormText("Subject: ", "subject", 50, 50,"My test's");

When it renders, the apostrophe and the "s" are missing.


Thanks

Doug P



49
phillipd
Re: $_FILES is empty
  • 2005/2/23 19:48

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Once again you pull my fat out of the fire.

Thankyou VERY much!

Doug P



50
phillipd
$_FILES is empty
  • 2005/2/23 19:31

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm using XoopsFormFile in a "form" to get a filename into $_FILES in my recieving script. I'm doing it in EXACTLY the same manner as wfdownloads does it. But in my recieving script, which is the same as the form script, $_FILES is empty. My code snippet:

$darform = new XoopsThemeForm("", "darentryform", "addedit.php");

$darform->addElement(new XoopsFormFile('Attachment', 'userfile',0));
add submit button here...
$darform->display();


Recieving script:

global $_FILES;
if (empty($_FILES['userfile']['name'])) {
echo "FILES is empty...<br>";
}

Any help is greatly appreciated...

Doug P




TopTop
« 1 2 3 4 (5) 6 7 8 ... 22 »



Login

Who's Online

238 user(s) are online (164 user(s) are browsing Support Forums)


Members: 0


Guests: 238


more...

Donat-O-Meter

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

Latest GitHub Commits