2

When I do a var_dump in my default.php file, I get all the parameters en info from my module. However, I work with a seperate PHP file that takes the params that users enter in the admin panel, and puts them into a stylesheet. Thing is, this seperate file is not able to access the modules information. When I do a var_dump, all I get is this

object(stdClass)#120 (9) {
  ["id"]=>
  int(0)
  ["title"]=>
  string(0) ""
  ["module"]=>
  string(16) "mod_improvedmenu"
  ["position"]=>
  string(0) ""
  ["content"]=>
  string(0) ""
  ["showtitle"]=>
  int(0)
  ["control"]=>
  string(0) ""
  ["params"]=>
  string(0) ""
  ["user"]=>
  int(0)
}

is there anything I should check?

  • 4
    joomla.stackexchange.com/questions/4528/… .. as mentioned in my answer to your previous question, I would strongly recommend you do not use a separate PHP file. It's simply pointless in your situation. Joomla modules have a file structure already so make full use of it. – Lodder Nov 4 '14 at 14:44
  • 1
    I fully agree with Lodder. You need to rethink your architecture. Do it in your regular module files and use JFactory::getDocument()->addStyleDeclaration('your-rules-here') (docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page) – Bakual Nov 4 '14 at 19:45
  • 1
    if you'd see the size of the stylesheet you'd understand. it worked perfectly fine in the older version of the module. I just need to know how I can read the params in this file – Hocho Nov 5 '14 at 8:59
  • 1
    I have decided to try and retrieve the params for the database. Mind you, this too is purely for practice. So, I was wondering if there was a specific way or function to read the params from the db and retrieve it as an object so that I may use it as $object->param1, etc? – Hocho Nov 5 '14 at 11:35
2

If your are looking for a way access externally to modules information and parameters, you must go directly to the database and read #__modules table / params field. Params field is a JSON encoded string, it can be simply decoded calling json_decode.

Otherwise, implement a module following Joomla! CMS practices: http://docs.joomla.org/J3.x:Creating_a_simple_module

  • how would I then go about decoding the params as a usable object, so that I can for example use params->get('fontcolor') ? – Hocho Nov 5 '14 at 11:12
  • They are enconded as JSON. You can use json_decode. – Anibal Nov 5 '14 at 16:39
1

Not sure what you are trying to accomplish but if you need to hang onto these parameters, you could try SESSION variables or session storage. This implies that you actually have access to them before your separate PHP file executes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.