getThemePath in block behaving very oddly

Permalink
In the power slider lite block, I'm trying to get the themepath:

$v = View::getInstance();
$themePath = $this->getThemePath();
$mobileCheck = strpos($themePath,'Mobile');
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
$isiPad = false;
if(strstr($useragent,'ipad')) {
   $isiPad = true;
}


and in the foreach loop, I have:

<?php if($mobileCheck && $isiPad === false){ // if is a mobile device but not an ipad ?>
<img src="<?php   echo $ih->getThumbnail($f, 480, 480)->src; ?>">
<?php } else if($isiPad){ // if it is an ipad ?>
<img src="<?php echo $ih->getThumbnail($f, 1024, 1024)->src; ?>">
<?php } else { ?>
<img src="<?php echo $ih->getThumbnail($f, 1400, 910)->src; ?>" width="640">
<?php } ?>


The code never returns the themepath unless I force it to throw an error by placing something like this after the foreach:

<!--<img src="<?php echo $ih->getThumbnail($f, 1400, 910)->src; ?>" width="640" test="<?php $vs->getThemePath() ?>">-->


Because the $vs should be $v, it errors out which somehow allows it to accurately grab the themepath. Otherwise, it just comes out blank each time.

I don't know if this is related to the problem or not, but each time I update the blocks view, I have to load it to the server, go back into edit mode and then reselect the custom template before it will display the new changes.

 
Kalindor replied on at Permalink Reply
You should be able to get the themePath, if you use $v instead of $this:

$v = View::getInstance(); 
$themePath = $v->getThemePath();


That at least works for me.
TNTdesign replied on at Permalink Reply
Thanks, that's what I actually tried initially but it was giving me the same results, which is that it was not giving me the theme path most of the time, unless I forced it to error out. Any idea as to why with even using $v it won't work?