Welcome Guest, Not a member yet? Register   Sign In
returning output instead of printing it
#1

[eluser]monkster[/eluser]
Hi all,

I'm using CI within another framework. Is it possible to not let CI handle the printing of output, but rather, let it do whatever it has to do, and then returning the output somehow as a variable?

This means the end-user will not be calling CI's index.php directly, but the other framework's index.php.

Regards.

Eric
#2

[eluser]tonanbarbarian[/eluser]
About 2 thirds down the page is a section Processing Output
Controller
if you create a method in your controller call _output it can be used to override the default display of the output
Code:
function _output($output) {
  $GLOBALS['somevar'] = $output;
} // output
#3

[eluser]monkster[/eluser]
[quote author="tonanbarbarian" date="1199784845"]About 2 thirds down the page is a section Processing Output
Controller
if you create a method in your controller call _output it can be used to override the default display of the output
Code:
function _output($output) {
  $GLOBALS['somevar'] = $output;
} // output
[/quote]

Thanks.

One more question.

If I want to pass variables from one framework to CI (so CI can know which function to call), is the best way for this using $_POST?
#4

[eluser]tonanbarbarian[/eluser]
If you are including CI directly inside the other framework, like you seem to be in Joomla! then you should be able to just set the variables into the global scope in Joomla! and then grap them from the global scope in CI

Somewhere in Joomla!
Code:
global $myvar;
$myvar = 'something';
or
Code:
$GLOBALS['myvar']='something';

Anywhere in CI
Code:
global $myvar;
echo $myvar;
or
Code:
echo $GLOBALS['myvar'];

The one thing I will warn you about.
Joomla! uses quite a bit of memory by default 4-5Mb of Memory for an average page.
Add onto that Community Builder (which I noticed you are using from your other post) and it will b 6-7M (particularily because you are using plugins in CB)
This means that if you are running on a Linux box and PHP has --with-memory-limit enabled then by default in PHP 4 and PHP 5 you will be limited to 8M of memory (PHP 5.1 and 5.2 are limited to 12 I believe by default)
If you are running on windows you will not have a problem.

What this means is that you have to be very careful with your code if the site is going to run on linux because you may easily run out of memory. If that is the case you have several options
1. increase the memory in php (if you arer allowed to)
2. change your code to run in a seperate thread. i.e. curl or fsockopen to the page as a stand alone app
3. build the plugin in the CB/Joomla framework directly to save some memory
4. move onto a server with no memory limit in php

Kinda off topic i know but just wanted to warn you (have 3 years mambo/joomla experience and know a lot of the pitfalls)
#5

[eluser]monkster[/eluser]
[quote author="tonanbarbarian" date="1199810775"]If you are including CI directly inside the other framework, like you seem to be in Joomla! then you should be able to just set the variables into the global scope in Joomla! and then grap them from the global scope in CI

Somewhere in Joomla!
Code:
global $myvar;
$myvar = 'something';
or
Code:
$GLOBALS['myvar']='something';

Anywhere in CI
Code:
global $myvar;
echo $myvar;
or
Code:
echo $GLOBALS['myvar'];

The one thing I will warn you about.
Joomla! uses quite a bit of memory by default 4-5Mb of Memory for an average page.
Add onto that Community Builder (which I noticed you are using from your other post) and it will b 6-7M (particularily because you are using plugins in CB)
This means that if you are running on a Linux box and PHP has --with-memory-limit enabled then by default in PHP 4 and PHP 5 you will be limited to 8M of memory (PHP 5.1 and 5.2 are limited to 12 I believe by default)
If you are running on windows you will not have a problem.

What this means is that you have to be very careful with your code if the site is going to run on linux because you may easily run out of memory. If that is the case you have several options
1. increase the memory in php (if you arer allowed to)
2. change your code to run in a seperate thread. i.e. curl or fsockopen to the page as a stand alone app
3. build the plugin in the CB/Joomla framework directly to save some memory
4. move onto a server with no memory limit in php

Kinda off topic i know but just wanted to warn you (have 3 years mambo/joomla experience and know a lot of the pitfalls)[/quote]

Thanks for the warning. This is valuable advice for me Smile

I read from the CI user guide that "During system initialization all global variables are unset, except those found in the $_POST and $_COOKIE arrays. The unsetting routine is effectively the same as register_globals = off."

In that case I was not expecting any $GLOBALS to be present. Am I correct here?

offtopic: I already get a memory error while using CB stock... had to increase.
#6

[eluser]tonanbarbarian[/eluser]
no i think the only globals it unsets is only for things like $_GET and $_REQUEST
try it and see




Theme © iAndrew 2016 - Forum software by © MyBB