0

I did an override for joomla core mod_menu. But if I try to insert an image like this...

<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/image.png">

... it didnt work. The side loads only the content of the menu without any styling. If I insert the direct link without any php it works. In my template index.php the same code works fine. Does somebody know how I can link to an image in an html override, without a hard coded url?

4

You may get an PHP error or warning. That would explain why you see the menu without styling. You should enable error reporting on your server to see these errors/warnings.

What is the value of $this->baseurl and $this->template? Are these variables really available in your override? You can check the values with PHP's var_dump() function:

<?php var_dump($this->baseurl); ?>

My guess is that these or at least one of these variables is null, because they are not defined. If I'm correct you can use this code to get your URLs:

<img src="<?php echo JUri::base(true); ?>/templates/<?php echo JFactory::getApplication()->getTemplate(); ?>/images/image.png" /> 
1

You can try this one:

<img src="<?php echo JUri::root(); ?>/templates/<?php echo JFactory::getApplication()->getTemplate(); ?>/images/image.png" /> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.