getThemePath() in block template
what am I doing wrong?
echo('<a href="' . $pageLink . '"><img src="' . $this->getThemePath() .'/images/'. $ni->getName() .'_menu.png"></a>');
$v = View::getInstance();
$v = View::getInstance(); $themePath = $v->getThemePath();
And use $themePath instead.
 Oops. Spoke too soon. Following is my template code:
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <div class="content_breakout_template"> <?php $v = View::getInstance(); $themePath = $v->getThemePath(); ?> <img class="o-logo" src="<?=$themePath?>/images/oriana_logo_35x35_trans-back.png" /> <?php $content = $controller->getContent(); print $content; echo "Theme Path: ".$themePath; ?> </div> <!-- Close breakout_shadow_centred -->
The point is to insert a logo into the top-left corner of the content box and then apply some other sytling to the box. Everything works except for the image. Most of the time the path comes out as "/images/oriana_logo_blah-blah-blah" without the proper theme path in front of it. Strange thing is, every now and again, the theme path DOES work. Can't figure that one out. Anyway, just need to get the IMG fixed and I'll be happy.
[edit 2] Threw in the "echo $themePath" line as a troubleshooting tool. It outputs "Theme Path: <blank space>" the majority of the time.
<?php $v = View::getInstance(); $themePath = $v->getThemePath(); echo "<img class=\"o-logo\" src=\"$themePath/images/oriana_logo_35x35_trans-back.png\" />"; ?>
Thanks for the suggestion, but as far as I can see it's exactly the same as what I've done outside of forcing all of the code to be inside a single PHP code block instead of mixing the PHP/HTML. I understand your thinking but that's also why I used the last block as a sanity check --> echo "Theme Path: ".$themePath. The result is the same.
Question for you: is this a custom template for the block's view, or are you trying to do this in the add/edit form?
So what you might want to do instead is include the image in the block's directory (or the custom template's directory if that's what you're doing). Then you can get THAT path using this code:
<img class="o-logo" src="<?php echo $this->getBlockURL(); ?>/images/oriana_logo_35x35_trans-back.png" />
I'm creating a package with a custom template of page_list inside. Whan i'm in the view.php of my custom template i can't get the url ou relative path to this directory (from my package) is right?
Thanks a lot a lot