PLease help me with this code
<?php
if (!empty($this->product->customfieldsSorted['youtube'])) {
$this->position = 'youtube';
echo '<button class="shop_tablinks tab2" onclick='"openSpecs(event, 'Specs3')"' >';
echo JText::_('Video');
echo '</button>';
} // Product Custom ontop end
?>
It seems I don't wrote ok the
onclick='"openSpecs(event, 'Specs3')"' >'
Replace you code with below:
<?php if (!empty($this->product->customfieldsSorted['youtube'])) {
$this->position = 'youtube';
echo '<button class="shop_tablinks tab2" onclick="openSpecs(event, \'Specs3\')">';
echo JText::_('Video');
echo '</button>';
} // Product Custom ontop end
?>
Need to use escape operator for '' if you want to use in html code while echoing as you are echoing with ''. So in HTml code its taking it as concat operator.
Change your line
echo '<button class="shop_tablinks tab2" onclick='"openSpecs(event, 'Specs3')"' >';
to
echo '<button class="shop_tablinks tab2" onclick="openSpecs(event, \'Specs3\')" >';
final code:
if (!empty($this->product->customfieldsSorted['youtube'])) {
$this->position = 'youtube';
echo '<button class="shop_tablinks tab2" onclick="openSpecs(event, \'Specs3\')" >';
echo JText::_('Video');
echo '</button>';
}
Related
I am dynamically creating the checkbox input fields with text lables, and trying to create a treeview when I click any item in the tree the first check box is always toggling.What can be the possible reason.
if($category->visible==1){
echo '<div class="categorylist level'.$depth.' cat">';
$count=$DB->count_records('course',['category'=>$category->id]);
if($count>0){
echo '<div class="parent">';
if($depth>0){
$indent=10;
for($i=0;$i<=$depth;$i++){
$indent=$indent+$depth;
echo '<div style="margin-left:'.$indent.'px">';
}
}
echo '<input type="checkbox" id="category" name="cat[]" value='.$category->id.'/>';
echo '<label for="category"'.$category->id.'"><span class="">'.$category->name.' ('.$count.')</span></label><br>';
if($depth>0){
for($i=0;$i<=$depth;$i++){
echo '</div>';
}
}
echo '</div>';
}
else{
echo '<div class="parent">';
if($depth>0){
$indent=10;
for($i=0;$i<=$depth;$i++){
$indent=$indent+$depth;
echo '<div style="margin-left:'.$indent.'px">';
}
}
echo '<label for="category"><span class="">'.$category->name.' ('.$count.')</span></label><br>';
if($depth>0){
for($i=0;$i<=$depth;$i++){
echo '</div>';
}
}
echo '</div>';
}
echo '</div>';
}
Just checked this <label for="category"'.$category->id.'"> could be your issue, label with duplicate for attribute can cause this issue, make sure that you have no label with same $category->id
I am not sure how to keep my checkbox checked after I hit the Apply button. I am thinking I have to add is_set to the output but I am not sure how or where to add it in. Here is my code below any help would be great.
<div id="product-filter-options">
<form method="GET">
<?php
$scooters = $_GET['scooters'];
$product_type = $_GET['product_type'];
$bike_sub_category = $_GET['bike_sub_category'];
$model_year = $_GET['model_year'];
?>
<?php
function get_terms_chekboxes($taxonomies, $args) {
$terms = get_terms($taxonomies, $args);
foreach($terms as $term) {
$output .= '<span><label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$taxonomies.'" value="'.$term->slug.'" >' .$term->name.'</label></span>';
}
return $output;
}
echo '<div class="check-contain">';
echo '<h4>Bicycle Brand</h4>';
echo get_terms_chekboxes('scooters', $args = array('hide_empty'=>true));
echo '<span class="slide-show-more">See More</span>';
echo '</div>';
echo '<div class="check-contain">';
echo '<h4>Bicycle Type</h4>';
echo get_terms_chekboxes('product_type', $args = array('hide_empty'=>true));
echo '<span class="slide-show-more">See More</span>';
echo '</div>';
echo '<div class="check-contain">';
echo '<h4>Bicycle Sub-Type</h4>';
echo get_terms_chekboxes('bike_sub_category', $args = array('hide_empty'=>true));
echo '<span class="slide-show-more">See More</span>';
echo '</div>';
echo '<div class="check-contain">';
echo '<h4>Model Year</h4>';
echo get_terms_chekboxes('model_year', $args = array('hide_empty'=>true));
echo '<span class="slide-show-more">See More</span>';
echo '</div>';
?>
<button type="submit">Apply</button>
Thanks in advance.
so I am new to codeigniter and PHP and I have a problem. I can't get the proper syntax to execute an echo within an echo. In my code, the else won't work since I'm using another php code to get the site_url() in codeigniter. Here's the code.
<td><?php if($row->homeowner_feedback == 0) {echo "Finished"; } else { echo '<button type="button" class="btn btn-custom-3" data-href="<?php echo site_url() . "user_tracking/set_finished_recent/" . $row->ticketid; ?>" data-toggle="modal" data-target="#delete-modal">Set as Finished</button>'?></td>
Try like this.load url helper first using $this->load->helper('url'); in controller.use dot(.) for concatenation rateher than nested echo.
<td><?php if($row->homeowner_feedback == 0)
{
echo "Finished";
} else {
echo "<button type='button' class='btn btn-custom-3' data-href='".base_url()."'/user_tracking/set_finished_recent/".$row->ticketid."' data-toggle='modal' data-target='#delete-modal'>Set as Finished</button>";
} ?></td>
Just for fun, when you have an if/else that is performing the same function, in this case echo'ing something, you could use this ternary operation instead (Tested).
<td>
<?= ($row->homeowner_feedback == 0)
? 'Finished'
: '<button type="button" class="btn btn-custom-3" data-href="' . base_url() . '/user_tracking/set_finished_recent/' . $row->ticketid . ' data-toggle="modal" data-target="#delete-modal">Set as Finished</button>';
?>
</td>
i would like to change a link to target="_blank" (opening in a new window, or tab) but can#t fix it. i´m a fool in php and my try&error-method did´t work. can anybody help me?
Thank you so much!
original code from the parallax one theme (wordpress)
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo ''.$parallax_one_contact_item->text.' ';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo ''.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'';
} else {
echo ''.esc_attr($parallax_one_contact_item->text).'';
}
}
echo '</div>';
}
}
}
?>
Simply add target="_blank" in your anchor tag. For example :
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
Try this:
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo '<a target="_blank" href="" class="strong">'.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'</a>';
} else {
echo '<a target="_blank" href="" class="strong">'.esc_attr($parallax_one_contact_item->text).'</a>';
}
}
echo '</div>';
}
}
}
?>
Note: Added target="_blank" in each hyperlink.
What is wrong here..
<?php if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
} ?>
The result of this:
index.php?page=25&id=<?php%20echo%20$user[id];%20?>
Modify your code accordingly :
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
Change
This
<?php
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
?>
Into this
<?php
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
?>
PHP tag is not necessary inline of echo, that is your error.
Update
The $user variable is a object but used as an array.
In you code, change
echo '<li>My Profile
to this
echo '<li>My Profile
In object you have to refer to its key with -> as in arrays you do []