So, I am newbie in php so I feel litle confused right now.
I have a joomla! site with K2 extension. I have $this->item->imageXLarge;
inside K2 item.php
. I need to get $this->item->imageXLarge;
outside of my item.php
, but exactly in same page (in a module that is rendering in current image).
What I really tried out:
$k2itemimage = $this->item->imageXLarge;
- at the top of myitem.php
echo $k2itemimage
- inside my module, outside myitem.php
This gets Fatal error: Using $this when not in object context
Any idea of how could I get $this
variable of current imageXLarge?
EDIT -> setDefaultImage class
public static function setDefaultImage(&$item, $view, $params = NULL)
{
if ($view == 'item')
{
$image = 'image'.$item->params->get('itemImgSize');
$item->image = $item->$image;
switch ($item->params->get('itemImgSize'))
{
case 'XSmall' :
$item->imageWidth = $item->params->get('itemImageXS');
break;
case 'Small' :
$item->imageWidth = $item->params->get('itemImageS');
break;
case 'Medium' :
$item->imageWidth = $item->params->get('itemImageM');
break;
case 'Large' :
$item->imageWidth = $item->params->get('itemImageL');
break;
case 'XLarge' :
$item->imageWidth = $item->params->get('itemImageXL');
return $k2itemimage = $item->params->get('itemImageXL');
break;
}
}
At the top of your page write:
$k2itemimage = null;
then when you want to set this variable inside your object simply write:
Here is a function to check whether a variable has anything inside of it:
Put that right at the top of your script, and where ever you are trying to assign the global var simply put on the line above: