I am using wordpress wpml plugin to display selected language content.
if(wpml_getLanguage()=='en'):
echo esc_attr($avocation_options['home-post-title-1']);
endif;
if(wpml_getLanguage()=='sv'):
echo esc_attr($avocation_options['home-post-title-swedish1']);
endif;
I got solution of this problem
if (ICL_LANGUAGE_CODE == 'en') {
echo wpautop($avocation_options['home-post-desc-1']);
}
if (ICL_LANGUAGE_CODE == 'sv') {
echo wpautop($avocation_options['home-post-desc-swedish1']);
}
Related
I run traffic for multiple clients on various platforms. The traffic goes to publisher sites that contain articles that link to client stores. I am trying to pass those utms through but don't want to duplicate or show unused utms
Here is the code that echos:
</script>
<?php endif; ?>
<?php $utm_source = isset($_GET['utm_source']) ? $_GET['utm_source'] : ""; ?>
<?php $utm_medium = isset($_GET['utm_medium']) ? $_GET['utm_medium'] : ""; ?>
<?php $utm_campaign = isset($_GET['utm_campaign']) ? $_GET['utm_campaign'] : ""; ?>
<?php $utm_term = isset($_GET['utm_term']) ? $_GET['utm_term'] : ""; ?>
<?php $utm_content = isset($_GET['utm_content']) ? $_GET['utm_content'] : ""; ?>
<?php $nbt = isset($_GET['nbt']) ? $_GET['nbt'] : ""; ?>
<?php $nb_placement = isset($_GET['nb_placement']) ? $_GET['nb_placement'] : ""; ?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$(function() {
$("a").attr('href', function(i, h) {
return h + (h.indexOf('?') != -1 ? "&utm_source=<?php echo $utm_source; ?
>&utm_medium=<?php echo $utm_medium; ?>&utm_campaign=<?php echo $utm_campaign; ?
>&utm_term=<?php echo $utm_term; ?>&utm_content=<?php echo $utm_content; ?>&nbt=<?PHP
echo $nbt; ?>&nb_placement=<?php echo $nb_placement; ?>" : "?utm_source=<?php echo
$utm_source; ?>&utm_medium=<?php echo $utm_medium; ?>&utm_campaign=<?php echo
$utm_campaign; ?>&utm_term=<?php echo $utm_term; ?>&utm_content=<?php echo
$utm_content; ?>&nbt=<?php echo $nbt; ?>&nb_placement=<?php echo $nb_placement; ?>");
});
});
});
</script>
Im trying to use something like this but I cant make it work
if (!empty($utm_source)) {
} else { echo "Niente";}
I am very new to coding so I apologize if this is a bad question
I've got on my page several News, to every News we can add comment via form.
So actually I've got 3 News on my index.ctp, and under every News is a Form to comment this particular News. Problem is, when i add comment, data is taken from the last Form on the page.
I don;t really know how to diverse them.
i've red multirecord forms and Multiple Forms per page ( last one is connected to different actions), and i don't figure it out how to manage it.
Second problem is, i can't send $id variable through the form to controller ( $id has true value, i displayed it on index.ctp just to see )
This is my Form
<?php $id = $info['Info']['id']; echo $this->Form->create('Com', array('action'=>'add',$id)); ?>
<?php echo $this->Form->input(__('Com.mail',true),array('class'=>'form-control','field'=>'mail')); ?>
<?php echo $this->Form->input(__('Com.body',true),array('class'=>'form-control')); ?>
<?php echo $this->Form->submit(__('Dodaj komentarz',true),array('class'=>'btn btn-info')); ?>
<?php $this->Form->end(); ?>
and there is my controller ComsController.php
class ComsController extends AppController
{
public $helpers = array('Html','Form','Session');
public $components = array('Session');
public function index()
{
$this->set('com', $this->Com->find('all'));
}
public function add($idd = NULL)
{
if($this->request->is('post'))
{
$this->Com->create();
$this->request->data['Com']['ip'] = $this->request->clientIp();
$this->request->data['Com']['info_id'] = $idd;
if($this->Com->save($this->request->data))
{
$this->Session->setFlash(__('Comment added with success',true),array('class'=>'alert alert-info'));
return $this->redirect(array('controller'=>'Infos','action'=>'index'));
}
$this->Session->setFlash(__('Unable to addd comment',true),array('class'=>'alert alert-info'));
return false;
}
return true;
}
}
you are not closing your forms
<?php echo $this->Form->end(); ?>
instead of
<?php $this->Form->end(); ?>
for the id problem you should write
echo $this->Form->create(
'Com',
array('action'=>'add/'.$id
)
);
or
echo $this->Form->create(
'Com',
array(
'url' => array('action'=>'add', $id)
)
);
I'm trying to add a way for members to comment on articles. From what I have gathered, it should be as simple as using:
<?php echo $this->content()->renderWidget('modulename.widget-name') ?>
So this is my attempt in my view:
<div>
<?php
echo("<h2>".$this->news['title']."</h2>");
print_r($this->news['news']);
echo $this->content()->renderWidget('core.comment')
?>
</div>
I only seem to get an empty <div> tag at the bottom of my page.
Does anyone know what I am doing wrong?
Edit: works for 'core.admin-dashboard' but not 'core.comment'. Why is this?
Widget core.comment will appear only if the page where you're placing this widget has subject and there is methods 'comments' and 'likes' for this subject:
if( !($subject instanceof Core_Model_Item_Abstract) ||
!$subject->getIdentity() ||
(!method_exists($subject, 'comments') && !method_exists($subject, 'likes')) ) {
return $this->setNoRender();
}
Hope this helps.
I have two controllers partners and deals.
When I add deal there is field partner id and in cakephp this generates a dropdown with all the partners. Is there away that if the user wants to add a new partner they could click a checkbox and add form would appear. Tried adding the partner input boxes and yes this creates new partner but it in the deal table it puts the partner id of the selected partner from the drop down not the new partner.
Deal Veiw
<div class="deals form">
<h2>Add New Deal</h2>
<p>Use the form below to fill in the new deals details.</p>
<?php echo $form->create('Deal');?>
<?php
echo $cksource->create();
echo $form->input('title');
echo $form->input('price');
echo $form->input('market_price');
echo $form->input('discount');
echo $form->input('buy_link');
echo $form->input('image');
$config['toolbar'] = array(
array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike', '-','BulletedList' ),
array( 'Image', 'Link', 'Unlink', 'Anchor' )
);
?><label>Deal Highlights</label><?php
echo $cksource->ckeditor('highlights', array('config'=>$config));
?><label>Deal Fine Print</label><?php
echo $cksource->ckeditor('fine_print', array('config'=>$config));
echo $form->input('description');
?><hr />
<h3>Partners Details<?php
echo $form->input('partner_id');
echo $form->input('Partner.name');
echo $form->input('Partner.address1');
echo $form->input('Partner.city');
echo $form->input('Partner.county');
echo $form->input('Partner.postcode');
echo $form->input('city_id');
?><hr />
<h3>Schedule Deal<?php
echo $form->input('start');
echo $form->input('end');
echo $cksource->end();
?>
<?php echo $form->end(__('Submit', true));?>
</div>
Deal Controller
function admin_add() {
if (!empty($this->data['Partner']['name'])) {
$this->data['Deal']['partner_id'] = "";
if ($this->Deal->Partner->saveAll($this->data)) {
$this->Session->setFlash(__('The deal has been saved', true));
$this->redirect(array('controller'=>'deals', 'action' => 'add'));
} else {
$this->Session->setFlash(__('The deal could not be saved. Please, try again.', true));
}
} else {
if ($this->Deal->saveAll($this->data)) {
$this->Session->setFlash(__('The deal has been saved', true));
$this->redirect(array('controller'=>'deals', 'action' => 'add'));
}
}
$partners = $this->Deal->Partner->find('list');
$cities = $this->Deal->City->find('list');
$this->set(compact('partners', 'cities'));
}
Any Ideas guys? If you know a better way to do it would be happy to hear it,
Thanks
Dave
in controller before saving, check if the partner form is not empty, then empty out the $this->data['Deal']['partner_id'];
I have this view:
<?php echo form_open(); ?>
<?php echo form_input('username', '', ''); ?>
<?php echo form_submit('submit', 'Submit'); ?>
<?php echo form_close(); ?>
<?php echo validation_errors(); ?>
and this controller method:
function test() {
$username = $this->input->post('username');
$this->form_validation->set_rules($username, 'Username', 'required|min_length[4]');
if ($this->form_validation->run() !== FALSE) {
echo 'Tada!';
}
$this->load->view('test');
}
but when I leave the username field blank, nothing happens. However, if I type in something in it will tell me the field is required. I've downloaded and given CI a fresh install almost ten times now, trying to load with and without different helpers etc. It's becoming really frustrating, please help.
Try using this:
$this->form_validation->set_rules('username', 'Username', 'required|min_length[4]');
The problem lies in the first parameter of set_rules, which is the field name.
The $username you're passing is basically setting the field name to validate as whatever the user puts in the input field. If you were to type 'username' into the input box, you'd see that your form validates.
Change the line
$this->form_validation->set_rules($username, 'Username', 'required|min_length[4]');
to
$this->form_validation->set_rules('username', 'Username', 'required|min_length[4]');
Maybe is the problem of this line
<?php echo form_open(); ?>
If you leave it blank it basically send back to the controller itself and calling the construct and index function only. In this case your function dealing with form processing is "test()"
try this
<?php echo form_open('yourControllerName/test'); ?> //test is the function dealing with
if it is not working try on this
<?php echo form_open('test'); ?>