Jump to content

Unable to Echo


Mark Donne

Recommended Posts

Hi

 

We are trying to output some simple HTML text in a custom module we have written but every attempt seems to come up blank.

 

I have even tried stripping the code down to 3 lines and it still does not output anything.

The following code does not output anything at all.

 

function mymodule_AdminCustomButtonArray() {

$buttonarray = array(

"View Activity" => "useractivity"

);

return $buttonarray;

}

 

function mymodule_useractivity($params) {

 

echo "<p>Testing 1 2 3</p>";

$result = "success";

return $result;

}

 

The "View Activity" button shows OK and if we press it it simply says "Module Command Success" without anything else.

 

We are using the latest version 5.0.3 under Windows.

 

What am I doing wrong?

 

Thanks

Mark Donne

Edited by Mark Donne
Add version Number
Link to comment
Share on other sites

  • 3 weeks later...
Hi

 

We are trying to output some simple HTML text in a custom module we have written but every attempt seems to come up blank.

 

I have even tried stripping the code down to 3 lines and it still does not output anything.

The following code does not output anything at all.

 

function mymodule_AdminCustomButtonArray() {

$buttonarray = array(

"View Activity" => "useractivity"

);

return $buttonarray;

}

 

function mymodule_useractivity($params) {

 

echo "<p>Testing 1 2 3</p>";

$result = "success";

return $result;

}

 

The "View Activity" button shows OK and if we press it it simply says "Module Command Success" without anything else.

 

We are using the latest version 5.0.3 under Windows.

 

What am I doing wrong?

 

Thanks

Mark Donne

 

or change it to this.

 

$result = "<p>Testing 1 2 3</p>";

$result .= "success";

return $result;

 

You should be very careful when echoing from a function in a templateing system, what it actually does is echo the line out of context of the template itself.

 

I am sure your value is echoing out, just not displaying as you would expect it to. I suggest you view the source of the page in the browser and see if it is echoed before any other display content. This is the normal case for echoing out from within a function that prints its results into a template.

Link to comment
Share on other sites

Nope, same problem.

 

:(

 

My code still returns an error if I try and assign anything but success to $result.

 

I have settled for leaving it as an error as that way I at least get some output returned as follows:

 

"Module Command Error

success - 1 Users, Last login was on 21/05/2012 from xx.xx.xx.xx"

 

The button was designed to get some data and return it in the output, namely the last time a user had logged in. It will do for now but if anyone else has any ideas then please do let me know, its always nice to see a Green Success tick rather than an error logo when running a command

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated