I'm trying to retrieve the "current" article id from an external script in Joomla! 2.5 Firstly, I included Joomla core files:
define( '_JEXEC', 1 );
defined('_JEXEC') or die('Restricted access');
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' ));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
Then, initialized the session:
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
Now, I know that for Joomla 2.5 I have to use Jinput instead of JRequest (deprecated), so:
$jAp = JFactory::getApplication();
$jInput = $jAp->input;
As already told, I'm trying to retrieve the article id. I tried many instances but nothing seems to work.
$id = $jInput->get('id', 0); // doesn't work
$idInt = $jInput->getInt('id',0); //doesn't work
Also with JRequest... I can't get current article id.
This works only if I would request data for logged in users, example:
$user = JFactory::getUser();
echo $user->username; // this works...
What I am missing? Where is my fault?
Thanks a lot to all!
$jInput->get->get("id")
? - LanceJRequest::getInt('id')
(it is deprecated but still works) should return current article id. Same as$_REQUEST['id']
. How that article is displayed? - Artur Stępień