1

How can I pass a value from component or set the certain value on a certain page that it then could be use in the plugin or module of joomla?

For example, in this view: index.php?option=com_mycom&view=myview will set $a = 1 (it could be generated from database).

Every time people come to this address there will be a variable $a = 1 that I could use it in my plugin.

I know some people suggest using session but it is not a good way for me to solve this problem.

John Rix
  • 6,271
  • 5
  • 40
  • 46
Duc Phan
  • 175
  • 1
  • 3
  • 14
  • 1
    I'm not sure if this is an "answer" but you can use JRequest::set/get which would make content available in the global scope but not necessarily into a cookie, and the var would only be available per page request. http://api.joomla.org/Joomla-Platform/Environment/JRequest.html – udjamaflip Aug 23 '13 at 02:40
  • as udjamaflip said, pass value through url – user1876234 Aug 24 '13 at 18:46

1 Answers1

0

Old question, I know, but there are no answers here, and things have moved on slightly from the original comment above. JRequest is now deprecated in recent versions of Joomla.

The current way to do this would be:

In your component code:

$app = JFactory::getApplication();
$app->input->set('myvar', 123);

In your module/plugin code:

$app = JFactory::getApplication();
$app->input->get('myvar');

As you say, using the session object is another way to do this, but it has the obvious downside of being persisted between web requests, which is often not what you want.

John Rix
  • 6,271
  • 5
  • 40
  • 46