| Author |
Message |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Thu Jan 15, 2009 3:38 am |
|
I'm now busy with a module, however got a small problem. I got the index part (which appears by default) and next to the an item that I call from the database I have an edit button
the link is set to "admin.php?op=testupdate&tid=$id" but when I click on it I get a blank page...
this is what I have till now (the form is not finished so not sure if it's correct)
| Code: |
$module_name = basename(dirname(dirname(__FILE__)));
if(is_mod_admin($module_name)) {
function index(){
global $prefix, $db;
include_once(NUKE_BASE_DIR.'header.php');
OpenTable();
$sql = "SELECT tid,title, content FROM test";
$result = $db->sql_query($sql)
or die ("Fout bij uitvoeren query");
OpenTable();
echo "<div>\n<a>Nuke-Evolution Test :: Modules Admin Panel</a></div>\n";
echo "<br><br>";
echo "<div>\n[ <a>" . _SP_RETURNMAIN . "</a> ]</div>\n";
CloseTable();
echo "<br>";
echo"<div><img></div><br><br>";
echo"<table>";
echo"<tr><td><font>Name</font></td><td> </td><td><font>Content</font></td><td> </td></tr>\n";
while (list($id, $title, $inhoud) = $db->sql_fetchrow($result))
{
echo"<tr>\n";
echo"<td>".$title."</td>\n";
echo"<td> </td>\n";
echo"<td>".$inhoud."</td>\n";
echo"<td><a>edit</a></td>\n";
echo"</tr>\n";
}
echo"</table>\n";
$db->sql_freeresult($result);
CloseTable();
include_once(NUKE_BASE_DIR.'footer.php');
}
function testingupdate(){
include_once(NUKE_BASE_DIR.'header.php');
OpenTable();
OpenTable();
echo "<div>\n<a>Nuke-Evolution Test :: Modules Admin Panel</a></div>\n";
echo "<br><br>";
echo "<div>\n[ <a>" . _SP_RETURNMAIN . "</a> ]</div>\n";
CloseTable();
$result = $db->sql_query("SELECT * FROM test WHERE tid='$id'");
$site_row = $db->sql_fetchrow($result);
echo "<form action=admin.php?op=testupdate' method='post' enctype='multipart/form-data'>";
echo "<input>";
echo "<input>";
echo "</form>";
CloseTable();
include_once(NUKE_BASE_DIR.'footer.php');
}
switch ($op) {
case "testupdate":
testingupdate();
break;
default:
index();
break;
}
}
else{
DisplayError("<strong>"._ERROR."</strong><br><br>You do not have administration permission for module \"$module_name\"");
die();
} |
|
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Thu Jan 15, 2009 7:07 am |
|
You only appear to have a function called testingupdate not testupdate so the link is returning to a non existant function |
_________________ Code Authors Nuke Reviews |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Thu Jan 15, 2009 7:37 am |
|
but I thought that if you call up admin.php?op=Testupdate it sends Testupdate to the switch and asks to execute the function that corresponds with Testupdate (here testingupdate(); )
I've seen that most of the switches use same case name and function.. but didn't know it would change something. I'll have a test.
well at least that's how they thought me C# |
| |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Thu Jan 15, 2009 7:42 am |
|
myeah .. meantime I based myself on the supporters module (btw it's for nuke evo 2.0.7)
I got this now:
| Code: |
if (!defined('ADMIN_FILE')) {
die('Access Denied');
}
global $admin, $bgcolor2, $prefix, $db, $admin_file;
$module_name = basename(dirname(dirname(__FILE__)));
define('NUKE_BASE_MODULES', preg_replace('/modules/i', '', dirname(dirname(dirname(__FILE__)))));
require_once(NUKE_BASE_MODULES.'mainfile.php');
get_lang($module_name);
if(is_mod_admin($module_name)) {
switch ($op) {
case "Testupdate":include(NUKE_MODULES_DIR.$module_name.'/admin/Testupdate.php');break;
case "Testadd":
break;
default:include(NUKE_MODULES_DIR.$module_name.'/admin/Main.php');break;
break;
}
}
else{
DisplayError("<strong>"._ERROR."</strong><br /><br />You do not have administration permission for module \"$module_name\"");
die();
} |
just like the supporter module, but still no luck. |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Thu Jan 15, 2009 9:48 am |
|
I'm not familiar with Evo but I would do something like this for *nuke
| Code: |
if (!defined('ADMIN_FILE')) {
die('Access Denied');
}
global $admin, $bgcolor2, $prefix, $db, $admin_file;
$module_name = 'YOUR_MODULE_NAME';
require_once('mainfile.php');
get_lang($module_name);
if(is_mod_admin($module_name)) {
switch ($op) {
case 'Testupdate':
include_once(''.$module_name.'/admin/Testupdate.php');
break;
case 'Testadd':
break;
default:
include_once(''.$module_name.'/admin/Main.php');
break;
}
}
else {
DisplayError('<strong>'._ERROR.'</strong><br><br>You do not have administration permission for module '.$module_name.'');
die();
} |
You would probably still get a blank page though as have not included the header and footer elements |
_________________ Code Authors Nuke Reviews |
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Thu Jan 15, 2009 1:24 pm |
|
You should also turn on error reporting and that will sometimes lead you straight to the problem. |
| |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Thu Jan 15, 2009 2:30 pm |
|
is that in the config?
got this, but no errors are displayed, just white page:
$debug = true; |
| |
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Thu Jan 15, 2009 2:38 pm |
|
I'm not exactly now that works in evo, but yes, that seems like it would be the setting.
for quick tests you can do stuff like this...
| Code: |
case 'test':
echo 'this is a test';
break;
|
then access admin.php?op=test
also, a surefire way to show errors would be to add something like this to the top of your script
| Code: |
ini_set('display_errors', true);
error_reporting(E_ALL); |
|
| |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Thu Jan 15, 2009 3:25 pm |
|
the echo doesn't work but when I access the module I created I get this (because I added the error thing):
Notice: Constant _AB_WARNED already defined in C:\xampp\htdocs\Nuke-evo\language\blocks\lang-english.php on line 49
Notice: Constant _NEWSLETTER already defined in C:\xampp\htdocs\Nuke-evo\language\blocks\lang-english.php on line 91
Notice: Constant _THEMES_DEFAULT already defined in C:\xampp\htdocs\Nuke-evo\language\blocks\lang-english.php on line 92 |
| |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Sat Jan 17, 2009 1:21 pm |
|
[update]
oooh ok I found why, I had to add the same switch/case options in the case.php wooooot lol
| Code: |
/*=======================================================================
Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
=======================================================================*/
if (!defined('ADMIN_FILE')) {
die('Access Denied');
}
$module_name = basename(dirname(dirname(__FILE__)));
get_lang($module_name);
switch ($op) {
case "Test":
case "testing":
include(NUKE_MODULES_DIR.$module_name.'/admin/index.php');
break;
} |
|
| |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Sun Jan 18, 2009 9:58 am |
|
I'm in the update part but just can't seem to update correctly, when I submit it does not update, what am I doing wrong? any help would be appreciated:
this is Testupdate.php
| Code: |
$result = $db->sql_query("SELECT * FROM " . $prefix . "_test WHERE tid='$tid'");
$site_row = $db->sql_fetchrow($result);
include_once(NUKE_BASE_DIR.'header.php');
OpenTable();
echo "<div align=\"center\">\n<a href=\"$admin_file.php?op=SPMain\">" . _SP_ADMIN_HEADER . "</a></div>\n";
echo "<br /><br />";
echo "<div align=\"center\">\n[ <a href=\"$admin_file.php\">" . _SP_RETURNMAIN . "</a> ]</div>\n";
CloseTable();
OpenTable();
echo"<br /><br /> <center>";
echo "<form action='".$admin_file.".php?op=Testeditsave' method='post' enctype='multipart/form-data'>";
echo "ID: ".$site_row['tid']."<br />";
echo "<input type='hidden' name='title' value='".$site_row['tid']."'>";
echo "Title: <input type='type' name='title' value='".$site_row['title']."'><br /><br />";
echo "Content: <input type='type' name='title' value='".$site_row['content']."'><br /><br />";
echo "<input type='submit' value='Update'>";
echo "</form>";
echo"</center>";
CloseTable();
include_once(NUKE_BASE_DIR.'footer.php'); |
and in index.php of the admin:
| Code: |
if (!defined('ADMIN_FILE')) {
die('Access Denied');
}
$module_name = basename(dirname(dirname(__FILE__)));
define('NUKE_BASE_MODULES', preg_replace('/modules/i', '', dirname(dirname(dirname(__FILE__)))));
require_once(NUKE_BASE_MODULES.'mainfile.php');
get_lang($module_name);
global $prefix, $db, $admdata;
if(is_mod_admin($module_name)) {
function Testeditsave ($tid, $title, $content){
global $prefix, $db, $admin_file;
$title = Fix_Quotes($title);
$content = Fix_Quotes($content);
$tid = intval($tid);
$db->sql_query("update ".$prefix."_test set title='$title', content='$content' where tid='$tid'");
redirect($admin_file.".php?op=Test");
}
switch ($op) {
case "Testupdate":include(NUKE_MODULES_DIR.$module_name.'/admin/Testupdate.php');break;
case "Testeditsave":
Testeditsave($tid, $title, $content);
break;
case "Test":include(NUKE_MODULES_DIR.$module_name.'/admin/Main.php');break;
}
}
else{
DisplayError("<strong>"._ERROR."</strong><br /><br />You do not have administration permission for module \"$module_name\"");
die();
} |
|
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Sun Jan 18, 2009 10:27 pm |
|
Well I would never use $content as that is a global variable already in use for blocks.
Follow the logic of your code and at each step echo out any data that you need to use.
For example in your function testeditsave you are passing $tid, $title, $content so the first thing to is add something like
| Code: |
echo 'The tid is: '.$tid.'<br>The title is: '.$title.'<br>The content is: '.$content.' '; //diagnostic |
If you can see that data is missing and your table fields are 'not null', that would could the sql update to fail but more importantly you know to follow the data back to it's source if it isn't getting passed. |
_________________ Code Authors Nuke Reviews |
|
|
 |
krike

Joined: Apr 02, 2008
Posts: 68
|
Posted:
Mon Jan 19, 2009 5:43 am |
|
thanks I allready got it working and it's for a module (administration part). in my table I have the column content, that's why i have the variable $content. I think it's better to renaim it to something else lol. |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Mon Jan 19, 2009 6:22 am |
|
Cool, glad you got it working.
Whenever I'm developing code I always try to give my functions and variables a naming convention that is unique to help prevent any conflicts with existing code. All my commercial scripts at Code Authors usually use something like ca_moduleInitials_something. |
_________________ Code Authors Nuke Reviews |
|
|
 |
|
|