jquery delete selected comment - php

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();
});
});

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>

PHP: Using Ajax to get records from Database and insert HTML

I have several records from my database displayed like this in HTML.
<?php foreach($adverts_list as $ad) { ?>
<!--anuncio 1-->
<div class="card all ad-isotope <?php echo $ad->ad_categorie; ?>">
<div class="card-body">
<div class="card-title">
<div class="card-info">
<i class="fa fa-tags"></i>
<p class="card-tag"><?php echo $ad->categorie_name; ?></p>
<?php if($ad->subCategorie_id != 10) { ?>
<p class="card-subcat"> <?php echo $ad->subCategorie_display; ?></p>
<?php } ?>
</div>
</div>
<div class="new-symbol">
<p>
<?php if($ad->ad_nouveau == 1) {
echo "nouveau";
} ?>
</p>
</div>
<div class="card-subtitle">
<p class="db-title"><?php echo $ad->ad_title; ?></p>
<p class="db-subtitle"><?php echo $ad->ad_subtitle; ?></p>
</div>
<div class="card-readmore">
<a data-toggle="modal" href="#ad-detail-modal-<?php echo $ad->ad_id; ?>">
<p class="read-more">voir l'annonce</p>
</a>
</div>
</div>
</div>
But i wan't to filter it according to a click in a button. I'll have 10 buttons, each corresponding to a category. I wan't to extract the innerHTML from the button, and match it to the records with the same category.
I'm stuck here
//save in variable all elements refering to categories
var categorias = document.querySelectorAll("a.link");
//a loop to create event on click of each element
for(var i = 0; i < categorias.length; i++) {
categorias[i].addEventListener("click", function() {
//save innerHTML
var categoria = this.innerHTML;
//make ajax call
$.ajax({
url: "index.php",
type: "GET",
dataType: "html",
success: function(response) {
}
});
});
}
How can i make the ajax call to search for the records that have the saved category, and display only those?

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) . '">';

Inserting custom FB share button in post (Wordpress)

Im trying to insert big custom FB share button.
I was able to make it appear, but the problem started to happen with jquery.
I am having 2 fb share buttons on the same post, but for only one of them share popup opens up. What must i do to make the second share popup work? You can find below the code im using:
<?php
/**
* The single post loop Default template
**/
if (have_posts()) {
the_post();
$td_mod_single = new td_module_single($post);
?>
<article id="post-<?php echo $td_mod_single->post->ID;?>" class="<?php echo join(' ', get_post_class());?>" <?php echo $td_mod_single->get_item_scope();?>>
<div class="td-post-header">
<?php echo $td_mod_single->get_category(); ?>
<header class="td-post-title">
<?php echo $td_mod_single->get_title();?>
<?php if (!empty($td_mod_single->td_post_theme_settings['td_subtitle'])) { ?>
<p class="td-post-sub-title"><?php echo $td_mod_single->td_post_theme_settings['td_subtitle'];?></p>
<?php } ?>
<div class="td-module-meta-info">
<?php echo $td_mod_single->get_author();?>
<?php echo $td_mod_single->get_date(false);?>
<?php echo $td_mod_single->get_comments();?>
<?php echo $td_mod_single->get_views();?>
</div>
</header>
</div>
<?php echo $td_mod_single->get_social_sharing_top();?>
<div class="td-post-content">
<div class="big-facebook-share" data-url="<?php echo home_url(add_query_arg(array(),$wp->request));?>" id="fb-share-button">
<span class="big-share-text"><?php _e('Share on facebook','fb');?></span>
</div>
<script>
jQuery(function(){
jQuery("#fb-share-button").on('click', function () {
fbShare(jQuery(this).attr("data-url"));
})
});
function fbShare(url) {
var width=640;
var height=320;
var leftPosition, topPosition;
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=no,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
var u=location.href;
var t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;
}
</script>
<?php
// override the default featured image by the templates (single.php and home.php/index.php - blog loop)
if (!empty(td_global::$load_featured_img_from_template)) {
echo $td_mod_single->get_image(td_global::$load_featured_img_from_template);
} else {
echo $td_mod_single->get_image('td_696x0');
}
?>
<?php echo $td_mod_single->get_content();?>
<div align="center"> <?php echo do_shortcode('[fb_button]'); ?></div>
<div class="big-facebook-share" data-url="<?php echo home_url(add_query_arg(array(),$wp->request));?>" id="fb-share-button">
<span class="big-share-text"><?php _e('dhare on facebook','fb');?></span>
</div>
<?php echo do_shortcode('[fbcomments url="https://facebook.com/Facebook/" width="700" count="off" num="3" countmsg="wonderful comments!"]'); ?>
</div>
<footer>
<?php echo $td_mod_single->get_post_pagination();?>
<?php echo $td_mod_single->get_review();?>
<div class="td-post-source-tags">
<?php echo $td_mod_single->get_source_and_via();?>
<?php echo $td_mod_single->get_the_tags();?>
</div>
<?php echo $td_mod_single->get_social_sharing_bottom();?>
<?php echo $td_mod_single->get_next_prev_posts();?>
<?php echo $td_mod_single->get_author_box();?>
<?php echo $td_mod_single->get_item_scope_meta();?>
</footer>
</article> <!-- /.post -->
<?php echo $td_mod_single->related_posts();?>
<?php
} else {
//no posts
echo td_page_generator::no_posts();
}
Your jQuery selector is targeting the id and since the buttons have the same id (they should be unique), only one is working. Consider giving each button a unique id or update your jQuery selector to use class instead.
jQuery(".big-facebook-share").on("click", function() {...});

Printing image from array

first off, I'm extremely new to PHP.
I'm using Conrete5, and I have a new template to an image slider. This is what I'm using:
http://codepen.io/altitudems/pen/KdgGLG
There's a placeholder image, which I'm trying to replace by grabbing the first image set in the block itself. Here is my view file from the actual block:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$navigationTypeText = ($navigationType == 0) ? 'arrows' : 'pages';
$c = Page::getCurrentPage();
if ($c->isEditMode()) { ?>
<div class="ccm-edit-mode-disabled-item" style="width: <?php echo $width; ?>; height: <?php echo $height; ?>">
<div style="padding: 40px 0px 40px 0px"><?php echo t('Image Slider disabled in edit mode.')?></div>
</div>
<?php } else { ?>
<script>
$(document).ready(function(){
$(function () {
$("#ccm-image-slider-<?php echo $bID ?>").responsiveSlides({
prevText: "", // String: Text for the "previous" button
nextText: "",
<?php if($navigationType == 0) { ?>
nav:true
<?php } else { ?>
pager: true
<?php } ?>
});
});
});
</script>
<div class="ccm-image-slider-container ccm-block-image-slider-<?php echo $navigationTypeText?>" >
<div class="ccm-image-slider">
<div class="ccm-image-slider-inner">
<?php if(count($rows) > 0) { ?>
<ul class="rslides" id="ccm-image-slider-<?php echo $bID ?>">
<?php foreach($rows as $row) { ?>
<li>
<?php if($row['linkURL']) { ?>
<?php } ?>
<?php
$f = File::getByID($row['fID'])
?>
<?php if(is_object($f)) {
$tag = Core::make('html/image', array($f, false))->getTag();
if($row['title']) {
$tag->alt($row['title']);
}else{
$tag->alt("slide");
}
print $tag; ?>
<?php } ?>
<div class="ccm-image-slider-text">
<?php if($row['title']) { ?>
<h1 class="ccm-image-slider-title"><?php echo $row['title'] ?></h1>
<?php } ?>
<?php echo $row['description'] ?>
</div>
</li>
<?php } ?>
</ul>
<?php } else { ?>
<div class="ccm-image-slider-placeholder">
<p><?php echo t('No Slides Entered.'); ?></p>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
Here is my gallery view file:
<a class="gallery-launcher" href="#gallery1"> // Location of the image
<div class="overlay">
<div class="overlay-content">
<button class="btn btn-default">Open Gallery</button>
</div>
</div>
</a>
<div class="gallery inactive" id="gallery1">
<div class="gallery-item">
//Fullscreen gallery code here
</div>
</div>
Where it says // Location of the image is where I need to have the first image set. I can't figure out what I'd put there? Any help will be appreciated.
You could use the concrete5 file helper to get the file path, like this for example:
$f = File::getByID($row['fID']);
$relpath = $f->getRelativePath();
In general I suggest that you read more about the concrete5 file functions to understand more how it works:

Categories