Jumi - an universal multipurpose module

Discuss the development and implementation of Joomla! modules here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Sun Nov 02, 2008 9:13 am

Have you got a fix for .pdf yet?
It is about how Joomla! processes content plugins. Not a bug but a feature.
The fix can be done through hacking of one the Joomla! core files. You will find kksou solution here.
MarHaj

bcancel
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Nov 02, 2008 1:15 pm

Re: Jumi - an universal multipurpose module

Post by bcancel » Sun Nov 02, 2008 1:58 pm

Original text deleted as meanwhile I have solved my problem.
Is it possibile to delete this post?
Thanks and best regards,
Bruno

wwwolf
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Nov 02, 2008 4:45 am

Re: Jumi - an universal multipurpose module

Post by wwwolf » Sun Nov 02, 2008 3:21 pm

Hello, I've got say that Jumi looks like a great extension, but I'm hoping you might be able to help me with an issue I've got that I think might be attached to Jumi.

I'm new to Joomla, and I have a site that runs some Jumi modules for custom code. Under testing everything is great - but when it goes live it crashes Apache after 4-8 hours, Firefox displays a 'Connection Interrupted' message, and I get error messages about:

PHP Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
PHP Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource
and
PHP Notice: Trying to get property of non-object

When ever their is a page reference, it's to one of my Jumi pages.
When the system crashes it takes the whole Apache server down with it, and I need to reboot the whole server (restarting Apache does nothing).

This may not even be a Jumi issue, but if you have any ideas I would be grateful.

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Sun Nov 02, 2008 9:39 pm

It takes the whole Apache server down...it crashes Apache after 4-8 hours...
...When ever their is a page reference, it's to one of my Jumi pages.
I am very sorry you have got problems like these ones...
Seems like something cannot read from database.
Jumi itself does not do anything with MySQL. I am afraid the problem will be somewhere else. And after 4-8 hours? Some stack overflow? I haven't got the slightest idea (even how to find it).
Will you please ask some Apache guru? Maybe he will know ...
MarHaj

wwwolf
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Nov 02, 2008 4:45 am

Re: Jumi - an universal multipurpose module

Post by wwwolf » Mon Nov 03, 2008 4:15 pm

MarHaj,
Thanks for the quick reply, I didn't really think it was going to be Jumi either - but I thought I might as well ask.
Thanks.

User avatar
alecrespi
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Mar 29, 2006 3:22 pm
Location: Italy
Contact:

Re: Jumi - an universal multipurpose module

Post by alecrespi » Tue Nov 04, 2008 11:59 am

MarHaj wrote: But it will take you some time to get acquainted with a) MySQL queries, b) php and c) Joomla to develop appropriate php script. No professional level is required; your task is not too difficult.
I do not know what your tech background is but if you already have some programming knowledge it will take you some 1(queries)+2(php)+3(Joomla) days. If not then better find somebody. Professional can make the script like that in two to three hours at worst. And you can then concentrate on visible details only.
Hi!
I've managed to create the TABLE and filling it with values. :)
I've managed to create a SQL QUERY selection
I've managed to write down a simple .PHP file (including sql selection query)
I've managed to configure JUMI to show the "result table" inside an article (using Jumi PlugIn).
W-O-W (this is a great result for me!!!)

Now another question: is it possible to use JUMI ARGUMENTS to pass sql selection filter? Or do I have to create lots of different PHP to load at different needs?
I'd like to create some "WHERE" conditions passing some arguments using JUMI.

Hoping to be clear.
Thank you again.

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Tue Nov 04, 2008 1:34 pm

Is it possible to use JUMI ARGUMENTS to pass sql selection filter
Yes, definitely.
For example your querries are the same in nature

Code: Select all

SELECT FROM `mos_downloads_log` WHERE `date` < '2008-11-04'
and only date is change

So:
{jumi [mytest.php] [2008-11-04]}, {jumi [mysql.php] [2008-06-04]}, etc
calls different query.
In your mytest.php write
$query= SELECT FROM `jos_downloads_log` WHERE `date` < $jumi[0];

Or you can pase full queries into the argument
{jumi [mysql.php] [SELECT FROM `mos_downloads_log` WHERE `date` < '2008-11-04]}
smytest.php is clear.

Or you can place there a variable(s) definition (smart solution):
{jumi [mysql.php] [$date='2008-06-04']}
And in the mytest.php

Code: Select all

eval('<?php'.$jumi[0].'?>');
(The efect is the same as you would write there $date='2008-06-04';)

You can use as many Jumi arguments as you wish. With the previous approach you can do it by only one argument too.

It depends on your taste what to choose.
MarHaj

Hermes2008
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Nov 05, 2008 2:34 am

Help for a Php Newbie!!

Post by Hermes2008 » Wed Nov 05, 2008 2:58 am

Hello!
I am not a webmaster but also a novice on Joomla. I have worked with Joomla since version 1.0.7 and I think we really control it, but I do not have much knowledge about php and that is why I need your help with the following problem .....

I just discovered JUMI and I think that is perfect for what I need, ....to insert a quiz in a Joomla module, or in an Joomla article, I do not care who is in one way or another.

The quiz works if you call from the browser http://mysite/test/dodosquiz.php?n=1, but I have no idea as to insert it into JUMI for me to work. Any idea for a beginner ?....

The code I want to insert is:

Code: Select all

<?php

/****************************************************

// Dodo's Quiz Script

// Copyrighted by Ying Zhang

// http://regretless.com/scripts

// No redistribution without authorization

// Script released under linkware

// that means LINK ME if you use it for your website

/****************************************************/



/********************************************************************************

Remember if you name this file quiz_1.php it will be quiz no. 1!

You will have to call this script by using

quiz.php?n=1

*********************************************************************************/

// Would you like to get get an email when someone takes this particular quiz?

$email_notify = 0;  // 1 = yes 0 = no

// if so

$admin_email = "you@domain.com";



// Your quiz question:

$quiz_question = "Are you the one for Dodo?";



// What you want your submit button to say?

$submit_button = "Are you the one?";



// Your quiz description:

$quiz_description = "This is a quiz that finds out your compatibility with Dodo ;) Have fun!";



// Do you want to make sure that all of your questions are answered before the results are calculated?

$all_questions_answer = 1; // 1 = yes 0 = no



// Now for each result, give it a description. Please make sure you put \ in front your quotations or you will get parse error!

// Put them as the result name => result description

// For example: "not_the_one" => "You are definitely not the one for Dodo. Too bad :(";

// WARNING: it's always possible to get the same two results so watch the order of these.

$results_array = array(

1 => "<div class=\"header\">Somewhat Close</div><div class=\"just\">You are somewhat close. You are probaby a very good friend. <br /><br />Add more your description here. blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah </div>",

2 => "<div class=\"header\">THE ONE</div><div class=\"just\">You are THE ONE! WOW.. you are my soulmate! <br /><br />Add more your description here. blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah </div>",

3 => "<div class=\"header\">EEK...</div><div class=\"just\">You are definitely not the one for me. Too bad :(<br /><br /> Add more your description here. blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah blah blab blah </div>",

);



// Now your questions

$questions_array = array(

1=> "What color does dodo like?",

2=> "What season does dodo like?",

);



// your answers. MAKE SURE it's the same order as the questions. also gives which of the results is the answer corresponding to separated by the symbol |. One unique answer per line!



$answers_array = array(

1=> "Blue|3

Red|3

Pink|1

Black|3

Rainbow|2",

// above will print as answers

// 1. Blue (this corresponds to not the one)

// 2. Red (not the one)

// 3. Pink (sorta)

// 4. Rainbow (the one)

2=> "Spring|1

Summer|3

Fall|2

Winter|3",

// above will print as answers

// 1. Spring (sorta)

// 2. Summer (not the one)

// 3. Fall (the one)

// 4. Winter (not the one)



/*******************************************

 I hope you get the idea now.

 Just add more if you have more questions.

 Make sure to change the index numbers.

 For example, the next one should begin with

 3=> "blah|1

 blah|2

 blah|3",

 always end with a quotation and a comma!

 *******************************************/



);



######### END OF QUIZ 1 DATA ##################################################

?>
Thanks in Advance! :'(

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Wed Nov 05, 2008 9:31 am

The quiz works if you call from the browser http://mysite/test/dodosquiz.php?n=1, but I have no idea as to insert it into JUMI for me to work. Any idea for a beginner ?....
Hi,
from the first sight I think the code you presented contains quiz data (questions) only.

But these data should be presented and answers should be collected by some form. And the answers should be send after pressing submit button somewhere to their processing.

So the whole quiz has to contain three blocks: quiz data, form presentation and answers processing.

Think first about the organization where these blocks will be and how they will collaborate.
For example for each quiz there could be one file. Form another file and answers processor another one.

Second: where in Joomla you want a form with various data to be presented?
You can chooose articles (each article one quiz), module (many copies of the module or one module with quiz selector), or standalone pages - component.

I suggest (but you can choose another approach) that quizes will be in articles.
So you can include a quizes (data and form) into the articles by simple
{jumi [quiz001.php]}, {jumi [quiz002.php]}, ...
And quizes processor?
I am using for this purpose chronoforms now. It sufficies to prepare just one page that waits for the quiz answers and processed them. Or you can use Jumi component which will be released soon. But both, chronoforms and component, are working in Joomla 1.5.x only.

I hope I gave you the answer that have some value to you.
MarHaj

dsands
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Sep 18, 2008 12:04 pm

Re: Jumi - an universal multipurpose module

Post by dsands » Wed Nov 05, 2008 3:14 pm

I just installed jumi in a J! 1.5 site. I made a jumi module using an included php file.

I have a php script that is working fine, except when I try to put a user-defined function in.

Then the script dies.

The function can be anything, no user-defined function works.

Specifically....

Code: Select all

<?php

defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );

function anyfunction() {

}

... rest of script

... does not work. The script dies. If you take out the user-defined function, it works fine. (commenting out the call to the function in the main script)

Any help is appreciated.


Edit:

This is a complete example of what does not work for me.

Code: Select all

<?php

defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );

function myfunc()
{
	echo "Hello world.";
}

myfunc();

?>
I get a white page.
Last edited by dsands on Wed Nov 05, 2008 3:45 pm, edited 2 times in total.

Hermes2008
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Nov 05, 2008 2:34 am

Re: Jumi - an universal multipurpose module

Post by Hermes2008 » Wed Nov 05, 2008 3:15 pm

Hello again!

First, Thank you very very much for your effort, and to answer me so fast. I'm a very gratefull Newbie!!

As you comment the code presented quiz contains data (questions) only. Indeed I have another file that is running the quiz, and a css file that controls the appearance of the form.

I have tried as you tell me, to include the code in a Joomla article, but it doesn't work. But I think my problem is that I need to call the quiz as:
quiz.php? n=1
and not just quiz.php, as in the case of jumi_demo.php.

So when in the path i write only quiz_1.php, the application that runs the form not recognize the numbre of the form I'm ussing "n=1" and doesn't work....... and that's all.

I just include the code of the form to see if you can find a way to eliminate the need to include behind php ... "? n=1" to call the quiz, because it causes the error. The form is made to use 3 types of calculation, and I only use the first, so I don't need the others and could be eliminated.

Here is the other code:

Code: Select all


<?

/****************************************************

// Dodo's Quiz Script

// Copyrighted by Ying Zhang

// http://regretless.com/scripts

// No redistribution without authorization

// Script released under linkware

// that means LINK ME if you use it for your website

/****************************************************/





/***********************************************************

// With this script you should able to make multiple quizzes

// Just call your quiz with its number.

// For example: dodosquiz.php?n=1 will include your quiz_1.php

// No changes below this unless you REALLY KNOW what you are

// doing.

/***********************************************************/



/************************************************************

// Email function added Jan 30, 2003

// Made it compatible with PHP5 April 1, 2008

/************************************************************/



if(!$_GET['n'])

	exit;

require("quiz_".$_GET['n'].".php");

include("header.php");



if($_GET['action'] == "results") {

	$choices = $_POST['choices'];

	$total_choices = count($choices);

	if($total_choices == 0) {

		echo "<div class=\"rings\">Error</div><div class=\"just\">None of the questions is answered! Please <a href=\"javascript:history.back(1)\">go back</a> and answer them!";

	} else {

		if($all_questions_answer && ($total_choices != count($questions_array))) {

			echo "<div class=\"rings\">Error</div><div class=\"just\">You didn't answer all the questions. Please <a href=\"javascript:history.back(1)\">go back</a> and answer them!";

			footer();

			include("footer.php");

			exit;

		}



		/*********************

		 MATH QUIZ RESULT

		**********************/

		if($math_quiz) {

			// calculate the results



			// declare an array the same size as choices with only 0

			$total_results = count($results_array);

			for($j=1; $j <= $total_results; $j++) {

				$int_results_array[$j]=0;

			}

		

			

			for($i=1; $i <= $total_choices; $i++) {

				$num = trim($choices[$i]);

				// if the quiz taker has choosen the correct answer

				if($num == $correct_result)

					$int_results_array[$correct_result]=$int_results_array[$correct_result]+1;

			}





			$max_value = max($int_results_array);



			// if max_value is the same as the total number of questoins

			if($max_value == count($questions_array)) {

				$right = 1;

			}



			if($right)

				$final_result=$results_array[$correct_result];

			else {

				if($math_quiz_show_correct) {

					$total = count($questions_array);

					$final_result = $results_array[$math_quiz_show_correct_before]." It seems you have gotten <b>$max_value</b> out of $total correct.".$results_array[$math_quiz_show_correct_after];

				} else {

					$final_result=$results_array[$wrong_result];

				}

			}



			echo $final_result;



			email_admin($final_result);

			footer();

			include("footer.php");

			exit;

		}

		/*********************

		 END OF THE MATH QUIZ

		**********************/





		/*********************

		 TYPE 2 QUIZ RESULT

		**********************/

		if($quiz_2) {



			// test to make sure the level array is the same size as the result array

			if(count($level_array) != count($results_array)) {

				echo "<div class=\"rings\">Error</div><div class=\"just\">The quiz maker didn't provide valid info for this quiz. If you are the quiz maker, please make your level array the same size as your result array in order for the type 2 quiz to work!</div>";

				footer();

				include("footer.php");

				exit;

			}

			// calculate the results

			$total_num_correct = 0;

			

			for($i=1; $i <= $total_choices; $i++) {

				$num = trim($choices[$i]);

				// if the quiz taker has choosen the correct answer

				if($num == $correct_result)

					$total_num_correct++;

			}



			// now $total_num_correct should contain how many problems did the quiz taker get right.

			if($total_num_correct <= $level_array[1]) {

				$final_result = $results_array[1];

				echo $final_result;



				footer();

				email_admin($final_result);

				include("footer.php");

				exit;

			}



			$total_levels = count($level_array);

			for($j=1; $j < ($total_levels-1); $j++) {

				$k=$j+1;

				if(($total_num_correct > $level_array[$j]) && ($total_num_correct <= $level_array[$k])) {

					$final_result = $results_array[$k];

					echo $final_result;



					footer();

					email_admin($final_result);

					include("footer.php");

					exit;

				}



			}



			// else the final result must the be the last

			$final_result = $results_array[count($results_array)];



			echo $final_result;



			footer();

			email_admin($final_result);

			include("footer.php");

			exit;

		}

		/*********************

		 END OF THE QUIZ II

		**********************/

			// calculate the results



			// results array

			//print_r($results_array);

			// declare an array the same size as choices with only 0

			$total_results = count($results_array);

			for($j=1; $j <= $total_results; $j++) {

				$int_results_array[$j]=0;

			}

		

			//print_r($choices);

			for($i=1; $i <= $total_choices; $i++) {

				$num = trim($choices[$i]);

				$int_results_array[$num]=$int_results_array[$num]+1;

			}



			//print_r($int_results_array);



			$max_value = max($int_results_array);



			$total_int_results_array = count($int_results_array);

			for($i=1; $i<=$total_int_results_array; $i++) {

			   if($int_results_array[$i] == $max_value) {

					$max_key = $i;

					break;

			   }

			}



			//echo "the max key is $max_key";

			//print_r($int_results_array);

			//echo "max key is  $max_key";

			$final_result=$results_array[$max_key];

			echo $final_result;



	} // end of else





} // end of the result function



function email_admin($final_result) {

	global $admin_email, $email_notify, $HTTP_USER_AGENT, $REMOTE_ADDR, $HTTP_REFERER, $quiz_question;

	// email admin if it's enabled

	if($email_notify) {



		if($final_result != "") {



			$final_email_result = str_replace("<div class=\"header\">", "", $final_result);

			$final_email_result = str_replace("<div class=\"just\">", "", $final_email_result);

			$final_email_result = str_replace("</div>", "\n\n", $final_email_result);

			$final_email_result = str_replace("<br />", "\n", $final_email_result);

			

			// get the quiz taker's info

			$date = date("Y-m-d H:i:s");

			$ip = $_SERVER['REMOTE_ADDR'];

			$browser_info = $_SERVER['HTTP_USER_AGENT'];

			$host = gethostbyaddr($ip);

			$referer = $_SERVER['HTTP_REFERER'];



			// from info

			$from_info = "

This is the result of the test taker:



$final_email_result

	

------------------------------------------------------------------------------------------

	IP: $ip

	HOST: $host

	Browser: $browser_info

	Time: $date

	Referred by: $referer

------------------------------------------------------------------------------------------";





			$subject = "Someone has taken $quiz_question quiz";



			//echo "in footer, trying to send mail: $admin_email, $final_result, $from_info, $subject";



			mail($admin_email, $subject, $from_info, "From: Test_Taker");

		} // end of if final result is not empty





	} // end of if

}

function footer() {

	echo "<div style=\"font-family: Verdana; font-size: 10px;\">Quiz made possible with <a href=\"http://regretless.com/scripts/\" target=\"_blank\">Dodo's Quiz Script</a></div>";

} // end of footer function



if(!$_GET['action']) {

	echo "<div class=\"header\">".$quiz_question."</div>\n<div class=\"just\">".$quiz_description."</div>";

	echo "<form action=\"dodosquiz.php?n=".$_GET['n']."&action=results\" method=\"post\">";

	for($i = 1; $i <= count($questions_array); $i++) {

		echo "<div class=\"rings\">".$questions_array[$i]."</div>\n";

		// find the answers

		$this_answers = explode("\n", $answers_array[$i]);

			// print the answers and modify the results

			echo "<div class=\"just\">\n";

			for($k = 0; $k < count($this_answers); $k++) {

				$this_particular_answer = explode("|", $this_answers[$k]);

				echo "<label><input type=\"radio\" name=\"choices[".$i."]\" value=\"".trim($this_particular_answer[1])."\">".$this_particular_answer[0]."</label><br /> \n";

			}

			echo "</div><br />\n";

			//print_r($this_answers);

	} // end of for

	echo "<input type=\"submit\" value=\"".$submit_button."\" class=\"form\"></form>";

} // end of if not action

footer();

email_admin($final_result);

include("footer.php");

?>
Thanks in Advance!

User avatar
alecrespi
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Mar 29, 2006 3:22 pm
Location: Italy
Contact:

Re: Jumi - an universal multipurpose module

Post by alecrespi » Wed Nov 05, 2008 3:28 pm

MarHaj wrote:
Is it possible to use JUMI ARGUMENTS to pass sql selection filter
Yes, definitely.
WOW! It runs!!! ;)
Great, I can pass arguments to create different SQL queries.

Now trying to go further... Can I pass these arguments "on the fly" using a combo box?
i.e. after selecting a value from a "drop down list" I immediately pass the new argument to the query.

Thank you in advance

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Wed Nov 05, 2008 3:47 pm

So when in the path i write only quiz_1.php, the application that runs the form not recognize the numbre of the form I'm ussing "n=1" and doesn't work....... and that's all.
I understand.
The quiz you have behaves as a standalone application. So it can call data through URL.
When you want it integrated into Joomla! you have to respect Joomla! conventions. That means rewriting the script.

If you are not php man, there is an another solution: show your application in Joomla! via iframe tag. Not too difficult but and not coder's gem.

Suppose you have to include
http://mysite/test/dodosquiz.php?n=i, where i is some digit.

write a simple php script (qqq.php) containg (except security header) only this:

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
echo '<iframe src ="http://mysite/test/dodosquiz.php?n=$jumi[0]" width="100%"></iframe>';
?>
You can add to <iframe> tag another attributes. See http://www.w3schools.com/tags/tag_iframe.asp

Calling i-th quiz from the article will be
{jumi [somepath/qqq.php] }
where i is the appropriate digit.

As I said. Not a programmer's gem. But simple enough. Will work immediately.
MarHaj

silence2
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Nov 05, 2008 3:45 pm

Re: Jumi - an universal multipurpose module

Post by silence2 » Wed Nov 05, 2008 3:50 pm

Hello,

I have Joomla 1.5 with Jumi installed.
I have created a single php file where I'm connecting to database and selecting some stuff from it. The file is called: test.php
The same database is used for Joomla.
When I access this file via url http://mysite.com/test.php it connects to db without any problems.
Once I put this file into Joomla by using {jumi [test.php]} I got connection error.
Do you know why?
Is this even possible to have a php file inside joomla with another connection do database?
Any help would be appriciated.
Thank you :)

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Wed Nov 05, 2008 4:09 pm

Can I pass these arguments "on the fly" using a combo box?
You can.
There are two approaches: standard and nonstandard one.

Standard:
combo box is a part of a form containing submit button. When the form is submitted it sends info about picked element into $_POST['element']. There has to be IF decision in your script

Code: Select all

if isset($_POST['element'])
{
   process_query();
}
else
{
   show_combo($_POST['element']);
}
But!!!
But there will be problems with Joomla! cache. For details see self calling forms on new Edo's Jumi Tips and Tricks page

Nonstandard (nonstandard for me):
javascript + php ~ AJAX
I am sorry I know too little about it to give you an advice. :( But I know it will work. :)
MarHaj

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Wed Nov 05, 2008 4:23 pm

I have a php script that is working fine, except when I try to put a user-defined function in. Then the script dies. If you take out the user-defined function, it works fine. (commenting out the call to the function in the main script)
I get a white page.

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
function myfunc()
{
   echo "Hello world.";
}
myfunc();
?>
Strange. It should work. It must work!
Under dying you mean the whole white page? No error message, no Joomla?
Have you tried to check up generated white page source code?
MarHaj

Hermes2008
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Nov 05, 2008 2:34 am

Re: Jumi - an universal multipurpose module

Post by Hermes2008 » Wed Nov 05, 2008 4:33 pm

Calling i-th quiz from the article will be
{jumi [somepath/qqq.php] }
where i is the appropriate digit.

As I said. Not a programmer's gem. But simple enough. Will work immediately.


Thank You Again for answer so fast!

It's not working for me! I only can see an empty white screen.


But don't worry!.... your words put me on the way to achieve this but in another way.

I tried to accommodate the quiz within a joomla wrapper and has worked perfect. Now I can only change the CSS and leave the quiz pretty.

Thank you very much for everything!

I hope impatient the JUMI component to change my old Joomla contact form!

Bye!

dsands
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Sep 18, 2008 12:04 pm

Re: Jumi - an universal multipurpose module

Post by dsands » Wed Nov 05, 2008 7:15 pm

MarHaj wrote:
I have a php script that is working fine, except when I try to put a user-defined function in. Then the script dies. If you take out the user-defined function, it works fine. (commenting out the call to the function in the main script)
I get a white page.

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
function myfunc()
{
   echo "Hello world.";
}
myfunc();
?>
Strange. It should work. It must work!
Under dying you mean the whole white page? No error message, no Joomla?
Have you tried to check up generated white page source code?
No error message, no joomla, no generated code, nothing.

Hermes2008
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Nov 05, 2008 2:34 am

Re: Jumi - an universal multipurpose module

Post by Hermes2008 » Thu Nov 06, 2008 10:28 am

Calling i-th quiz from the article will be
{jumi [somepath/qqq.php] }
where i is the appropriate digit.

As I said. Not a programmer's gem. But simple enough. Will work immediately.


Hello again. I followed the advice of the post next to mine, and I've checked the source code on the page, and I could see where is the error and why we can see only a blank iframe within my article.

What appears is:
<iframe src="http://mysite/test/dodosquiz.php?n=$jumi%5B0%5D" width="100%"></iframe>

As you have told me, I'm using this code in a file named test.php into my host, in the same place of dodosquiz.php file:

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
echo '<iframe src ="http://mysite/test/dodosquiz.php?n=$jumi[0]" width="100%"></iframe>';
?>
Where is the error?
Why "$jumi[0]" generates these strange characters $jumi%5B0%5D?

I have Joomla 1.5.7 stable. Is there any problem between this Joomla version and JUMI?

Thanks in advance!

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Thu Nov 06, 2008 3:08 pm

Where is the error?
Why "$jumi[0]" generates these strange characters $jumi%5B0%5D?
Oh, I am sorry. Very sorry.
New code:

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
echo '<iframe src ="http://mysite/test/dodosquiz.php?n='.$jumi[0].'" width="100%"></iframe>';
?>
MarHaj

dsands
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Sep 18, 2008 12:04 pm

Re: Jumi - an universal multipurpose module

Post by dsands » Thu Nov 06, 2008 4:15 pm

dsands wrote:
MarHaj wrote:
I have a php script that is working fine, except when I try to put a user-defined function in. Then the script dies. If you take out the user-defined function, it works fine. (commenting out the call to the function in the main script)
I get a white page.

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
function myfunc()
{
   echo "Hello world.";
}
myfunc();
?>
Strange. It should work. It must work!
Under dying you mean the whole white page? No error message, no Joomla?
Have you tried to check up generated white page source code?
No error message, no joomla, no generated code, nothing.
SOLVED

Boy do I feel stupid. :)

I had multiple modules on the same page using the same script. So after the first module loaded the script, the remaining modules were trying to redefine the function.

I changed the function to be an include file and used include_once("myfunc.php").

meeks
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Wed Sep 27, 2006 7:55 pm

Re: Jumi - an universal multipurpose module

Post by meeks » Thu Nov 06, 2008 9:04 pm

Hi.

How do I include html files containing <html>, <head> and <body> tags? On your tips and tricks page it says it will be demonstrated in another article but I can't seem to find it. Basically, what I have is a JavaScript which needs to be included in Joomla content as a <body onload="function()">. How do I do that with Jumi?

Kind regards.

Meeks.

meeks
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Wed Sep 27, 2006 7:55 pm

Re: Jumi - an universal multipurpose module

Post by meeks » Thu Nov 06, 2008 10:07 pm

meeks wrote:Hi.

How do I include html files containing <html>, <head> and <body> tags? On your tips and tricks page it says it will be demonstrated in another article but I can't seem to find it. Basically, what I have is a JavaScript which needs to be included in Joomla content as a <body onload="function()">. How do I do that with Jumi?

Kind regards.

Meeks.
Oh well, I solved it by adding window.onload = function function() to the JavaScript - hence getting rid of the <html>, <head> and <body> tags. :-)

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Thu Nov 06, 2008 10:10 pm

...No error message, no joomla, no generated code, nothing....
the remaining modules were trying to redefine the function....
I am doing the same things daily. And do not feel stupid. Do the same (=no bad feelings or remorse).
But I switched on my Joomla! (somewhere at the backend) to report errors.
So I do obtain errors. I do not like them but for me they are better then
...No error message, no joomla, no generated code, nothing....
MarHaj

Hermes2008
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Nov 05, 2008 2:34 am

Re: Jumi - an universal multipurpose module

Post by Hermes2008 » Thu Nov 06, 2008 10:38 pm

New code:

Code: Select all

<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
echo '<iframe src ="http://mysite/test/dodosquiz.php?n='.$jumi[0].'" width="100%"></iframe>';
?>
Now, Everything is working!!

Really Thank you very much!! You are a crack!!

Thanks for that usefull module and Good Luck with your new component!!.... I'm hoping for it...

Bye!!

yoinkster
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 10, 2008 2:23 pm

Re: Jumi - an universal multipurpose module

Post by yoinkster » Mon Nov 10, 2008 2:30 pm

Hi guys,
not sure if this has been asked before but can jumi access things like username when logged in to a Joomla site?
So as a very simple example,

Code: Select all

{jumi [java.php] [*username*]} <a href="#" onclick="javaFunction()">Test</a>
and then in java.php have

Code: Select all

<SCRIPT language="JavaScript">
function javaFunction() {
alert("Bonjour " + *username*);
}
</script>
Would you want to use jumi for this or can you set it in the onclick arguement to get the alert box to come up with like "Bonjour yoinkster"

yoinkster
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 10, 2008 2:23 pm

Re: Jumi - an universal multipurpose module

Post by yoinkster » Mon Nov 10, 2008 4:38 pm

Sorry to double post but thought I'd give an update for anyone that may have read my other post.
I've done a var_dump on the $_SESSION and can see that $_SESSION['username']=yoinskter in my test files, but whenever I try to do a simple
echo "Your username is {$_SESSION['username']}" in my included php file itj ust comes up with "Your username is "
Am I doing something really stupid to miss how this should be working?
All I am doing in Joomla! is

Code: Select all

{jumi [/java.php]}
and having

Code: Select all

<?php
echo "Your username is {$_SESSION['username']}";
?>
Any ideas?

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Mon Nov 10, 2008 4:53 pm

can jumi access things like username when logged in to a Joomla site?
Jumi, except other things, has access to All Joomla global variables. That means for user object too.
For Joomla 1.0.x try (maybe with preceding specification: global $my;)
if ($my->id) {
if ( $name ) {
$name = $my->name;
} else {
$name = $my->username;
}
echo $name;
?>
For J.5 see JUser object nice example visit: http://docs.joomla.org/JUser

So write a simple php script and welcome/unwelco your visitors. :)
MarHaj

yoinkster
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 10, 2008 2:23 pm

Re: Jumi - an universal multipurpose module

Post by yoinkster » Mon Nov 10, 2008 5:19 pm

Hi, I'm using J1.5.7 and I used this {as suggested} and it works fine :

Code: Select all

global $my;
if ($my->id) {
if ( $name ) {
$name = $my->name;
} else {
$name = $my->username;
}
echo $name;
}
?>
But I'm not really sure why it works. I'm new to Joomla and the way it works and fairly new to PHP as well, would you mind explaining to me what $my is? Is it just the array Joomla uses to store session/cookie info?
I read the document from your link about JUser and didn't understand much of it sorry :P Can you exmplain in really simple language :P

User avatar
MarHaj
Joomla! Ace
Joomla! Ace
Posts: 1168
Joined: Fri Jun 30, 2006 5:24 pm
Location: CZ
Contact:

Re: Jumi - an universal multipurpose module

Post by MarHaj » Mon Nov 10, 2008 8:04 pm

User is a global object. PHP object that creates Joomla!
User's information is stored in a database table. If a user is authenticated then Joomla creates global object from data stored in the database.
This object holds user specific id, username, name, email, user type, ...

How the user object relates to session/cookie I do not know.
Again I'd like to point you to
- developers.joomla.org
- docs.joomla.org and
- http://forum.joomla.org/viewforum.php?f=509
MarHaj


Locked

Return to “Modules”