Polylang Adding script code according to the language used - multilingual

I want to use tawk.to chatbot on my website. But I need to use different tawt.to code in en language and different in tr language. I do this in WPML plugin, but I couldn't do it in polylang plugin. Does anyone have information?
Example in WPML plugin
<?php
$current_language_code = apply_filters( 'wpml_current_language', null );
if($current_language_code == 'en'):
?>
<!--Start of Tawk.to Script-->
EN Script Code
<!--End of Tawk.to Script-->
<?php
elseif($current_language_code == 'tr'):
?>
<!--Start of Tawk.to Script-->
TR SCRİPT CODE
<!--End of Tawk.to Script-->
<?php
endif;
?>

Related

View inside a view using CakePHP 3

Is it possible to display a view inside another view?
I have the following code:
<?php if ($result->type === 'brochure') : ?>
<div>
// massive template block
</div>
<?php elseif ($result->type === 'library') : ?>
<div>
// massive template block different from above
</div>
<?php else : ?>
<div>
// massive template block different from both above
</div>
<?php endif; ?>
I want to replace those with a content block so to speak. I had a look at view blocks but I'm either using it wrong or it doesn't do what I want it to do.
Is this possible in CakePHP 3?
you can use elements for that.
first you should create elements in src/Template/Element directory with .ctp format like this
// in brochure.ctp file in src/Template/Element
<div>
// your massive template block
</div>
then you can call elements like this :
<?php if ($result->type === 'brochure') : ?>
<?= $this->element("brochure") ?>
<?php elseif ($result->type === 'library') : ?>
<?= $this->element("library") ?>
<?php else : ?>
<?= $this->element("default") ?>
<?php endif; ?>

CakePHP youtube video not showing

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']; ?>

I can't load blocks in my default.ctp

I want to use the blocks statements in my application. I have a theme called: Boostrap. If I use only the statement $this->element() my elements load without problems, but if I use $this->start() and $this->end() I can't load my elements.
I try create a new file called index.ctp for a TestsController but the result is the same. I put $this->fetch('header') and $this->fetch('footer') in this file and nothing.
That's only an example of my real structure:
Themed\Boostrap\Layouts\default.ctp:
<html>
<head>
<title></title>
</head>
<body>
<?php $this->start('header'); ?>
<?php echo $this->element('header'); ?>
<?php $this->end(); ?>
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
<?php $this->start('footer'); ?>
<?php echo $this->element('footer'); ?>
<?php $this->end(); ?>
</body>
</html>
Themed\Boostrap\Elements\header.ctp:
<header>
<h1>Hello World!!</h1>
</header>
Themed\Boostrap\Elements\footer.ctp:
<!-- app/views/themed/boostrap/elements/footer.ctp -->
<footer>
Copyright (c) Bla bla bla 2014.
</footer>
Details of my environment:
S.O: Windows 7
CakePHP Versión: 2.4.4
PHP Versión: 5.3.28
You're layout should define the block output, not the start and end methods:
<?php echo $this->fetch('header'); ?>
Then, in your view, you outline the block that will be outputted:
<?php $this->start('header'); ?>
<?php echo $this->element('header'); ?>
<?php $this->end(); ?>
Given this use case, blocks don't seem like the right solution. Your element seems like it would be the only thing to display, in which you would output the element on the layout. However, a more appropriate use case would be different output at a per-page level.
In your layout:
<?php echo $this->element('header'); ?>
<?php echo $this->fetch('header_block'); ?>
Page one:
<?php $this->start('header_block'); ?>
//Something unique to page 1
<?php $this->end(); ?>
Page two:
<?php $this->start('header_block'); ?>
//Something unique to page 2
<?php $this->end(); ?>

Is it possible to get a different header.php on language switch with qtranslate (Wordpress)?

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 } ?>

Help with the auto complete method in cakephp

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

Resources