I'm making a custom WordPress theme with pinegrow editor and I'm using slick slider for my slides (not the WordPress plugin!). Here is the code of one item of my slider with custom dot thumb:
<div class="item" data-thumb="images/realmix/products/fresh-energy.png">
<div class="row productz">
<div class="col-md-7 col-lg-7 doesle col-sm-5 col-xs-12">
<img src="images/realmix/products/energy-panel.png">
</div>
</div>
</div>
and this is the php code i get from that code snippet from exporting the wordpress theme:
<div class="item" data-thumb="images/realmix/products/fresh-energy.png">
<div class="row productz">
<div class="col-md-7 col-lg-7 doesle col-sm-5 col-xs-12">
<img src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/realmix/products/energy-panel.png">
</div>
</div>
</div>
now the problem is my slider dot images won't get loaded because pinegrow does not convert the data-thumb src into php.
Trying to add the php echo at the data-thumb like this:
data-thumb="<?php echo esc_url( get_template_directory_uri() ); ?>images/realmix/products/fresh-energy.png"
does not work when i upload to wordpress, still shows no images
How can i fix that by myself?
Not sure i'm following your correctly. I'll update if I am off track.
Maybe try using get_bloginfo('template_url') function instead?
data-thumb="<?=get_bloginfo('template_url)?>/images/realmix/products/fresh-energy.png"
This will go to the immediate child images folder in your current theme folder.
In relation to your comment on questions/64405779 linking to this question, for that script to work with your php, would be as follows...
<div class="slider">
<div class="item" data-thumb="<?=get_bloginfo('template_url')?>/images/realmix/products/fresh-energy.png">
<div class="row productz">
<div class="col-md-7 col-lg-7 doesle col-sm-5 col-xs-12">
<img src="<?=get_bloginfo('template_url')?>/images/realmix/products/energy-panel.png" alt="" />
</div>
</div>
</div>
<!-- next slides here -->
</div>
And the script would be...
// my slick slider options
const options = {
slidesToShow: 1,
slidesToScroll: 1,
dots: true,
arrows: false,
adaptiveHeight: true,
autoplay: true
};
// my slick slider as const object
const mySlider = $('.slider').on('init', function(slick) {
// set this slider as const for use in set time out
const slider = this;
// slight delay so init completes render
setTimeout(function() {
// dot buttons
let dots = $('.slick-dots > LI > BUTTON', slider);
// each dot button function
$.each(dots, function(i,e) {
// slide id
let slide_id = $(this).attr('aria-controls');
// custom dot image
let dot_img = $('#'+slide_id).data('thumb');
$(this).html('<img src="' + dot_img + '" alt="" />');
});
}, 100);
}).slick(options);
and the css would be the same from questions/64405779
Related
These are the custom fields composition:
1 Group Footer
1.1 Group Col2
1.1.1 bbcimg (this is the image ID)
1.1.2 bbc-rss (this is the RSS feed ID)
I have the following code displaying the bbc-rss:
<div class="col-md-3">
<?php
$footer = get_field('footer'); // 'footer' is your parent group
$col2 = $footer['col2']; // 'col2' is your child group
?>
<div class="widget_item widget_latest sm-m-top-50">
<h4 id="white" class="text-white">Latest News</h4>
<div class="widget_latst_item m-top-30">
<div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/bbc_rss.png" alt="" /></div>
<div id="gris" class="widget_latst_item_text">
<p><?php echo $col2['bbc-rss'];?></p>
</div>
</div>
<div class="widget_latst_item m-top-30">
<div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/reuters_rss.png" alt="" /></div>
<div id="gris" class="widget_latst_item_text">
<p><?php echo $col2['reuters-rss'];?></p>
</div>
</div>
<div class="widget_latst_item m-top-30">
<div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/cnbc.jpg" alt="" /></div>
<div id="gris" class="widget_latst_item_text">
<p><?php echo $col2['cnbc-rss'];?></p>
</div>
</div>
</div><!-- End off widget item -->
</div><!-- End off col-md-3 -->
I have created the image field bbcimg with the following properties:
Field label: bbcimg
Field Name: bbcimg
Field Type: image
Instructions: -
Required: No
Return Format: Image Array
Preview Size: Medium(300x300)
Library: All
Minimum: Width 40px, Height px 40 File size - MB
Minimum: Width - px, Height px - File size - MB
Allowed file types: -
Conditional Logic: -
Wrapper Attributes: -
And the image is already uploaded in the custom field. See picture:
Question:
How to write the logic to display the picture on the website?
Thank you very much in advance!
been trying to use
First you need to find out what is getting returned inside the custom field.
Add a good old print_r to your code somewhere:
<?php print_r($col2['bbcimg']) ?>
That will print out an array of values like Array( 'url' => 'http....something.jpg', 'size'=>'full', ..etc)
Then you can identify which array value gives you the full URL to the image. Say in this case it would be a field called url, then you can use that value as follows:
<div id="gris" class="widget_latst_item_text">
<img src="<?php echo $col2['bbcimg']['url']; ?>" alt=""/>
<p><?php echo $col2['bbc-rss'];?></p>
</div>
I am implementing a page on which when page loads, the slideshow starts. The pictures for that slideshows are coming form back-end(database). Each picture has its own timer as there are some pictures with the content while some with only heading or logos. At present, I have the same time interval set to each pictures, but now I want to set the time intervals according to their values in database.
here is the code that I have for now with the same time interval:
index.php
<section class='images'>
<? foreach($model->slides as $slide){ ?>
<div class='image'>
<img class='image' src="<?= $slide->image ?.'/pictures/'.$slides->image : '' ?>">
</div>
<? } ?>
</section>
<script type="text/javascript">
$(document).ready(function(){
$('.images').slick({
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 10000,
});
});
</script>
In indexController.php(Controller)
public function index(Array $params = []){
$this->view->slides = \Model\Slide_Picture::getList(['orderBy'=>"image_order asc"]);
$this->loadView($this->view);
}
My table 'slide_images' consist of 3 fields: image, image_order and timer.
As mentioned earlier, this code helps me to get the image slideshow with the time interval of 10s, but now I want to set it different for each images. Say for example, there are 3 images in the database, Picture 1 has a timer value 30s, picture 2 has that of 10s, and picture 3 has value of 40s. So is this possible? If yes, how can I achieve it. Thanks in advance. Appreciate the help.
You would need to add your timing to the database for each image, then once you do that you can return the timing value, and use it in a data attribute. (seems you have done that timer)
Then utilise the afterChange event to get the value and then dynamically change the autoplaySpeed speed.
Below is an example, you would need to integrate it.
$(document).ready(function() {
var images = $('.images');
images.slick({
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 1000,
}).on("afterChange", function(e, slick) {
var slideTime = $('div[data-slick-index="' + slick.currentSlide + '"]').data("timer");
images.slick("setOption", "autoplaySpeed", slideTime);
});
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.css" />
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<section class='images'>
<div class='image' data-timer="2000">
<img class='image' src="http://via.placeholder.com/350x150">
</div>
<div class='image' data-timer="100">
<img class='image' src="http://via.placeholder.com/350x150">
</div>
<div class='image' data-timer="1000">
<img class='image' src="http://via.placeholder.com/350x150">
</div>
<div class='image' data-timer="3000">
<img class='image' src="http://via.placeholder.com/350x150">
</div>
<div class='image' data-timer="1000">
<img class='image' src="http://via.placeholder.com/350x150">
</div>
</section>
Run the snippet to see it in action.
So your loop would look something like:
<section class="images">
<?php foreach ($model->slides as $slide): ?>
<div class="image"<?= !empty($slide->timer) ? ' data-timer="'.$slide->timer.'"' : null ?>>
<img class="image" src="<?= $slide->image ? '/pictures/'.$slides->image : null ?>">
</div>
<?php endforeach ?>
</section>
I am working on a website in drupal 7, I have created a Home page in page--front.tpl.php with Static Html like the code below,
<div class="col-sm-8 col-xs-24 botmboxes">
<div class="row">
<div class="boxbotmimg">
<img class="img-responsive" src="./sites/all/themes/korhanifashion/images/PlasticRug-Boat.png">
<span class="hovblck"></span>
</div>
<div class="botboxhov">
<a href="<?php print $front_page; ?>limited_offers">
<img class="bbres" src="./sites/all/themes/korhanifashion/images/limroffer.png"></a>
</div>
</div>
</div>
<div class="col-sm-4 col-xs-24 botmboxes botboxthree">
<div class="row">
<div class="boxbotmimg">
<img class="img-responsive" src="./sites/all/themes/korhanifashion/images/AnchorLine_BLCR_HI.png">
<span class="hovblck"></span>
</div>
<div class="botboxhov">
<a href="https://www.facebook.com/KORHANIhome">
<img class="bbres" src="./sites/all/themes/korhanifashion/images/fusonfbok.png"></a>
</div>
</div>
</div>
I want to manage these Images from back-end i.e from Admin-panel. So that Admin can change the images from Admin-panel, And also how Admin can put links to that images from back-end.
How I can do that?
Thanks in Advance
I usually solve similar issues(customizing the dynamic home page contents) by creating a custom content type(https://www.drupal.org/node/306792).
And then you can hard-code to read nodes of a specific type in your template file or use Views (https://www.drupal.org/project/views).
Added sample code:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'home_image')
->entityCondition('status', 1);
$result = $query->execute();
if (isset($result['node'])) {
$nodes = node_load_multiple(array_keys($result['node']));
foreach ($nodes as $node) {
$img_url = file_create_url($node->field_image['und'][0]['uri']);
}
}
In the above code, 'home_image' is the name of content type you have created and 'field_image' is the name of image field. You can add and edit the name of image field when editing fields of content type. Please be sure to set the field type to 'Image'.
apologies if this has been covered anywhere here. I tried searching, but only found topics related to styling and positioning captions within the carousel code…
So, I have a layout that contains three columns:
The left column contains general information related to each page/project.
The center column contains a Bootstrap 3 carousel with images.
The right column is where I was planning on displaying all the captions related to the images in the center Carousel.
I can't quite figure out how to get the captions working in the right column. To clarify, the captions will change with each carousel slide, just as they do in the default carousel setting. I basically want to move the captions off the image, and into the right column.
I am using Kirby (www.getkirby.com) as my CMS and I am using a foreach loop to get the code for the images, etc. in the carousel. Here is my current code, including the caption section (which I am trying to move…)
<div id="center" class="col-xs-12 col-sm-6 col-md-8">
<?php $imagepage = $page->children()->first() ?>
<?php if($imagepage->hasImages()): ?>
<div id="merry-go-round" class="carousel slide">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php $n=0; foreach($imagepage->images() as $image): $n++; ?>
<div class="item<?php if($n==1) echo ' active' ?>">
<img style="display:block; margin-left: auto; margin-right: auto;" src="<?php echo $image->url() ?>" alt="<?php echo html($image->title()) ?>" class="img-responsive">
<div class="carousel-caption"><?php echo $image->img_title() ?></div>
</div>
<?php endforeach ?>
<?php endif ?>
</div><!-- /carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#merry-go-round" data-slide="prev"></a>
<a class="right carousel-control" href="#merry-go-round" data-slide="next"></a>
</div><!-- /merry-go-round -->
</div><!-- /#center -->
<div id="right" class="col-xs-12 col-sm-3 col-md-2">
<p>THIS IS WHERE I AM TRYING TO PUT THE CAROUSEL CAPTIONS…</p>
</div><!-- /#right -->
I've tried by best but I am all out of ideas. I thought maybe I could do something like make the caption a variable:
<?php $test_caption = $image->img_title() ?><?php echo $test_caption ?>
but this doesn't work outside the carousel area. I'm guessing it's that it won't work outside of the foreach loop?
Anyway, if anyone has any suggestions I would really appreciate it. I'm learning PHP as I go along, but I don't know any javascript so I'm hoping there's a solution outside that. And again, I'm using Bootstrap 3.
Here is a link to a fiddle I made (without all the php stuff…):
http://jsfiddle.net/4tMfJ/2/
Based on Twitter Bootstrap Carousel - access current index
You can add the code below to your javascript (after loading jquery / bootstrap)
$(function() {
$('.carousel').carousel();
var caption = $('div.item:nth-child(1) .carousel-caption');
$('#right h1').html(caption.html());
caption.css('display','none');
$(".carousel").on('slide.bs.carousel', function(evt) {
var caption = $('div.item:nth-child(' + ($(evt.relatedTarget).index()+1) + ') .carousel-caption');
$('#right h1').html(caption.html());
caption.css('display','none');
});
});
also see: http://jsfiddle.net/4tMfJ/3/
Thanks Bass for your answer it worked for me !
But i did not want to have replicated content so i did it my way ;)
$("#slider").on('slide.bs.carousel', function(evt) {
var step = $(evt.relatedTarget).index();
$('#slider_captions .carousel-caption:not(#caption-'+step+')').fadeOut('fast', function() {
$('#caption-'+step).fadeIn();
});
});
http://jsfiddle.net/4fBVV/3/
I need help passing row from a mysql database into a div popup window?
how doI pass product id into popup div which I call through View?
For Example I Want Like This
View</li>
Here My Code
<div class="latest_products_sec">
<div class="latest_products">
<div class="title_box">
</div>
<!--Latest Products Slider -->
<div class="latest_pro_box">
<h4>Latest Shirt's Collection</h4>
<div class="latest_products_slider">
<?php
$queryshirt=mysql_query("select image,id from products
where cid='1' LIMIT 5") or die ('die shirt query');
while($rowshirt=mysql_fetch_array($queryshirt))
{
echo '<ul>';
echo '<li><img src="admin/'.$rowshirt['image'].'"
width="225" height="300" alt="" />
View</li>';
echo '</ul>';?>
}
?>
#shirt Div Popup Window
<div id="shirt" class="proquickview">
<span class="close_btn" onclick="parent.jQuery.fancybox.close();">Close</span>
<h2 class="title">quick view</h2>
<div class="quickviewinfo">
<?php
// I Need To Get ID Here
echo $id=$_REQUEST['id'];
?>
<div class="quickviewinforight">
<div class="titlerow">
<h2>Latest Shirt's Collection</h2>
<div class="start_ratings">
<div class="start_rating">
</div>
</div>
<div>
<div class="quick_review">
<h3>Quick Discription</h3>
<p>TEST.</p>
</div>
<div class="qty_row">
<div class="qty_field">
<label>Select Quantity</label>
<span>
<select name="S">
<option>5</option>
</select>
</span>
</div>
<br class="clear" />
<span class="total_price">Price <strong>$88.00</strong>
<del>$102.00</del></span>
ADD TO CART
</div>
<div class="total_price_row">
</div>
</div>
</div>
</div>
Javascript For Popup Window
$(document).ready(function() {
$(".view_btn").fancybox({
'titlePosition' : 'inside',
'transitionIn' : 'none',
'transitionOut' : 'none'
});
});
$(document).ready(function(){
// Cufon Functions //
Cufon.replace ('.latest_products_slider ul li a.view_btn',{hover:true});
});
You can use new 'echo'
echo 'View</li>';
instead of using this
echo '<li><img src="admin/'.$rowshirt['image'].'" width="225" height="300" alt="" />
View</li>';
combined 'echo' statement for image and link to View
Use jQuery .load function. Then make a hidden div, tgen on an action, use the load function to load the hidden div and change the css selection to visible. Very simple, add effects as well.