I load the font-awesome.css (4.7.0) in the head tag of layout.ctp cakephp as shown below
<?php echo $this->Html->script('jquery-3.4.0.js');?>
<?php echo $this->Html->script('jquery-ui.min.js');?>
<?php echo $this->Html->script('popper.min.js');?>
<?php echo $this->Html->script('bootstrap.js');?>
<?php echo $this->Html->script('moment.js');?>
<?php echo $this->Html->css('jquery-ui.css');?>
<?php echo $this->Html->css('bootstrap.css');?>
<?php echo $this->Html->css('bootstrap-datetimepicker.min.css');?>
<?php echo $this->Html->css('all.min.css');?>
<?php echo $this->Html->css('jquery-ui.theme.css');?>
<?php echo $this->Html->css('font-awesome.css');?>
and then in my view, I just use the class called fa fa-fw fa-sort for showing sorting icon :
<td style="text-align: center;"> <?php echo __('No') ;?> <i class="fa fa-fw fa-sort"></i></td>
But result is the icon is not showed properly :
And there is an error in the console :
fontawesome-webfont.ttf:1 Failed to load resource: the server responded with a status of 404 (Not Found)
I have read several post about this issue and they solved it by setting/adding mime type to "woff2". But I don't know how to add that new mime type in cakePHP ?
I also have tried to put several fontawesome webfont, but this is not working also :
Need help. Thank you
So I finally found a solution :
I just change font directory to fonts and put fontawesome-webfont.ttf only as shown below :
And it's working like an angel
Related
I would get the image url: mysite/img/test.png but I get this link: mysite/posts/test.png
<?php echo $this->Html->link(
$this->Html->image($post['Post']['image']),
$post['Post']['title']),
array('escape' => false)
);
?>
I have to get another way the url?
Edit:
If you want link to your image, you can do in this way.
<?php echo $this->Html->link(
$this->Html->image($post['Post']['image']),
$this->Html->url('/img/'.$post['Post']['image']),
array('escape' => false)
);
?>
or
<a href="<?php echo $this->Html->url('/img/'.$post['Post']['image']); ?>">
<?php echo $this->Html->image($post['Post']['image']); ?>
</a>
I have took youtube video url and add it in database.Here is youtube share code
<iframe width="99%" height="390" src="//www.youtube.com/embed/Tj34AZuGgEs" frameborder="0" allowfullscreen></iframe>
In php it is showing well.Here is my php code
<div id="video">
<?php echo $row['video_url']; ?>
</div>
Here it is working fine.In cakephp I have used console for generate code.Here video not showing,it is showing direct url same as database table.
Here is cakephp code
<dt><?php echo __('Video Url'); ?></dt>
<dd>
<?php echo h($video['Video']['video_url']); ?>
</dd>
</dl>
How can I see the video not video source code?
Use without h function <?php echo $video['Video']['video_url']; ?>
This is the example in the book, of a simple View Template
// app/View/Common/view.ctp
<h1><?php echo $this->fetch('title'); ?></h1>
<?php echo $this->fetch('content'); ?>
<div class="actions">
<h3>Related actions</h3>
<ul>
<?php echo $this->fetch('sidebar'); ?>
</ul> </div>
And this is how it might be extended
// app/View/Posts/view.ctp
<?php
$this->extend('/Common/view');
$this->assign('title', $post);
My question is:
How can I set a default value/content for (let's say) the title, in order to overwrite if needed ?
Thank you!
Fetch the var. If its not empty, echo it, otherwise echo the default.
$title = $this->fetch('title');
echo !empty($title) ? $title : 'Default';
the problem is that on home page I have a lot of code which is added through header.php and it is not amendable through admin panel. What I want to do is to switch header files on language switch. Whenever a user press on the language icon, lets say on the English language icon the header should also switch from <?php get_header('mylanguage') ?> to <?php get_header('english') ?> or etc. Is it possible to do like this?
Regards,
In your page template instead of calling header through:
get_header();
use this to enable header switching when changing languages;
<?php if (qtrans_getLanguage() == 'de'): ?>
<?php include(TEMPLATEPATH.'/header-home-de.php' ); ?>
<?php else : ?>
<?php include(TEMPLATEPATH.'/header-home-en.php' ); ?>
<?php endif; ?>
In this example there are 2 headers depending on selected language.
Surely, it is possible in qTranslate. Even I've done qTranslate Swicher in bootstrap navigation.
<?php } if (qtranxf_getLanguage() == 'en') { ?>
English
<ul class="dropdown-menu">
<?php echo qtranxf_generateLanguageSelectCode('code'); ?>
</ul>
<?php } elseif (qtranxf_getLanguage() == 'fr') { ?>
Français
<ul class="dropdown-menu">
<?php echo qtranxf_generateLanguageSelectCode('code'); ?>
</ul>
<?php } ?>
I'm trying to have an auto complete box in my application,where the values are retrieved from a table.
I want to share a form with set of users in the Users table. i have a link called 'Share' and when I click the link, the autocomplete box is generated.
Now when I type in the text box any letter, I want it to be auto suggested.
This is my view file, /views/main/home.ctp
<?php echo $javascript->link('prototype');?>
<?php echo $javascript->link('scriptaculous');?>
<?php echo $javascript->link('effects');?>
<?php echo $javascript->link('controls');?>
$(document).ready(function(){
$(".Share<?=$r['Form']['id'];?>").click(function(){
$("#share<?=$r['Form']['id'];?>").toggle("show");
});
});
<li id="Share<?php echo $r['Form']['id']?>">
Share
<div id="share<?php echo $r['Form']['id']?>">
<?php echo $form->create('User', array('url' => '/forms/share'));?>
<?php echo $ajax->autoComplete('User.name', '/forms/autoComplete');?>
<?php echo $form->end('Share');?>
</div>
</li>
This is my auto_complete.ctp file:/views/forms/auto_complete.ctp
<?php echo $javascript->link('scriptaculous.js');?>
<?php echo $javascript->link('prototype.js');?>
<ul>
<?php foreach($users as $user): ?>
<li><?php echo $user['User']['name']; ?></li>
<?php endforeach; ?>
</ul>
And this this the function in the forms_controller: /forms/autoComplete
function autoComplete()
{
$this->set('users',$this->User->find('all',array('conditions'=>array('User.name LIKE' => $this->data['User']['name'].'%'))));
$this->layout = "ajax";
}
I get the results in the auto_complete.ctp file, i.e, if I type in the letter 's' in the autoComplete text box, I get the corresponding users in that file, but I do not get those values in the text box. Someone help me please.
Well I found the answer myself.
Autocomplete feature of cakephp does not work if you use JQuery.
I removed the line
<?php echo $javascript->link('jquery');?>
and it is working...
EDIT:
If you also want to work with jquery and need the jquery.js file, you would need to enable no-conflict mode in jQuery,as given in the site
http://docs.jquery.com/Using_jQuery_with_Other_Libraries