I am trying to get the images to display in my cakephp website. My task is simple to get the website labelled below 1) which is a cakephp website to look like the website labelled 2) which is a freeware website. The layout of website 1) has the cakephp code which just calls in a view for the middle’blue section’
I am getting the paths wrong to display images/js. I am not seeing what I doing wring with loading images and js
I load images like this
echo $this->Html->image('f_pic2.jpg', array('alt' => 'CakePHP'`
I load Js like 2 ways an neither seem to have any effect.
// cant see images on website 1) that should appear from website 2). I have loaded all the files,images into the webroot img/js dir
website cakephp 1) http://18.104.22.168/maths/users/calm
website freeware 2) http://22.214.171.124/calm-pack/
I have read the docs and I dont know what I am doing wrong.
My friend read answer @ SO
I have the same or even a simpler problem. I want to put a logo in default.php for the header. I have put the logo in the folder of default.php, in the img folder, in the webroot folder and tried to access it with absolute / relative paths and the HTML helper. Nothings shows, only white space indicates something does happen. I don’t need to work with JS as far as I am concerned.
I tried the same with the cake_logo.png that is by default in the img folder. Doesn’t show either.
PS for debuggings sake: what is the proper way to retrieve the root folder? In order to confirm where <img src="" is looking?
Just put your image in webroot/img
Let say your image name is abc.jpg add the following code:
<?= $this->Html->image('abc.jpg', ['alt' => 'Image']); ?>
That doesn’t work either, as I said I tried it with the standard logo that resides there:
<?php $this->Html->image('cake-logo.png', ['alt' => 'WIA', 'url' => 'https://cakephp.org']); ?>
You should put echo in your coding. eg:
<?php echo $this->Html->image('cake-logo.png', ['alt' => 'WIA', 'url' => 'https://cakephp.org']); ?>
<?= $this->Html->image('cake-logo.png', ['alt' => 'WIA', 'url' => 'https://cakephp.org']); ?>
still doesn’t work :\
<?php echo $this->Html->image('cake-logo.png', ['alt' => '', 'url' => 'https://cakephp.org']); ?>
First it just showed the alt text as a hyperlink. Now it doesn’t show anything (as I removed the alt). I thought it might be due to using bootstrap, but after disabling that, still no result. Still white space though.
Can you post the bit of HTML that is generated by this call? That should help to determine where the problem lies.
This is the source of the page:
<a href="https://cakephp.org"><img src="/img/cake-logo.png" alt=""/></a> <img src="WIAlogo.png" alt=""> ..
As I said I had implemented bootstrap before, and even though I disabled it again, there is still a hint that the layout in general is affected:
The image above is what I have in the right bottom of my page, instead of the red-white cake logo.
If I scroll down I find out there is text and by cntrl A copy pasting I see there is an error hiding:
The request to
/debug-kit/toolbar/b92b5c68-706b-4cc0-87fb-837459d485e8 did not apply any authorization checks.
So I think that has nothing to do with the lay-out, but with setting the auth to ignore debug https://book.cakephp.org/debugkit/4/en/index.html#configuration
That little red square looks like DebugKit is trying to run, but having some issue, and the error message would seem to confirm it.
Exactly, so it should not be related to the layout right?
Another thing that changed and did not change back after disabling bootstrap, is that my clickable table elements are bold red (instead of the bold grey default).
I would like to implement bootstrap again though, but I don’t see whether and where it could have affected the default layout functions like the HTML->image , especially since I disabled the bootstrap lines