Jump to content

Owen modul call brake the page?


Recommended Posts

Posted

Hey ho everybody,

at first... i´m the new one :)

So, now to my problem...

I try to make my owen modul.

A little "flipchart" vor arrivals etc.

I read in the devl. documentation that i should begin with the follow:

<?php
class ModuleTest extends CodonModule
{
public function index()
{
	echo "We are at index";
}

public function pageone()
{
	echo "We are at page one";
}
}
?>

if i try to call this modul via index.php/Flipcharts i will get the follow error message:

Fatal error: Cannot redeclare class ModuleTest in C:\xampp\htdocs\va\core\modules\Flipcharts\Flipcharts.php on line 14

also a little bit funny is:

if i try to call only the index.php.... the message go ahead and the complete webpage are broken...

Well, im not a native php programer like some of you....

Have anyone some ideas how to fix?

Thanks a lot and best regards

Moe

PS: Sorry for my - maybe - bad english... i´m not a native speaker. i´m from germany ;)

  • Administrators
Posted

Looks like your module class name is Flipcharts.php and then you try to declare the class as MosuleTest within the file. The folder name filename and class name all have to be the same and can only be used one time within the application.so;

folder name - > Flipcharts

filename - > Flipcharts.php

file - >

<?php
   class Flipcharts extends CodonModule    {

        public function index()    {
              echo 'Flipcharts index';
        }
}

Posted

Yeb, now it works...

Ok i didn´t know that the class name must be the same like the modulfile and folder :)

Thanks a lot

Posted

Uhm, next problem....

i try to list something from the Database....

I made the follow "test" function (just to play with some code)

public function test($count=3) {
	$sql = 'SELECT * FROM '. TABLE_PREFIX .'pilots ORDER BY totalpay Limit ' . $count;
	$res = DB::get_results($sql);
	if(!$res)
		return;
	foreach($res as $row)
	{
		//TODO: change the date format to a setting in panel
		$this->set('pilotid', $row->pilotid);	
		echo "Die PilotenID lautet: " . $pilotid . "<br>";
	}
}

It should show:

Die PilotenID lautet: 1 /next line

Die PilotenID lautet: 3 /nextline

Die PilotenID lautet: 2 /end

but it shows:

Die PilotenID lautet: /next line

Die PilotenID lautet: /nextline

Die PilotenID lautet: /end

Whats wrong? o0

i got the examplecode from the news module and changed it to list pilots...

  • Administrators
Posted

Try changing your sql syntax to:

$sql = "SELECT * FROM ".TABLE_PREFIX."pilots ORDER BY totalpay LIMIT $count";

and also change your variable in your echo

echo "Die PilotenID lautet: " . $row->pilotid . "<br>";

the assignment of;

$this->set('pilotid', $row->pilotid);

will only make the variable available in the template, and also only hold the last peice of data assigned to it through the foreach loop. You would want to assign the complete array to the variable and then break it down in your template.

$this->set('pilotid', $res);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...