Mark Donne Posted April 30, 2012 Share Posted April 30, 2012 (edited) 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 April 30, 2012 by Mark Donne Add version Number 0 Quote Link to comment Share on other sites More sharing options...
Mark Donne Posted May 17, 2012 Author Share Posted May 17, 2012 Matt, are you able to offer any advice on what the problem could be or where we are going wrong? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted May 19, 2012 Share Posted May 19, 2012 You're returning a success status so its not going to bother displaying the echo. drop that out and/or replace it with die(); 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted May 20, 2012 Share Posted May 20, 2012 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. 0 Quote Link to comment Share on other sites More sharing options...
Mark Donne Posted May 21, 2012 Author Share Posted May 21, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted May 21, 2012 Share Posted May 21, 2012 Thats because the module expects "success" for a successful call, and anything else is considered an error. You cannot return additional information with a successful action. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.