javascript dropdown not loading in time - php

My problem is that I am trying to create a javascript menu but the script seems to be loading really slow and late so it's not working on the first seconds. Correct me if I am wrong.
Second, I don't manage to make each column to work well and sometimes it's just linking to the same page, no matter which option I choose as well to another problem that there is no reaction to my choice, like I didn't do anything even if I really chose something from the menu.
Do you know what can be the problem? Is it a bad idea to do it with JavaScript? Would you make it with PHP? I also thing that the code is maybe too long.
This is the example for my problem - link
<div class="quick_width">
<div class="quick_links"><img src="http://www.101greatgoals.com/wp-content/themes/tutorial/images/quick_links.jpg" width="102" height="37" alt=" "></div>
<div class="green_bg">
<div class="option_width">
<div class="form_row_name_input1">
<ul class="dropdownul">
<li id="categories">
<?php wp_dropdown_categories('show_option_none=Country'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/category/goals/"+dropdown.options[dropdown.selectedIndex].text.split(' ').join('-');
}
}
dropdown.onchange = onCatChange;
--></script>
</li>
</ul>
</div>
<div class="form_row_name_input1">
<ul class="dropdownul">
<li id="categories">
<?php wp_dropdown_categories('taxonomy=teams&show_option_none=Teams&name=teamsmenu'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("teamsmenu");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/?teams="+dropdown.options[dropdown.selectedIndex].text.split(' ').join('-');
}
}
dropdown.onchange = onCatChange;
--></script>
</li>
</ul>
</div>
<div class="form_row_name_input1">
<ul class="dropdownul">
<li id="categories">
<?php wp_dropdown_categories('taxonomy=players&show_option_none=Players&name=playersmenu'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("playersmenu");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/?players="+dropdown.options[dropdown.selectedIndex].text.split(' ').join('-');
}
}
dropdown.onchange = onCatChange;
--></script>
</li>
</ul>
</div>
<div class="form_row_name_input1">
<ul class="dropdownul">
<li id="categories">
<?php wp_dropdown_categories('taxonomy=managers&show_option_none=Managers&name=managersmenu'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("managersmenu");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/?managers="+dropdown.options[dropdown.selectedIndex].text.split(' ').join('-');
}
}
dropdown.onchange = onCatChange;
--></script>
</li>
</ul>
</div>
<div class="form_row_name_input1">
<ul class="dropdownul">
<li id="categories">
<?php wp_dropdown_categories('taxonomy=clean_feeds&show_option_none=Other&name=othermenu'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("othermenu");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/?clean_feeds="+dropdown.options[dropdown.selectedIndex].text.split(' ').join('-');
}
}
dropdown.onchange = onCatChange;
--></script>
</li>
</ul>
</div>
</div>
</div>
<div class="right_align"></div>
</div>

In this case, I would definitely recommend creating the HTML output through PHP beforehand. This way, when the page has loaded you can trigger your menu-script.
The example provided in the WordPress reference for the wp_dropdown_categories() function has a cool example which should help you on your way. What it does is basically replace certain parts of the generated HTML. These replacements in your case would then be mainly in the generated URL. Example reproduced here for clarity:
<li id="categories">
<h2><?php _e('Posts by Category'); ?></h2>
<form action="<?php bloginfo('url'); ?>/" method="get">
<div>
<?php
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript>
</div></form>
</li>

Related

Listing page redirect issue in php

I'm working on php, I have fetched all the data from database and and I have to show listing the page,I have to show all the dynamic date in listing page & I'm fetching all the data from database but how to redirect and show listing page, how I tried this I'm not getting please check my code and help me.
Here my HTML code:
<div class="col-lg-3 col-md-6 test" data-idtest="Diabetes">
<a href="javascript:void(0);" class="box_cat_home">
<i class="icon-info-4"></i>
<img src="assets/img/icon_cat_3.svg" width="60" height="60" alt="">
<h3>Diabetes</h3>
<ul class="clearfix">
<li><strong>124</strong>Doctors</li>
<!-- <li><strong>60</strong>Clinics</li> -->
</ul>
</a>
</div>
my Jquery code:
<script type="text/javascript">
$(document).ready(function() {
$('.test').click(function (){
var id = $(this).data('idtest') ;
alert(id);
$.ajax({
type: "POST",
url : "speciallist.php",
data : {id:id },
cache: false,
success: function(data){
console.log(data);
}
});
})
});
</script>
Here my PHP code:
<?php
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = 'mysql';
$dbName = 'fre';
$db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
$id =$_REQUEST['id'];
$men ="select * from tbl_users where doctor_speciality='$id'";
$men_result=$db->query($men);
$projects=array();
while($row=mysqli_fetch_assoc($men_result)){
$projects[] = $row;
}
?>
dynamic Listing page: speciallist.php
<div class="col-lg-12 list-items">
<?php foreach($projects as $row){
$userId = $row['userId'];?>
<div class="strip_list wow fadeIn">
<figure>
<!-- <img src="http://via.placeholder.com/565x565.jpg" alt=""> -->
<img src="<?php echo "admin/uploads"."/".$row['doctor_image']; ?>"
</figure>
<h3><?php echo $row['name']; ?></h3>
<p><!-- Doctor Education : --> <?php echo $row['doctor_education']; ?>,<?php echo $row['doctor_speciality']; ?></p>
<p> 9 years experience</p>
<p>Gynecologist/Obstetrician</p>
<!-- <p> Doctor Speciality : <?php echo $row['doctor_speciality']; ?></p> -->
<!-- <p><?php echo $row['doctor_profile']; ?></p> -->
<p><!-- Mobile : --> <?php echo $row['mobile']; ?></p>
<!-- <p><?php echo $row['doctor_profile']; ?></p> -->
<!-- <p>Dr. Mr is a Senior Endodontist, specializes in Smile Designing, Single Visit Root Canal Treatments, Implants, Cosmetic Dentistry.</p> -->
<div class="sideleft">
<p>Clinic Name:<?php echo $row['clinic_name']; ?></p>
<p>Clinic Address:<?php echo $row['clinic_address']; ?></p>
</div>
<ul>
<li>MON-SAT 9:00 AM - 9:30 PM</li>
<li>Book now</li>
</ul>
</div>
<?php }?>
</div>
Add the 'PHP Code' to the top of specialist.php and change your javascript code to:
<script type="text/javascript">
$(document).ready(function() {
$('.test').click(function (){
var id = $(this).data('idtest') ;
alert(id);
document.location = "speciallist.php?id=" + id;
});
});
</script>

issue with php code and meta tags

I need little bit of help with a small issue,
I need you to fix some line in PHP
What is the issue:
when we share our page on facebook linkedin it comes with
<ol> <li> <span> or <p>
For example the second line on post comes like this!
<ol> <li>Oversee the safety and compliance programs for all the facilities operated by PWSAC.
<?php error_reporting(0);
$user_data=$this->session->userdata('session_user_data');
$f=$this->uri->segment('1');
$p=$this->uri->segment('2');
$i=$this->uri->segment('3');
//echo $apply_url=$f.'/'.$p.'/'.$i; exit;
$this->session->set_userdata('session_apply_job_url',$apply_url);
$image=base_url().'img/user.png';
if(#$company_details[0]->logo!=''){
if (file_exists('./upload/user/resize/'.$company_details[0]->logo)){
$image=base_url().'upload/user/resize/'.$company_details[0]->logo;
}
}
$selectSkill='';
$skill_arr=array();
$selectSkill=#$candidate_profile[0]->skills;
if(!empty($selectSkill)){
$skill_arr=explode(',',$selectSkill);
}
$client_ip=$this->Common->get_client_ip();
$job_visits=$this->Common->selectMultiWhere('tbl_job_visits',$where=array('ip_addtess'=>$client_ip,'job_id'=>$i));
if(empty($job_visits)){
$this->db->insert('tbl_job_visits',array('ip_addtess'=>$client_ip,'job_id'=>$i,'user_id'=>#$this->userId,'date'=>date('Y-m-d h:i:s')));
}
$related_jobs=array();
if(!empty($selectSkill)){
$related_jobs=$this->Common->related_jobs($selectSkill);
}
//echo '<pre>';print_r($user_data[0]->ID);exit;
?>
<style>
.btn-disable_b {
background-color: #c0c0c0;
color: #c0c0c0;
cursor: not-allowed;
display: inline-block;
pointer-events: none;
}
.bg-whit.newmainAdd { background: #f5f5f5 !important;}
</style>
<!--<div id="main">
<div id="container"></div>
Keep Going!
</div>
<div id="footer">You Made It!</div>-->
<section class="wow fadeIn no-padding-bottom newmainAdd" id="main">
<div class="container">
<div class="row">
<div class="col-md-8 col-sm-7 col-xs-12 bg-aqt">
<div class="leftModal newadd1">
<div class="full p-r-15">
<div class="jobDescription">
<div class="jobDescriptionLeft"> <img src="<?php echo $image; ?>" alt="<?php if(isset($candidate_profile[0]->job_title)){echo $candidate_profile[0]->job_title;}?>"> </div>
<div class="jobDescriptionRight">
<h2>
<?php echo glang('Jobs at');?> <?php if(isset($users_info[0]->company_name)){echo $users_info[0]->company_name;}?> : <?php if(isset($candidate_profile[0]->job_title)){echo $candidate_profile[0]->job_title;}?> <?php echo glang('in');?> <?php if(isset($job_description[0]->location)){echo $job_description[0]->location;}?> - <?php echo glang('AquacultureTalent');?>
</h2>
<h3><span>
<?php
//$arr = substr($str, 0, strpos($str, '('));
if($job_description[0]->role_description!=''){
$arr = explode(".", $job_description[0]->role_description, 2);
echo $arr[0].'.';
}
?>
</span></h3>
</div>
</div>
<div class="fullTimeArea full">
<ul>
<li>
<?php if(isset($job_description[0]->job_type)){if($job_description[0]->job_type=='fulltime'){echo 'Full-time';}else if($job_description[0]->job_type=='contract'){echo 'Contract';}elseif($job_description[0]->job_type=='parttime'){echo 'Part-time';}else{echo 'Full-time';}} ?>
</li>
<li><i class="fa fa-calendar"></i> <?php echo $this->Common->time_passed(strtotime($post_jobs_info[0]->approved_date)); ?> </li>
<li><i class="fa fa-map-marker"></i><a href="javascript:;">
<?php if(isset($job_description[0]->location)){echo $job_description[0]->location;}?>
</a></li>
<?php if($job_description[0]->show_salary==1){ ?>
<li><i class="fa fa-eur"></i><a href="javascript:;" data-toggle="tooltip" data-placement="top" title="Gross Anual Salary">
<?php if(isset($job_description[0]->gross_salary_low)){echo $job_description[0]->gross_salary_low;}?>
-
<?php if(isset($job_description[0]->gross_salary_high)){echo $job_description[0]->gross_salary_high;}?>
</a></li>
<?php } ?>
<!--<li><i class="fa fa-bar-chart-o"></i> Intermediate</li>-->
<li><a href="javascript:;" data-toggle="tooltip" title="Preferred spoken language!"><i class="fa fa-language"></i>
<?php if(isset($candidate_profile[0]->language)){echo $candidate_profile[0]->language;}?>
</a></li>
<li> <i class="fa fa-briefcase abs"></i>
<ul>
<li><a href="javascript:;"><span>
<?php if(isset($position_category[0]->title)){echo $position_category[0]->title;}?>
</span></a></li>
</ul>
</li>
<li> <i class="fa fa-tags abs"></i>
<ul>
<?php for($i=0;count($skill_arr)>$i;$i++){ ?>
<?php $skill_category=$this->Common->selectMultiWhere('tbl_talent_profile_option',$where=array('optionsId'=>$skill_arr[$i])); ?>
<li><span><?php echo $skill_category[0]->title; ?></span></li>
<?php }?>
</ul>
</li>
</ul>
</div>
<div class="offerSection full">
<?php if(isset($job_description[0]->role_description)){echo $job_description[0]->role_description;}?>
</div>
<div class="offerSection full">
<h3><?php echo glang('Main requirements');?></h3>
<?php if(isset($job_description[0]->main_requirements)){echo $job_description[0]->main_requirements;}?>
</div>
<div class="offerSection full">
<h2><?php echo glang('Nice to have');?></h2>
<?php if(isset($job_description[0]->nice_to_have)){echo $job_description[0]->nice_to_have;}?>
</div>
<div class="offerSection full">
<h2><?php echo glang('Perks');?></h2>
<?php if(isset($job_description[0]->perks)){echo $job_description[0]->perks;}?>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-5 col-xs-12" >
<div class="" >
<div class="full" id="container">
<div class="rightModal newadd2">
<?php
$string=$candidate_profile[0]->job_title;
$string_slug=$this->Common->create_slug($string);
$i=$this->uri->segment('3');
if(!empty($user_data)){
$student_application_details=$this->Common->selectMultiWhere('tbl_job_application_list',$where=array('applicant_id'=>$this->userId));
$application_array=array();
foreach($student_application_details as $row){
$application_array[]=$row->job_id;
}
?>
<?php if($this->userRoll==3 || $this->userRoll==2 || $this->userRoll==4){ ?>
<a class="applyNow button-3d btn-disable" href="javascript:;"><?php echo glang('apply');?></a>
<?php }else{?>
<?php if(in_array($i,$application_array)){?>
<a class="applyNow button-3d btn-disable" href="javascript:;"><?php echo glang('Already applied');?></a>
<?php }else{ ?>
<a class="applyNow button-3d" href="<?php echo base_url()?>apply-job/<?php echo $string_slug?>/<?php echo $p;?>"><?php echo glang('apply now');?></a>
<?php } ?>
<?php } ?>
<?php }else{ ?>
<a class="applyNow button-3d" href="<?php echo base_url();?>login?login_for=apply"><?php echo glang('Sign up to apply');?></a>
<?php } ?>
<div class="full m-t-30">
<?php if(!empty($user_data)){?>
<?php $bookmark_info=$this->Common->selectMultiWhere('tbl_bookmarks',$where=array('user_id'=>$user_data[0]->ID));
$bookmark_array=array();
foreach($bookmark_info as $row){
$bookmark_array[]=$row->job_id;
}
?>
<?php if($this->userRoll==3 || $this->userRoll==2 || $this->userRoll==4){ ?>
<div id="bookmarksBtn" class="btn-disable_b"> <a class="bookmarksBtn m-t-20 <?php if(in_array($i,$bookmark_array)){ echo 'remove_bookmark active';}else{echo 'add_bookmark';} ?>" data-id="<?php echo $i;?>" href="javascript:;"><i class="fa fa-bookmark"></i>
<?php if(in_array($i,$bookmark_array)){ echo glang('Remove Bookmark');}else{ echo glang('Bookmark'); } ?>
</a> </div>
<?php }else{ ?>
<div id="bookmarksBtn"> <a class="bookmarksBtn m-t-20 <?php if(in_array($i,$bookmark_array)){ echo 'remove_bookmark active';}else{echo 'add_bookmark';} ?>" data-id="<?php echo $i;?>" href="javascript:;"><i class="fa fa-bookmark"></i>
<?php if(in_array($i,$bookmark_array)){ echo glang('Remove Bookmark');}else{ echo glang('Bookmark'); } ?>
</a> </div>
<?php } ?>
<?php }else{ ?>
<a class="bookmarksBtn m-t-20" href="<?php echo base_url();?>login?login_for=apply"><i class="fa fa-bookmark"></i> <?php echo glang('Sign up to Bookmark');?></a>
<?php } ?>
</div>
<div class="full shereArea m-t-30">
<h4><?php echo glang('SHARE');?></h4>
<ul>
<li><i class="fa fa-facebook"></i></li>
<li class="twit"><i class="fa fa-twitter"></i></li>
<li class="linkD"><i class="fa fa-linkedin"></i></li>
<li class="mail2"><i class="fa fa-envelope"></i></li>
</ul>
</div>
<div class="full shereArea m-t-50">
<h4><?php echo glang('Related job offers');?></h4>
<div class="clearfix"></div>
<ul class="full offerspart">
<?php foreach($related_jobs as $r_job){ ?>
<?php if($r_job->id!=$i){ ?>
<?php $string=$r_job->job_title;
$string_slug=$this->Common->create_slug($string);
?>
<li><a href="<?php echo base_url()?>offer-details/<?php echo $string_slug?>/<?php echo $r_job->id; ?>">
<h5>
<?php if(isset($r_job->job_title)){ echo $r_job->job_title;} ?>
</h5>
<p>
<?php if(isset($r_job->company_name)){ echo $r_job->company_name;} ?>
</p>
</a></li>
<?php } ?>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</section>
<script>
$(document).on('click', '.add_bookmark', function() {
var id = $(this).data('id');
$.ajax({
url: base_url + 'apply/add_bookmark',
type: 'post',
data: {id: id},
dataType: 'json',
beforeSend: function(){
//$(self).parent().addClass('active');
},
complete: function(data){
$("#bookmarksBtn").load(location.href + " #bookmarksBtn>*", "");
},
success: function(json){},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).on('click', '.remove_bookmark', function() {
var id = $(this).data('id');
var self = this;
$.ajax({
url: base_url + 'apply/remove_bookmark',
type: 'post',
data: {id: id},
dataType: 'json',
beforeSend: function() {
//$(self).parent().parent().children('.bookmark').removeClass('active');
},
complete: function(data) {
$("#bookmarksBtn").load(location.href + " #bookmarksBtn>*", "");
},
success: function(json) {},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(".clickIcon").click(function(){
$(".dashLeft").toggleClass("dashLeft-left");
});
</script>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<script type="text/javascript" >
jQuery(document).ready(function($){
//variables
var $window = $(window);
var $container = $("#container");
var $main = $("#main");
var window_min = 0;
var window_max = 0;
var threshold_offset = 50;
/*
set the container's maximum and minimum limits as well as movement thresholds
*/
function set_limits(){
//max and min container movements
var max_move = $main.offset().top + $main.height() - $container.height() - 2*parseInt($container.css("top") );
var min_move = $main.offset().top;
//save them
$container.attr("data-min", min_move).attr("data-max",max_move);
//window thresholds so the movement isn't called when its not needed!
//you may wish to adjust the freshhold offset
window_min = min_move - threshold_offset;
window_max = max_move + $container.height() + threshold_offset;
}
//sets the limits for the first load
set_limits();
function window_scroll(){
//if the window is within the threshold, begin movements
if( $window.scrollTop() >= window_min && $window.scrollTop() < window_max ){
//reset the limits (optional)
set_limits();
//move the container
container_move();
}
}
$window.bind("scroll", window_scroll);
/**
* Handles moving the container if needed.
**/
function container_move(){
var wst = $window.scrollTop();
//if the window scroll is within the min and max (the container will be "sticky";
if( wst >= $container.attr("data-min") && wst <= $container.attr("data-max") ){
//work out the margin offset
var margin_top = $window.scrollTop() - $container.attr("data-min");
//margin it down!
$container.css("margin-top", margin_top);
//if the window scroll is below the minimum
}else if( wst <= $container.attr("data-min") ){
//fix the container to the top.
$container.css("margin-top",0);
//if the window scroll is above the maximum
}else if( wst > $container.attr("data-max") ){
//fix the container to the top
$container.css("margin-top", $container.attr("data-max")-$container.attr("data-min")+"px" );
}
}
//do one container move on load
container_move();
});
</script>
If you visit this job: https://aquaculturetalent.com/offer-details/123/hatchery-operation-manager and view its source, you'll see this code:
<meta name="description" content="<p>The Hatchery Operations Manager basic functions:</p>
<ol>
<li>Oversee all non-fish culture hatchery operations and staff involved with these tasks including the M/V Alaskan Challenger</li>
<li>Prepare annual budgets with hatchery managers for each facility and the annual budget for the Anchorage Distribution Center to present the General Manager/CEO</li>
<li>To work on a daily basis with the General Manager/CEO and members of the top management team to carry out the directives of the Board</li>
<li>Oversee the safety and compliance programs for all the facilities operated by PWSAC.">
Notice there's HTML inside the content=. Somewhere along the line you're not closing the li or ol and meta tags correctly. Update your back-end code that populates those pieces of data to be valid HTML and it should be fine.
You need to filter to remove tags and escape HTML entities, before content is placed into the meta description, wherever that is happening. Example...
<?php
$desc = "<p>The Hatchery Operations Manager basic functions</p>";
$desc_sanitized = filter_var($desc, FILTER_SANITIZE_STRING);
echo '<meta name="description" content="' . htmlspecialchars($desc_sanitized) . '">';

Magento - How to show realted products block in my product page?

I have this and i think this is a code for block which displays releated products for the product in the product page here it is.
/template/catalog/product/list/releated_products.phtml :
<?php if($this->getItems()->getSize()): ?>
<div class="related-products">
<h2><?php echo $this->__('Related Products') ?></h2>
<ol class="products-grid row" id="block-related">
<?php foreach($this->getItems() as $_item): ?>
<li class="item span3">
<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
<?php endif; ?>
<div class="product"> <img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(590,714) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
<div class="product-details">
<p class="product-name"><?php echo $this->htmlEscape($_item->getName()) ?></p>
<?php echo $this->getPriceHtml($_item, true, '-related') ?>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<?php echo $this->__('Add to Wishlist') ?>
<?php endif; ?>
</div>
</div>
</li>
<?php endforeach ?>
</ol>
<script type="text/javascript">decorateList('block-related', 'none-recursive')</script>
<script type="text/javascript">
//<![CDATA[
$$('.related-checkbox').each(function(elem){
Event.observe(elem, 'click', addRelatedToProduct)
});
var relatedProductsCheckFlag = false;
function selectAllRelated(txt){
if (relatedProductsCheckFlag == false) {
$$('.related-checkbox').each(function(elem){
elem.checked = true;
});
relatedProductsCheckFlag = true;
txt.innerHTML="<?php echo $this->__('unselect all') ?>";
} else {
$$('.related-checkbox').each(function(elem){
elem.checked = false;
});
relatedProductsCheckFlag = false;
txt.innerHTML="<?php echo $this->__('select all') ?>";
}
addRelatedToProduct();
}
function addRelatedToProduct(){
var checkboxes = $$('.related-checkbox');
var values = [];
for(var i=0;i<checkboxes.length;i++){
if(checkboxes[i].checked) values.push(checkboxes[i].value);
}
if($('related-products-field')){
$('related-products-field').value = values.join(',');
}
}
//]]>
</script>
</div>
<?php endif ?>
So how i can display this block in my view.phtml which display the info for the product view page. I want to paste it bellow the product description.
Thanks in advance!
Try this https://magento.stackexchange.com/questions/3177/showing-related-products-in-product-view-page
Make sure your current product has related product.

open accordion with external link

i am trying to open the the accordion using external link..Actually there are three main accordions on the page(about,results,contact)
and there is a menubar with items(about,results,contact).
what i want is when i click on about menu item it should open the about accordion
the below is jquery code
$(function() {
$( "#accordion" ).accordion({
collapsible: true,
autoHeight: false ,
active: false,
navigation:true,
});
$(".exlnk").click(function(event){
window.location.hash=this.hash;
});
});
The below is html menubar code:
<div id="navmenu" style='z-index:9999;'>
<ul>
<li>About</li>
<li><a href="#" >Results</a></li>
<li>Contact</li>
</ul>
</div>
and below is jquery code for external link
<script>
$(document).ready(function(){
$('a.anchor_about').click(function(){
$("#accordion").accordion("activate", '<?php echo $_GET['id']; ?>');
return false;
});
});
</script>
but its not working..:(
anyone knows about same?
thanks in advance
EDIT1
<script>
$("#navmenu ul").children("li").click(function()
{
$("#accordion").accordion("activate", <?php echo (int)$_GET['id']; ?>);
});
EDIT2
Below is the accordion code
<div class="demo">
<div id="accordion"> <!--- main accordion 1 demo-->
<h3></h3>
<div id="accordion1" style="margin-bottom:17px;" >
<h1><a href="#" ></a></h1>
<div id="content_our_offer" > <!--- sub accordion 1 demo-->
<?php $page_id=1742;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
<div style="margin-top:20px;"> <!--- sub accordion 2 demo-->
<h2 ><a href="#" ></a></h2> </div>
<div id="content_our_offer" >
<?php $page_id=1742;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
</div>
<div style="margin-top:20px;">
<h6><a class="exlnk" href="#about" title="About" ></a></h6> </div> <!--- main accordion 2 demo-->
<div id="id_ourresults">
<?php
$directory = 'our_results';
try {
// Styling for images
foreach ( new DirectoryIterator("../" . $directory) as $item ) {
if ($item->isFile()) {
echo "<div class=\"expand_image\">";
$path = "/" . $directory . "/" . $item;
echo "<img src=\"" . $path . "\" width=861 height=443 />";
echo "</div>";
}
}
}
catch(Exception $e) {
echo 'No images found for this player.<br />';
}
?>
</div>
<div style="margin-top:20px;">
<h4></h4> </div> <!--- main accordion 3 demo-->
<div id="id_contactus">
<?php $page_id=1791 ;?>
<?php get_page( $page_id ) ;
$page_data = get_page( $page_id );
echo '<h3>'. $page_data->post_title .'</h3>';// echo the title
echo apply_filters('the_content', $page_data->post_content); ?>
</div>
</div>
</div><!-- End demo -->
$('a.anchor_about').click(function(){
$("#accordion").accordion("activate", '<?php echo $_GET['id']; ?>');
return false;
});
I don't think $_GET['id'] in the accordion activate line is going to work as I guess you want something like this
$('a.anchor_about').click(function(){
var sectionId = $(this).attr("href");
$("#accordion").accordion("activate", sectionId);
return false;
});
check if this works - if there are any errors let me know.
EDIT **
Also, I think to open accordion you need an index based value not a ID value like #someId (which works for tab for sure). The index is zero-based so that first section of accordion can be activated by passing a zero value, second with 1, and so on.
Give the menu items a name according to index
<div id="navmenu" style='z-index:9999;'>
<ul>
<li>About</li>
<li>Results</li>
<li>Contact</li>
</ul>
</div>
then activate the appropriate accordionitem with the index given in the menu items:
$("#navmenu ul").children("li").click(function()
{
$("#accordion").accordion("activate", $(this).attr("name"));
// ALSO POSSIBLE (name attribute not needed):
// Only if the menu items are in the same order as the accordion items
$("#accordion").accordion("activate", $(this).index());
});
Edit
I just figured your code is in a different file, so here's an option to minimize the change to your code. Seeing as you send a hash and GET the ID in a new page. The accordion needs an indexnumber, not an ID: Accordion Methods
<div id="navmenu" style='z-index:9999;'>
<ul>
<li>About</li>
<li>Results</li>
<li>Contact</li>
</ul>
</div>
$('#accordion').accordion({"active": $(window.location.hash).index()});

jquery delete selected comment

I have made a forum and I want the user to delete their comment if they don't want it.
Now it deletes the first post and not the post that they have clicked "delete" on.
How can I check that its the comment they click on that gets deleted?
I have made this:
$(function() {
$(".slet").click( function(event) {
event.preventDefault();
//$(this).css("background-color","#000");
var id = "<?=$deleteID?>";
//alert(id);
$("#forum_content").fadeOut();
});
});
and my php:
it is a little messy.
<?php foreach ($comments as $comment): ?>
<?php
if($comment->level == "admin")
{
echo '<div class="adminclass">';
}
?>
<div id="forum_content" class="content">
<div class="forum_comment">
<div class="forum_profil_img"><img width="90" height="90" src="<?php echo base_url();?>images/users/thumbs/<?php echo $query->profile_picture; ?>"></div><!-- forum_profil_img -->
<div class="forum_post_content">
<span class="post_navn"><?php echo anchor('profil/index/'.$comment->kommentar_brugernavn, $comment->kommentar_brugernavn); ?></span>
<span style="font-size:11px; margin-left:3px; color:#686868;"><i> Siger</i></span><br>
<div id="data"><?php echo nl2br($comment->indhold); ?></div><!-- data -->
</div><!-- forum_post_content -->
<div style="width:auto; float:right; color:#a0a0a0; clear:left; position:relative; bottom:-15px;" id="forum_dato">
<i>
<abbr class="timeago" title="<?php echo $comment->dato; ?>"><?php echo $comment->dato; ?></abbr>
<?php
if($this->session->userdata('logget_ind') == 1 &&
$this->session->userdata('username') == $comment->brugernavn &&
time() - $comment->time < 300)
{ echo "- <a href=''>Ret</a> - <a class='slet' href=''>Slet</a>";
$deleteID = $comment->commentID;
} ?>
</i>
</div><!-- forum_post_content -->
</div><!-- forum_comment -->
<?php if ($comment->level == "admin") { ?> <span class="admin-ribbon"></span></div> <?php } ?>
</div><!-- content -->
<?php endforeach ?>
On each page use a counter, on which you assign a unique id to each comment from as it's added. That way you can delete comments irrelevant of their order (original or ordered).
Change the line echo "- <a href=''>Ret</a> - <a class='slet' href=''>Slet</a>" to
echo "- <a href=''>Ret</a> - <a class='slet' id='slet-".$comment->commentID."' href=''>Slet</a>"
and the click handler to:
$(function() {
$(".slet").click( function(event) {
event.preventDefault();
//$(this).css("background-color","#000");
var id = $(this).attr("id").replace(/[^0-9]/g, "");
alert(id);
$("#forum_content").fadeOut();
});
});

Categories