I need to get the current entry ID in plugin's variable file without submitting any form. I tried this but it gave an error Undefined property: Craft\PluginNameVariable::$element
namespace Craft;
class PluginNameVariable
{
/**
*/
public function totalitemsForElements($elements = array())
{
$criteria = craft()->elements->getCriteria('MyElementType');
$criteria->elementId = $this->element->id;
$items = $criteria->find();
return $criteria->find();
}
}
I was accessing this variable through
{% set itemElementType = craft.pluginName.totalitemsForElements %}
{{ itemElementType|length }}
Please Help. Thanks in advance !!