I have created some custom code (lines 287-309 in the code below)It is a duplicate function of 313-345 but with a few changes.
Although the function works perfectly well for some reason the page upon change or refresh duplicate the collection at the bottom of the page.
If I move lines 287-309 to line 347 onwards this does not happen. I'm assuming I a creating some sort of loop here or am I not closing the PHP correctly?
Any help would be hugely appreciated.
The Code:
<?php
include "../include/db.php";
include "../include/authenticate.php";
include "../include/general.php";
include "../include/resource_functions.php";
include "../include/collections_functions.php";
hook("homeheader");
include "../include/header.php";
if (!hook("replacehome")) {
if (!hook("replaceslideshow")) {
# Count the files in the configured $homeanim_folder.
$dir = dirname(__FILE__) . "/../" . $homeanim_folder;
$filecount = 0;
$checksum=0; # Work out a checksum which is the total of all the image files in bytes - used in image URLs to force a refresh if any of the images change.
$d = scandir($dir);
sort($d, SORT_NUMERIC);
$reslinks=array();
foreach ($d as $f) {
if(preg_match("/[0-9]+\.(jpg)/",$f))
{
$filecount++;
$checksum+=filesize($dir . "/" . $f);
$linkfile=substr($f,0,(strlen($f)-4)) . ".txt";
$reslinks[$filecount]="";
if(file_exists("../" . $homeanim_folder . "/" . $linkfile))
{
$linkref=file_get_contents("../" . $homeanim_folder . "/" . $linkfile);
$linkaccess = get_resource_access($linkref);
if (($linkaccess!=="") && (($linkaccess==0) || ($linkaccess==1))){$reslinks[$filecount]=$baseurl . "/pages/view.php?ref=" . $linkref;}
}
}
}
$homeimages=$filecount;
if ($filecount>1) { # Only add Javascript if more than one image.
?>
<script type="text/javascript">
var num_photos=<?php echo $homeimages?>; // <---- number of photos (/images/slideshow?.jpg)
var photo_delay=5; // <---- photo delay in seconds
var link = new Array();
<?php
$l=1;
foreach ($reslinks as $reslink)
{
echo "link[" . $l . "]=\"" . $reslink . "\";";
$l++;
}
?>
var cur_photo=2;
var last_photo=1;
var next_photo=2;
flip=1;
var image1=0;
var image2=0;
function nextPhoto()
{
if (!document.getElementById('image1')) {return false;} /* Photo slideshow no longer available (AJAX page move) */
if (cur_photo==num_photos) {next_photo=1;} else {next_photo=cur_photo+1;}
image1 = document.getElementById("image1");
image2 = document.getElementById("photoholder");
sslink = document.getElementById("slideshowlink");
linktarget=link[cur_photo];
if (flip==0)
{
// image1.style.visibility='hidden';
//Effect.Fade(image1);
jQuery('#image1').fadeOut(1000)
window.setTimeout("image1.src='<?php echo $baseurl . "/" . $homeanim_folder?>/" + next_photo + ".jpg?checksum=<?php echo $checksum ?>';if(linktarget!=''){jQuery('#slideshowlink').attr('href',linktarget);}else{jQuery('#slideshowlink').removeAttr('href');}",1000);
flip=1;
}
else
{
// image1.style.visibility='visible';
//Effect.Appear(image1);
jQuery('#image1').fadeIn(1000)
window.setTimeout("image2.style.background='url(<?php echo $baseurl . "/" . $homeanim_folder?>/" + next_photo + ".jpg?checksum=<?php echo $checksum ?>)';if(linktarget!=''){jQuery('#slideshowlink').attr('href',linktarget);}else{jQuery('#slideshowlink').removeAttr('href');}",1000);
flip=0;
}
last_photo=cur_photo;
cur_photo=next_photo;
timers.push(window.setTimeout("nextPhoto()", 1000 * photo_delay));
}
jQuery(document).ready( function ()
{
/* Clear all old timers */
ClearTimers();
timers.push(window.setTimeout("nextPhoto()", 1000 * photo_delay));
}
);
</script>
<?php } ?>
<div class="HomePicturePanel"
<?php if (isset($home_slideshow_width)) {
echo "style=\"";
$slide_width = $home_slideshow_width + 0;
echo"width:" . (string)$slide_width ."px; ";
echo "\" ";
}
?>>
<a id="slideshowlink"
<?php
$linkurl="#";
if(file_exists("../" . $homeanim_folder . "/1.txt"))
{
$linkres=file_get_contents("../" . $homeanim_folder . "/1.txt");
$linkaccess = get_resource_access($linkres);
if (($linkaccess!=="") && (($linkaccess==0) || ($linkaccess==1))) {$linkurl=$baseurl . "/pages/view.php?ref=" . $linkres;}
echo "href=\"" . $linkurl ."\" ";
}
?>
\>
<div class="HomePicturePanelIN" id='photoholder' style="
<?php
if (isset($home_slideshow_height)){
echo"height:" . (string)$home_slideshow_height ."px; ";
}
?>
background-image:url('<?php echo $baseurl . "/" . $homeanim_folder?>/1.jpg?checksum=<?php echo $checksum ?>');">
<img src='<?php echo $baseurl . "/" . $homeanim_folder?>/2.jpg?checksum=<?php echo $checksum ?>' alt='' id='image1' style="display:none;<?php
if (isset($home_slideshow_width)){
echo"width:" . $home_slideshow_width ."px; ";
}
if (isset($home_slideshow_height)){
echo"height:" . $home_slideshow_height ."px; ";
}
?>">
</div>
</a>
<div class="PanelShadow"></div>
</div>
<?php } # End of hook replaceslideshow
?>
<?php if (checkperm("s")) {
hook("homebeforepanels");
?>
<?php if ($home_themeheaders && $enable_themes) { ?>
<div class="HomePanel"><div class="HomePanelIN">
<h2><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php"><?php echo $lang["themes"]?></a></h2>
<?php echo text("themes")?>
<br /> <br />
<select style="width:140px;" onChange="CentralSpaceLoad(this.value,true);">
<option value=""><?php echo $lang["select"] ?></option>
<?php
$headers=get_theme_headers();
for ($n=0;$n<count($headers);$n++)
{
?>
<option value="<?php echo $baseurl_short?>pages/themes.php?header=<?php echo urlencode($headers[$n])?>"><?php echo i18n_get_translated(str_replace("*","",$headers[$n]))?></option>
<?php
}
?>
</select>
<br />> <?php echo $lang["viewall"] ?>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php if ($home_themes && $enable_themes) { ?>
<div class="HomePanel"><div class="HomePanelINtopA">
<div class="HomePanelINtopHeader"><?php echo $lang["themes"]?></div>
<div class="HomePanelINtopText"><?php echo text("themes")?></div>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php if ($home_mycollections && !checkperm("b") && $userrequestmode!=2 && $userrequestmode!=3) { ?>
<div class="HomePanel"><div class="HomePanelINtopB">
<div class="HomePanelINtopHeader"> <?php echo $lang["mycollections"]?></div>
<div class="HomePanelINtopText"><?php echo text("mycollections")?></div>
</div>
<div class="PanelShadow">
</div>
</div>
<?php } ?>
<?php if ($home_advancedsearch) { ?>
<div class="HomePanel"><div class="HomePanelINtopC">
<div class="HomePanelINtopHeader"> <?php echo $lang["advancedsearch"]?></div>
<div class="HomePanelINtopText"><?php echo text("advancedsearch")?></div>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php if ($home_mycontributions && (checkperm("d") || (checkperm("c") && checkperm("e0")))) { ?>
<div class="HomePanel"><div class="HomePanelINtopD">
<div class="HomePanelINtopHeader"><?php echo $lang["mycontributions"]?></div>
<div class="HomePanelINtopText"><?php echo text("mycontributions")?></div>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php if ($home_helpadvice) { ?>
<div class="HomePanel"><div class="HomePanelINtopE">
<div class="HomePanelINtopHeader"><?php echo $lang["helpandadvice"]?></div>
<div class="HomePanelINtopText"><?php echo text("help")?></div>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php if ($home_themes && $enable_themes) { ?>
<div class="HomePanel"><div class="HomePanelINtopIntro">
<div class="HomePanelINtopHeader"><?php echo text("welcometitle")?></div>
<div class="HomePanelINtopText"><?php echo text("welcometext")?></div>
</div>
<div class="PanelShadow"></div>
</div>
<?php } ?>
<?php
/* ------------ Customisable home page panels ------------------- */
if (isset($custom_home_panels))
{
for ($n=0;$n<count($custom_home_panels);$n++)
{
if (!hook("panelperm")) {
?>
<div class="HomePanel"><div class="HomePanelIN" <?php if ($custom_home_panels[$n]["text"]=="") {?>style="min-height:0;"<?php } ?>>
<h2><a href="<?php echo $custom_home_panels[$n]["link"] ?>" <?php if (isset($custom_home_panels[$n]["additional"])){ echo $custom_home_panels[$n]["additional"];} ?>> <?php echo i18n_get_translated($custom_home_panels[$n]["title"]) ?></a></h2>
<?php echo i18n_get_translated($custom_home_panels[$n]["text"]) ?>
</div>
<div class="PanelShadow"></div>
</div>
<?php
} // end hook 'panelperm'
}
}
?>
<!-- THIS IS LINE 287 please refer to question -->
<?php
if(!hook("EditorsPick")):
/* ------------ Collections promoted to the home page ------------------- */
$home_collectionsx=get_home_page_promoted_collectionsx(16);
foreach ($home_collectionsx as $home_collectionx)
{
?>
<div class="EditorsPick">
<div class="HomePanel"><div class="HomePanelINtopEditors">
<div class="HomePanelINtopHeader">Editors Pick</div>
<div class="HomePanelINtopText">This is the editors pick of Asset Space...</div>
<div class="EditorsPicImage"><div style="padding-top:<?php echo floor((155-$home_collectionx["thumb_height"])/2) ?>px; margin-top: -24px; margin-bottom: -15px;">
<a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collectionx["ref"] ?>" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="<?php echo get_resource_path($home_collectionx["home_page_image"],false,"thm",false) ?>" width="<?php echo $home_collectionx["thumb_width"] ?>" height=" <?php echo $home_collectionx["thumb_height"] ?>" /></div>
</div></div>
</div>
</div>
</div>
<?php
}
endif; # end hook homefeaturedcol
?>
<!-- THIS IS LINE 309 please refer to question -->
<!-- THIS IS LINE 313 please refer to question -->
<?php
if(!hook("homefeaturedcol")):
/* ------------ Collections promoted to the home page ------------------- */
$home_collections=get_home_page_promoted_collections(16);
foreach ($home_collections as $home_collection)
{
?>
<div class="ResourceOfTheDay"></div>
<div class="HomePanel HomePanelPromoted"><div class="HomePanelIN HomePanelPromotedIN">
<div class="MyCollectionsHighlite"></div>
<div class="HomePanelPromotedImageWrap">
<div style="padding-top:<?php echo floor((155-$home_collection["thumb_height"])/2) ?>px; margin-top: -24px; margin-bottom: -15px;">
<a href="<?php echo $baseurl_short?>pages/search.php?search=!collection<?php echo $home_collection["ref"] ?>" onClick="return CentralSpaceLoad(this,true);"><img class="ImageBorder" src="<?php echo get_resource_path($home_collection["home_page_image"],false,"thm",false) ?>" width="<?php echo $home_collection["thumb_width"] ?>" height="<?php echo $home_collection["thumb_height"] ?>" /></div>
</div>
<p style="font-size:14px; font-weight:bold"><?php echo i18n_get_translated($home_collection["home_page_text"]) ?></p>
<p style="font-size:12px; font-weight:normal">Click to view this collection</p>
</div>
<div class="PanelShadow"></div>
</div>
<?php
}
endif; # end hook homefeaturedcol
?>
<!-- THIS IS LINE 345 please refer to question -->
<!-- THIS IS LINE 347 please refer to question -->
<div class="clearerleft"></div>
<?php }
} // End of ReplaceHome hook
include "../include/footer.php";
?>
From your comment above I would say this line is to blame:
if(!hook("homefeaturedcol")):
I'm assuming that this is running as well as your new code above it when it's not the homepage
You may also want to have a look at your HTML structure
Related
I didn't build this PHP file, but I am trying to figure out why it is giving me errors. If the "Block layout mode" ACF variable is set to "Modal" then the block works, but gives me this error. "Undefined variable $vids on line 176". If I select the "Embed & Thumbnail" mode, then none of the block is displayed and I get this error. "Call to undefined function vc_embed_layout() on line 252". I can't pin down why this is happening, and I haven't been able to find any unclosed tags or anything in my php file. This is the file in question, and I've marked the lines that trigger errors.
<?php
global $theme_text_domain;
$block_class_identifier = 'blk__vidcol';
// default variables
$block_id = $top_class = $top_style = $inner_class = $inner_style = '';
// check for custom id
$block_id .= BLOCK::set_id( get_sub_field('content_block_id') );
// set block class, $i comes from FLEX class loop and represents the block order on a page
$top_class .= BLOCK::set_standard_classes( $i );
$top_class .= BLOCK::set_custom_classes( get_sub_field('content_block_classes') );
// check for top padding adjustment
$top_class .= BLOCK::set_padding_class( get_sub_field('block_padding_adjustment') );
$top_style .= BLOCK::set_padding_style( get_sub_field('block_padding_adjustment'), get_sub_field('custom_top_padding'), get_sub_field('custom_bottom_padding'));
// check for custom color theme
$top_style .= BLOCK::set_colors( get_sub_field('color_theme'), get_sub_field('text_color'), get_sub_field('custom_background_color') );
// check for width settings
$inner_class .= BLOCK::set_width_class( get_sub_field('content_width') );
$inner_style .= BLOCK::set_width_style( get_sub_field('content_width'), get_sub_field('custom_maximum_content_width') );
$block_assets = get_stylesheet_directory_uri() . '/inc/blocks/' . basename(__FILE__, '.php') . '/assets/';
/*
CUSTOM BLOCK SPECIFIC SETUP
*/
$layout = get_sub_field('block_layout_mode');
$top_class .= ' layout-' . $layout;
// title color
$h2_style = (get_sub_field('color_theme') == 'custom') ? ' color: ' . get_sub_field('custom_title_color') . ';' : '';
/**
* outputs code for the modal version of the video collection block
* #return html output
*/
if (!function_exists('vc_modal_layout')) {
function vc_modal_layout() {
global $block_class_identifier;
$cta_label = get_sub_field('cta_label');
$counter = 0;
$cta = array(
'style' => get_sub_field('cta_style'),
'button_color' => get_sub_field('button_color'),
'button_text_color' => get_sub_field('button_color')
);
$cta_class = BLOCK::get_cta_style( $cta, '.' . $block_class_identifier . ' .button');
?>
<?php // list section ?>
<?php if( have_rows('videos') ): ?>
<div class="vid-container">
<?php while ( have_rows('videos') ) : the_row(); ?>
<?php if ($counter == 0): ?>
<div class="vid-featured">
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
<a class="vid_overlay" data-fancybox data-src="#<?php echo $block_class_identifier; ?>_vid_0" href="javascript:;"></a>
</div>
<!-- modal -->
<div id="<?php echo $block_class_identifier; ?>_vid_0" class="modal video-modal" style="display: none;">
<div class="modal-inner">
<h3><?php echo get_sub_field('video_title'); ?></h3>
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
<div class="vid-list">
<?php else: ?>
<div class="vid-item">
<div class="item-btn">
<a class="button <?php echo $cta_class; ?>" data-fancybox data-src="#<?php echo $block_class_identifier; ?>_vid_<?php echo $counter; ?>" href="javascript:;"><?php echo $cta_label; ?></a>
</div>
<div class="item-title"><?php echo get_sub_field('video_title'); ?></div>
</div>
<!-- modal -->
<div id="<?php echo $block_class_identifier; ?>_vid_<?php echo $counter; ?>" class="modal video-modal" style="display: none;">
<div class="modal-inner">
<h3><?php echo get_sub_field('video_title'); ?></h3>
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
<?php endif; ?>
<?php $counter++; ?>
<?php endwhile; ?>
</div>
</div>
<?php else: ?>
No videos defined.
<?php endif; ?>
<?
}
}
/**
* outputs code for the embed version of the video collection block
* #return html output
*/
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout($vids, $i) {
?>
<?php if ( $vids ): ?> **this is line 176**
<div class="vid-container2">
<h2 class="vid-title"><?php echo $vids[0]['video_title']; ?></h2>
<div class="vid-container2-inner">
<div class="vid-embed">
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo $vids[0]['youtube_embed_code']; ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen onload="this.style.visibility = 'visible';"></iframe>
</div>
</div>
<div class="vid-thumbnails">
<?php foreach ($vids as $key => $vid): ?>
<?php $wrap_class = ($key == 0) ? ' tn-hide' : ''; ?>
<div class="tn-wrapper <?php echo $wrap_class; ?>" data-embed="<?php echo $vid['youtube_embed_code']; ?>" data-title="<?php echo $vid['video_title']; ?>">
<img src="https://img.youtube.com/vi/<?php echo $vid['youtube_embed_code']; ?>/mqdefault.jpg" alt="">
</div>
<?php endforeach; ?>
</div>
</div>
<script>
var vid_swap = function() {
$('.block_<?php echo $i; ?> .vid-embed').css({opacity: 1});
$('.block_<?php echo $i; ?> .tn-wrapper').on('click', function(e) {
var $this = $(this);
var embed_id = $this.attr('data-embed');
var title = $this.attr('data-title');
console.log('embed = ' + embed_id);
$('.block_<?php echo $i; ?> .vid-title').animate({opacity: 0}, 100);
$('.block_<?php echo $i; ?> .vid-embed').animate({opacity: 0}, 1000, function() {
$('.block_<?php echo $i; ?> .vid-embed, .block_<?php echo $i; ?> .vid-title').css('visiblity','hidden');
$('.block_<?php echo $i; ?> .vid-title').html( title );
$('.block_<?php echo $i; ?> .vid-embed iframe').attr('src', 'https://www.youtube.com/embed/' + embed_id);
$('.block_<?php echo $i; ?> .tn-wrapper.tn-hide').removeClass('tn-hide');
$this.addClass('tn-hide');
$('.block_<?php echo $i; ?> .vid-title').css('visiblity','visible').delay(500).animate({opacity: 1}, 500);
$('.block_<?php echo $i; ?> .vid-embed').delay(500).animate({opacity: 1}, 1000);
});
});
}
jQuery(document).on('block_init', vid_swap);
</script>
</div>
<?php else: ?>
No videos defined.
<?php endif; ?>
<?php
}
}
?>
<section id="<?php echo $block_id; ?>" class="<?php echo $block_class_identifier; ?> <?php echo $top_class; ?>" style="<?php echo $top_style; ?>">
<div class="inner <?php echo $inner_class; ?>" style="<?php echo $inner_style; ?>">
<?php // title section ?>
<?php if (get_sub_field('title')): ?>
<h2 style="<?php echo $h2_style; ?>"><?php echo get_sub_field('title'); ?></h2>
<?php endif; ?>
<?php $vids = get_sub_field('videos'); ?>
<?php if ($layout == 'modal') vc_modal_layout($vids); ?>
<?php if ($layout == 'embed') vc_embed_layout($vids, $i); ?> **This is line 252**
</div>
</section>
You're not accepting any arguments in vc_modal_layout() function declaration.
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout() {
needs to have parameters in order to accept arguments.
something like this is what you're looking for:
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout($vids=[], $i=0) {
And it's the same idea with vc_modal_layout, the function needs to be able to accept the variables from outside it.
When we call a function, the function needs to be able to accept all arguments passed to it. And all variables we use need to be defined, if there's a risk of them being undefined or empty arrays, we can check them with if(!empty($var)) or if(isset($var))
An alternative to passing the variable to the function is to access it as a global. But it's generally better to pass the variable to the function because when we pass the variable to a function in PHP it works with a copy of the variable's value inside the function. When we do something like this:
$var = 10;
function doIt(){
global $var;
$var++;
}
doit();
echo $var;
we could overcomplicate things..
let's have a closer look here:
if ($layout == 'modal') vc_modal_layout($vids);
if ($layout == 'embed') vc_embed_layout($vids, $i); ?> **This is line 252**
function vc_modal_layout(){ ... }
// should be:
function vc_modal_layout($vids){ ... }
function vc_embed_layout($vids, $i)
// looks good.
Aside from that, nothing stands out as really unusual & I'd want to have a look at the actual site to tinker with this problem further.
I have a problem looping my html tags. My goal is to enclose every 4 div with class "item" inside the class of "item-wrap". So far here's my code:
$speakers will return 8 rows so "item-wrap" class will be display twice with 4 "item" class inside
<?php
$speaker_ctr = 0;
if(count($speakers) > 0){
?>
<div class="item-wrap">
<?php foreach($speakers as $speaker){ ?>
<div class="item"> <img class="lazy" data-lazy-src="<?php echo $speaker['imagepath']; ?>" />
<h5 class="txt-18 bold-font text-uppercase no-mbt mt-20"><?php echo $speaker['name']; ?></h3>
<p class="no-mn"><?php echo $speaker['position']; ?></p>
<?php echo $speaker['company']; ?>
</div>
<?php } ?>
</div>
<?php
$speaker_ctr++;
}
?>
Try below code:-
<?php
if(count($speakers) > 0){
for($i=0;$i<=count($speakers);$i++){
if($i%4==0){
echo '<div class="item-wrap">';
}
?>
<div class="item"> <img class="lazy" data-lazy-src="<?php echo $speakers[$i]['imagepath']; ?>" />
<h5 class="txt-18 bold-font text-uppercase no-mbt mt-20"><?php echo $speakers[$i]['name']; ?></h3>
<p class="no-mn"><?php echo $speakers[$i]['position']; ?></p>
<?php echo $speakers[$i]['company']; ?>
</div>
<?php
if($i%4==0){
echo '</div>';
}
}
}
Try with -
$speaker_ctr = 0;
if(count($speakers) > 0){
?>
<div class="item-wrap">
<?php
foreach($speakers as $speaker){
$speaker_ctr++; // increment
?>
<div class="item"> <img class="lazy" data-lazy-src="<?php echo $speaker['imagepath']; ?>" />
<h5 class="txt-18 bold-font text-uppercase no-mbt mt-20"><?php echo $speaker['name']; ?></h3>
<p class="no-mn"><?php echo $speaker['position']; ?></p>
<?php echo $speaker['company']; ?>
</div>
<?php
// print if divisible by 4
// every 4th element
if($speaker_ctr%4 == 0 && $speaker_ctr != count($speakers)) {
echo "</div><div class='item-wrap'>";
}
}
?>
</div>
<?php
}
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:
In default theme all are fine and showing the homepage slideshow,but implementing other theme not showing the homepage slideshow.Checked the admin panel,there are all exactly same as default theme.How to show the slider?
theme/module/Slideshow.tpl
<div class="slideshow">
<div id="slideshow<?php echo $module; ?>" class="nivoSlider">
<?php foreach ($banners as $banner) { ?>
<?php if ($banner['link']) { ?>
<img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" />
<?php } else { ?>
<img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" />
<?php } ?>
<?php } ?>
</div>
</div>
<script type="text/javascript"><!--
$(document).ready(function() {
$('#slideshow<?php echo $module; ?>').nivoSlider();
});
--></script>
slideshow modules are not viewed any kind of images.when <?php echo $slideshow;?>.its showing array().
header.tpl
<?php $slideshow = $modules->getModules('slideshow'); ?>
<?php if(count($slideshow)) { ?>
<!-- Slider -->
<div id="slider" class="<?php if($theme_options->get( 'slideshow_layout' ) == 2) { echo 'fixed'; } else { echo 'full-width'; } ?>">
<div class="background-slider"></div>
<div class="background">
<div class="shadow"></div>
<div class="pattern">
<?php foreach($slideshow as $module) { ?>
<?php echo $module; ?>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
Thanks for share code with me, You are missed to define content_top area in your theme, you have to go here
catalog/view/theme/yourtheme/template/common/home.tpl
go to line no 18 & add this line just below the line 18
<?php echo $content_top; ?>
and your slider will come on your home page.
I have the following code but it is not working.
Basically I want it so if the field movie_title_2 is empty I want it to add the , but if it is not empty to show just . I am using wordpress and Advanced Custom Fields plugin. Thanks!
<div class="homepage-opacity">
<div class="movie-container">
<?php if (get_field('movie_title_2') && get_field('movie_title_2') != "") { ?>
<div class="movie-area alone">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster') ) : ?>
<img src="<?php the_field('movie_image_poster'); ?>" alt="<?php the_field('movie_image_poster'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title'))
{
echo '<h1 class="movie-title">' . get_field('movie_title') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times') . '</p>';
}
?>
<?php if ( get_field('trailer_link') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<?php } ?>
<?php if (get_field('movie_title_2') && get_field('movie_title_2') == "") { ?>
<div class="movie-area">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster') ) : ?>
<img src="<?php the_field('movie_image_poster'); ?>" alt="<?php the_field('movie_image_poster'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title'))
{
echo '<h1 class="movie-title">' . get_field('movie_title') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times') . '</p>';
}
?>
<?php if ( get_field('trailer_link') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<div class="movie-area">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster_2') ) : ?>
<img src="<?php the_field('movie_image_poster_2'); ?>" alt="<?php the_field('movie_image_poster_2'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title_2'))
{
echo '<h1 class="movie-title">' . get_field('movie_title_2') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times_2'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times_2') . '</p>';
}
?>
<?php if ( get_field('trailer_link_2') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link_2'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<?php } ?>
</div>
</div>
try:
<?php
$variable = get_field('movie_title_2');
if ($variable) { ?>
<h1>Add html just like you would normally do</h1>
<?php } else { ?>
<h1>Add different html here when the variable is empty</h1>
<?php } ?>