I was trying to call logo in custom phtml file with following code.
<?php echo $this->getLayout()->createBlock("Magento\Theme\Block\Html")->setTemplate("Magento_Theme::html/header/logo.phtml")->toHtml(); ?>
We can call logo with following code..
<?php echo $this->getLayout()->createBlock("Magento\Theme\Block\Html\Header\Logo")->setTemplate("Magento_Theme::html/header/logo.phtml")->toHtml(); ?>
Related
I have created a simple hello world module can someone please tell me how to add an image below Hello World.
I need to add image to phtml file
phtml file like below
<h2>Hello World></h2>
<img src = "<?php echo $block->getViewFileUrl('images/demo.jpg')"
images directory like below
app/code/Test/HelloWorld/view/frontend/web/images
Please try the below code,
<img src="<?php echo $block->getViewFileUrl('Test_HelloWorld::images/demo.jpg'); ?>" />
I am making a custom home page for my magento website in a phtml file named home_banner.phtml, which in turn i have referenced in the CMS->Pages->Home Page content by the following code
{{block type="core/template" template="theme/home_banner.phtml"}}
In my home_banner.phtml I have called tags/popular.phtml to display the popular tags.
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
However the tags are not being displayed even though the anchor tag which says "view all tags" id getting called correctly. The ul class="tags-list" is also visible in the page source but the tags themselves are not visible. Any suggestions?
You made a small mistake in the template file. Your template file has to be as below:
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('tag/popular')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
I tested this and its working fine.. Hope this helps..
At the moment I try to translate my web application with zend_translate.
I made it already that far to translate the view in the application.
At the moment I struggle with the follow thing. I want to translate my navigation items
who I setup by application.ini . I have no clue how to make this thing working.
I hope someone can show me an clear example with some description.
With kind regards,
Nick
don't you run through the navigation items in the view? like this
<?php
// in controller something like:
// pseudocode: $this->view->nav_items = My_Model_Nav::getItems();
// somewhere in the view:
?>
<ul>
<?php foreach ($this->nav_items as $item) : ?>
<li><?php echo $item['name']; ?></li>
<?php endforeach; ?>
</ul>
i think in this case, you only have to change one line into:
<li><?php echo $this->_($item['name']); ?></li>
if not, post your view snippet
I created one view called myview.php in my modul(Named adminpanel)
path(adminpanel\views\myview.php) in that I use following code but Assets are not load
<?php
use Fuel\Core\Asset;
use Fuel\Core\Session;
?>
<html>
<head><title>Admin Panel</title>
<?php Asset::js(array('jquery.js','test.js'));?>
</head>
<body>
<?php echo Session::get('my');?>
<input type="button" value="Call Designer Controller" >
</body>
here test.js and jquery.js are not work properly and I donot get any error in my browser
Asset::js() returns the HTML required to load the assets as a string.
If you don't ECHO it, nothing will happen.
I have two xml menu. I set it up this way:
<?php echo $this->Navigation($this->menuPrivate)->menu(); ?>
<hr />
<?php echo $this->Navigation($this->interfaceMenu)->menu(); ?>
<?php
echo '<pre><br/>';
var_dump($this->Navigation($this->interfaceMenu));
die();
?>
Within var_dump is correct data. But the menu rendering shows me the same result - $this->interfaceMenu the same as $this->menuPrivate.
So is it possible to setup different menu for one view?
Sorry, my fault. It should be look like:
<?php echo $this->Navigation()->menu($this->menuPrivate); ?>
<hr />
<?php echo $this->Navigation()->menu($this->interfaceMenu); ?>