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'); ?>" />
Related
I would like to insert an alt tag into this php code
<?php $image_url='https://www.whatever.com/book2.png'; ?>
but if i try and do it the page goes blank and i guess i need that $image_url part instead of using a href
please help i have tried to do
<?php echo img(array('src'=>'www.whatever.com/book2.png', 'alt'=> 'alt information')); ?>
but it doesnt work for my page i guess it's missing the $image_url part
Since you havent provided much to go on I am taking a shot in the dark. You can try something like this:
<img src="<?php $image_url='https://www.whatever.com/book2.png'; ?>" alt="" />
Your alt tag will go in the img tag. Dont forget the width and height of the image or it will display at its original resolution.
Hope this is what you were after.
Cheers
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(); ?>
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..
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.
Form tag is stripped off in Cake Php view file.
In 'login.ctp' (Layout view)
<div id="test">
<?php echo $this->Form->create(); ?>
Test form Elements
<?php echo $this->Form->end(); ?>
</div>
When checked in firebug console only creating below tags
<div id="test">
<div style="display:none;"><input type="hidden" value="POST" name="_method"></div>
Test form Elements
</div>
// "<div style="display:none;"><input type="hidden" value="POST" name="_method"></div>". This div tag is automatically created.
I also created a 'inner.ctp' on elements in views and tried to call from layout view(login.ctp) as echo $this->element('inner') , but results in same problem
Can any one help?
I'm almost certain that you have another form on your page, probably in your layout, that you're not closing with...
echo $this->Form->end();
If this is not the case, I suggest getting the latest stable version of Cake 1.3 and overwriting your current one.