Foreach loop not always displaying - php

I'm retrieving data out of a database using PHP's PDO extension. I never had a problem with this and it always shows up in all browsers. BUT when I tested the website on a friends laptop, the foreach loop works but the content is not displayed. The content is present in the source code.
this is how I set up the code that should be displayed:
<?php
foreach($advertentiesManager->recenteAdvertenties() as $advertentie) {
$verkoperData = $usersManager->userData($advertentie->verkoper);
?>
<div class="col-md-4" style="margin:10px 0;">
<div class="advertentie">
<div class="overlay"></div>
<div class="img" style="background:url('images/categorie/<?php echo $advertentie->categorie; ?>.jpg') no-repeat center center;background-size:cover;"></div>
<div class="picture" style="background:url('<?php echo str_replace("../", "", $verkoperData->foto); ?>') no-repeat center center;background-size:cover;"></div>
<div class="prijs"><p class="h2">€ <?php echo $advertentie->verkoopprijs; ?></p></div>
<div style="padding: 10px;padding-left:80px;margin-top:-40px;">
<a href="<?php echo $advertentie->type.'/'.strtolower(str_replace(" ", "-", $advertentie->titel)).'-'.$advertentie->id; ?>">
<?php echo $advertentie->titel; ?>
</a>
<br>
<p style="color:#777;font-size:.9em;">
<?php
$beschrijving = strip_tags($advertentie->omschrijving);
$max_length = 100;
if (strlen($beschrijving) > $max_length) {
$offset = ($max_length - 3) - strlen($beschrijving);
$beschrijving = substr($beschrijving, 0, strrpos($beschrijving, ' ', $offset)) . '... Meer';
} else {
$beschrijving = $advertentie->omschrijving;
}
echo $beschrijving;
?>
</p>
</div>
</div>
</div>
<?php
}
?>
You can view a live example at http://www.coupontrade.nl/ the content should be displayed under "Recente advertenties" and above the twitter part.

Related

WP-JSON - Multi-endpoint - Re-occuring Foreach Error

I'm currently trying to build out a multi-endpoint system for WP-JSON between 4 websites, and most of the time it's fine, however sometimes when my page performs the process, it will throw back an error for the Foreach cycle, saying 'Warning: Invalid argument supplied for foreach() in ...'
I've tried alternative methods of merging the arrays before retrieving the body using wp_remote_retrieve_body but there's no such luck. I've looked up various google solutions on multiple-endpoints using php but nothing i've found seems to do an effective job
<?php
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
/* BASE DETAILS FOR SEARCH*/
$b_url = get_site_url(); // Base URL
$posts_merged;
$args = array(
'sslverify' => false
);
if($_GET['search'] or !empty($_GET['search'])){
$filter_query = '?search='.$_GET['search'];
}else{
$filter_query = '';
}
$post_url_collective = array(
$b_url.'/wp-json/wp/v2/posts'.$filter_query, // Main Site
$b_url.'/db/wp-json/wp/v2/posts'.$filter_query, // DB Site
$b_url.'/dc/wp-json/wp/v2/posts'.$filter_query, // DC Site
$b_url.'/fw/wp-json/wp/v2/posts'.$filter_query // FW Site
);
$post_response = wp_remote_get($post_url_collective[0], $args);
$post_response = wp_remote_retrieve_body($post_response);
$post_response = json_decode($post_response);
$post_response_two = wp_remote_get($post_url_collective[1], $args);
$post_response_two = wp_remote_retrieve_body($post_response_two);
$post_response_two = json_decode($post_response_two);
$post_response_three = wp_remote_get($post_url_collective[2], $args);
$post_response_three = wp_remote_retrieve_body($post_response_three);
$post_response_three = json_decode($post_response_three);
$post_response_four = wp_remote_get($post_url_collective[3], $args);
$post_response_four = wp_remote_retrieve_body($post_response_four);
$post_response_four = json_decode($post_response_four);
$posts_merged = array_merge( $post_response, $post_response_two, $post_response_three, $post_response_four );
?>
<div class="container multi-search-wrap">
<div class="row" style="margin-bottom: 0px">
<div class="col sm12 m12 l12">
<form class="multi-search-form" method="GET">
<div class="row" style="margin-bottom: 0px">
<div class="col sm8 m9 l10">
<input type="text" name="search" value="<?php echo ( isset( $_GET['search'] ) ? $_GET['search'] : '' ); ?>" placeholder="Search for..."/>
</div>
<div class="col sm4 m3 l2">
<input type="submit" value="Search" />
</div>
</div>
</form>
</div>
</div>
<div class="row" style="background: #eeeeee;padding: 10px;font-size: 12px;margin:0px 0px 20px 0px">
<div class="col sm12 m12 l12">
We've found <strong><?php echo count($posts_merged);?></strong> results for <?php echo $_GET['search'];?>...
</div>
</div>
<div class="row">
<?php
// Post Loop
foreach($posts_merged as $get_post) {
$image_url = $b_url.'/wp-json/wp/v2/media/'.$get_post->featured_media;
$image_response = wp_remote_get($image_url, $args);
$image_response = json_decode($image_response['body']);
//echo'<pre>';print_r($image_response);echo'</pre>';
echo '<div class="col sm12 m6 l6 multi-search-post">';
echo '<div class="row">';
echo '<div class="col sm12 m3 l4 multi-search-post">';
if(!empty($image_response->media_details->sizes->thumbnail->source_url)){
echo '<img class="img_'.$get_post->id.'" src="'.$image_response->media_details->sizes->thumbnail->source_url.'" width="auto"><br>';
}else{
echo '<img class="img_'.$get_post->id.'" src="'.get_template_directory_uri().'/images/post-placeholder.jpg" width="auto"><br>';
}
echo '</div>';
echo '<div class="col sm12 m9 l8 multi-search-post">';
echo '<a href="'.$get_post->link.'">';
echo '<h3>'.$get_post->title->rendered.'</h3>';
echo '</a>';
echo '<p>'.limit_text($get_post->excerpt->rendered, 30).'</p>';
echo '</div>';
echo '</div>';
echo '</div>';
}
?>
</div>
</div>
I would like to improve the load speed of the queries but the most important part is ridding this occassional Foreach error.
Any help would be greatly appreciated

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:

how to make banner image draggable inside div then save position

I've seen lots of questions and answers around how to do this but I am very stuck how I implement this into my webpage. I have a div named "banner" that contains an image drawn from a custom field that is on all my artist pages as a banner for each page. I would like to be able to drag this image inside the div and to save it's position. (I only want this function for myself, not visitors to the website) AKA Facebook page cover image.. This would allow me to add an image that is bigger than the div container to my custom field and for me to edit how this is showing inside the div.
This demonstates what I want to do- http://w3lessons.info/2014/08/31/facebook-style-cover-image-reposition-using-jquery-php/
but i don't understand where i put these codes in my wordpress files and how to make this work for me.. I only want this on my artist pages, and therefore using my single-artists.php template..
Here is my php code-
<?php
// artist download start
// if ( isset($_GET['download']) ) {
// header('Content-type: application/mp3');
// header('Content-Disposition: attachment; filename='.basename($_GET['download']));
// readfile( $_GET['download'] );
// }
// artist download end
get_header();
global $cs_transwitch,$prettyphoto_flag;
$prettyphoto_flag = "true";
$cs_artist = get_post_meta($post->ID, "cs_artist", true);
if ( $cs_artist <> "" ) {
$xmlObject = new SimpleXMLElement($cs_artist);
$cs_layout = $xmlObject->cs_layout;
$cs_sidebar_left = $xmlObject->cs_sidebar_left;
$cs_sidebar_right = $xmlObject->cs_sidebar_right;
}
if ( $cs_layout == "left" ) {
$cs_layout = "two-thirds column right";
$show_sidebar = $cs_sidebar_left;
}
else if ( $cs_layout == "right" ) {
$cs_layout = "two-thirds column left";
$show_sidebar = $cs_sidebar_right;
}
else $cs_layout = "sixteen columns left";
?>
<div id="banner">
<div id="bannercontent"><?php
list($src, $w, $h) = get_custom_field('banner:to_image_array');
?>
<img src="<?php print $src; ?>" width="100%" />
</div></div>
<script>$( "#bannercontent" ).draggable({
stop: function(){
alert('top offset: ' + $('#bannercontent').offset().top + ' left offset: ' + $('#bannercontent').offset().left);
}
});</script>
<div class="clear:both;"></div>
<div id="container" class="container row">
<div role="main" class="<?php echo $cs_layout;?>" >
<?php
/* Run the loop to output the post.
* If you want to overload this in a child theme then include a file
* called loop-single.php and that will be used instead.
*/
//get_template_part( 'loop', 'single_cs_artist' );
?>
<?php if ( have_posts() ): while ( have_posts() ) : the_post(); ?>
<?php
//showing meta start
$cs_artist = get_post_meta($post->ID, "cs_artist", true);
if ( $cs_artist <> "" ) {
$xmlObject = new SimpleXMLElement($cs_artist);
$cs_layout = $xmlObject->cs_layout;
$cs_sidebar_left = $xmlObject->cs_sidebar_left;
$cs_sidebar_right = $xmlObject->cs_sidebar_right;
$artist_release_date = $xmlObject->artist_release_date;
$artist_social_share = $xmlObject->artist_social_share;
$artist_buy_amazon = $xmlObject->artist_buy_amazon;
$artist_buy_apple = $xmlObject->artist_buy_apple;
$artist_buy_groov = $xmlObject->artist_buy_groov;
$artist_buy_cloud = $xmlObject->artist_buy_cloud;
}
//showing meta end
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="heading"><?php the_title(); ?></h1>
<div class="in-sec">
<?php
// getting featured image start
$image_id = get_post_thumbnail_id ( $post->ID );
if ( $image_id <> "" ) {
//$image_url = wp_get_attachment_image_src($image_id, array(208,208),true);
$image_url = cs_attachment_image_src($image_id, 208, 208);
$image_url = $image_url;
//$image_url_full = wp_get_attachment_image_src($image_id, 'full',true);
$image_url_full = cs_attachment_image_src($image_id, 0, 0);
$image_url_full = $image_url_full;
}
else {
$image_url = get_template_directory_uri()."/images/admin/no_image.jpg";
$image_url_full = get_template_directory_uri()."/images/admin/no_image.jpg";
}
//$image_id = get_post_thumbnail_id ( $post->ID );
//$image_url = wp_get_attachment_image_src($image_id, array(208,198),true);
//$image_url_full = wp_get_attachment_image_src($image_id, 'full',true);
// getting featured image end
?>
<div class="light-box artist-tracks artist-detail <?php if($image_id == "") echo "no-img-found";?> ">
<div id="main-container">
<div id="leftcolumn">
<a rel="prettyPhoto" name="<?php the_title(); ?>" href="<?php echo $image_url_full?>" class="thumb" >
<?php echo "<img src='".$image_url."' />";?>
</a>
<br>
<br>
<div id="inpostgallery"><?php echo do_shortcode('[inpost_gallery thumb_width="104" thumb_height="104" post_id="' . get_the_ID() . '" thumb_margin_left="0" thumb_margin_bottom="0" thumb_border_radius="2" thumb_shadow="0 1px 4px rgba(0, 0, 0, 0.2)" js_play_delay="3000" id="" random="0" group="0" border="" type="yoxview" show_in_popup="0" artist_cover="" artist_cover_width="200" artist_cover_height="200" popup_width="800" popup_max_height="600" popup_title="Gallery"][/inpost_gallery]'); ?></div>
</div>
<div id="rightcolumn">
<div class="desc">
<p style="font-size:12px;"><span class="bold" style="text-transform:uppercase; color:#262626;"><?php _e('Categories', CSDOMAIN); ?> :</span>
<?php
/* translators: used between list items, there is a space after the comma */
$before_cat = " ".__( '',CSDOMAIN );
$categories_list = get_the_term_list ( get_the_id(), 'artist-category', $before_cat, ', ', '' );
if ( $categories_list ): printf( __( '%1$s', CSDOMAIN ),$categories_list ); endif; '</p>';
?>
</p>
<br>
<h5><?php print_custom_field('stars:formatted_list', array('<li><img src="http://www.entertaininc.co.uk/wp-content/uploads/2015/09/gold-star-graphic-e1441218522835.png">[+value+]</li>','<ul>[+content+]</ul>') );
?></h5><br />
<h2><strong>Price</strong> <?php print_custom_field('price'); ?></h2> <br />
<h2><strong>Location</strong> <?php echo do_shortcode('[gmw_post_info info="city, country" divider=","]'); ?></h2><br />
<h4><?php _e('Description', CSDOMAIN); ?></h4>
<div class='txt rich_editor_text'>
<?php
the_content();
?>
</div>
<div class="clear"></div>
<?php edit_post_link( __( 'Edit', CSDOMAIN ), '<span class="edit-link">', '</span>' ); ?>
</div></div>
</div>
<div class="clear"></div>
</div>
</div>
<div class="in-sec">
<div class="artist-opts">
<div class="share-artist">
<?php
$cs_social_share = get_option("cs_social_share");
if($cs_social_share != ''){
$xmlObject_artist = new SimpleXMLElement($cs_social_share);
if($artist_social_share == 'Yes'){
social_share();
}?>
<?php }?>
</div>
<?php if($artist_buy_amazon != '' or $artist_buy_apple != '' or $artist_buy_groov != '' or $artist_buy_cloud != ''){?>
<div class="availble">
<h4><?php if($cs_transwitch =='on'){ _e('Buy This',CSDOMAIN); }else{ echo __CS('buy_now', 'Buy This'); }?></h4>
<?php
if ( $artist_buy_amazon <> "" ) echo ' <a target="_blank" href="'.$artist_buy_amazon.'" class="amazon-ind"> <span>';if($cs_transwitch =='on'){ _e('Amazon',CSDOMAIN); }else{ echo __CS('amazon', 'Amazon'); } echo '</span></a> ';
if ( $artist_buy_apple <> "") echo ' <a target="_blank" href="'.$artist_buy_apple.'" class="apple-ind"> <span>'; if($cs_transwitch =='on'){ _e('Apple',CSDOMAIN); }else{ echo __CS('itunes', 'iTunes'); } echo '</span></a> ';
if ( $artist_buy_groov <> "") echo ' <a target="_blank" href="'.$artist_buy_groov.'" class="grooveshark-ind"> <span>'; if($cs_transwitch =='on'){ _e('GrooveShark',CSDOMAIN); }else{ echo __CS('grooveshark', 'GrooveShark'); } echo '</span></a> ';
if ( $artist_buy_cloud <> "") echo ' <a target="_blank" href="'.$artist_buy_cloud.'" class="soundcloud-ind"> <span>'; if($cs_transwitch =='on'){ _e('SoundCloud',CSDOMAIN); }else{ echo __CS('soundcloud', 'SoundCloud '); } echo '</span></a> ';
?>
</div>
<?php }?>
<div class="clear"></div>
</div>
</div>
<?php
foreach ( $xmlObject as $track ){
if ( $track->getName() == "track" ) {
?>
<div class="in-sec">
<?php
enqueue_alubmtrack_format_resources();
?>
<div class="artist-tracks light-box">
<?php
$counter = 0;
foreach ( $xmlObject as $track ){
$counter++;
if ( $track->getName() == "track" ) {
echo "<div class='track'>";
echo "<h5>";
echo $artist_track_title = $track->artist_track_title;
echo "</h5>";
echo "<ul>";
if ($track->artist_track_playable == "Yes") {
echo '
<li>
<div class="cp-container cp_container_'.$counter.'">
<ul class="cp-controls">
<li><a style="display: block;" href="#" class="cp-play" tabindex="1"> <span>'; if($cs_transwitch =='on'){ _e('Play',CSDOMAIN); }else{ echo __CS('play', 'Play'); } echo '</span></a></li>
<li> <span>'; if($cs_transwitch =='on'){ _e('Pause',CSDOMAIN); }else{ echo __CS('pause', 'Pause'); } echo '</span></li>
</ul>
</div>
<div style="width: 0px; height: 0px;" class="cp-jplayer jquery_jplayer_'.$counter.'">
<img style="width: 0px; height: 0px; display: none;" id="jp_poster_0">
<audio src="'.$track->artist_track_mp3_url.'" preload="metadata" ></audio>
</div>
<script>
jQuery(document).ready(function($){
var myCirclePlayer = new CirclePlayer(".jquery_jplayer_'.$counter.'",
{
mp3: "'.$track->artist_track_mp3_url.'"
}, {
cssSelectorAncestor: ".cp_container_'.$counter.'",
swfPath: "'.get_template_directory_uri().'/scripts/frontend/Jplayer.swf",
wmode: "window",
supplied: "mp3"
});
});
</script>
</li>
';
}
if ($track->artist_track_downloadable == "Yes"){ echo '<li> <span>'; if($cs_transwitch =='on'){ _e('Download',CSDOMAIN); }else{ echo __CS('download', 'Download'); } echo '</span></li>'; }
if ($track->artist_track_lyrics <> "") { echo '<li> <span>'; if($cs_transwitch =='on'){ _e('Lyrics',CSDOMAIN); }else{ echo __CS('lyrics', 'Lyrics'); } echo '</span></li>';}
if ($track->artist_track_buy_mp3 <> ""){ echo '<li> <span>'; if($cs_transwitch =='on'){ _e('Buy Song',CSDOMAIN); }else{ echo __CS('buy_now', 'Buy Song'); } echo '</span></li>';}
echo "</ul>";
echo '
<div id="lyrics'.$counter.'" style="display:none;">
'.str_replace("\n","</br>",$track->artist_track_lyrics).'
</div>
';
echo "</div>";
}
}
?>
<div class="clear"></div>
</div>
</div>
<?php
}
}
?>
<div class="clear"></div>
<?php if ( get_the_author_meta( 'description' ) ) :?>
<div class="in-sec" style="margin-top:20px;">
<div class="about-author">
<div class="avatars">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'PixFill_author_bio_avatar_size', 53 ) ); ?>
</div>
<div class="desc">
<h5><?php _e('About', CSDOMAIN); ?> <?php echo get_the_author(); ?></h5>
<p class="txt">
<?php the_author_meta( 'description' ); ?>
</p>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</div>
<?php endif; ?>
</div>
<?php endwhile; endif; // end of the loop. ?>
<?php comments_template( '', true ); ?>
</div>
<?php if( $cs_layout != "sixteen columns left" and isset($show_sidebar) ) { ?>
<!--Sidebar Start-->
<div class="one-third column left">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($show_sidebar) ) : ?>
<?php endif; ?>
</div>
<!--Sidebar Ends-->
<?php }?>
<div class="clear"></div><!-- #content -->
</div><!-- #container -->
<div class="clear"></div>
<?php get_footer(); ?>
You need to use jQuery UI library (draggable) - https://jqueryui.com/draggable/
And then read the offset of the div or so
You also can use a jquery plugin named draggabilly. See the event dragMove or dragEnd. Hope it helps.

In PHP fetch content and truncate the string or variable, till 3rd breakline then display

//In PHP fetch content and truncate the string or variable, till 3rd breakline then display
//when i use this method the entire div deallocated and the its not displaying properly...hope the fetch content contain some image tags too // ...
<div class="mid-blks-cont">
<!-- Block1 -->
<div class="mid-block-1 boxgrid caption">
<?php
foreach ($querypost as $row) {
$content = $row->post_content;
$pcontent_overview = (strlen($content) > 300) ? substr($content,0,300).'... Read More' : $content;
if($img == "No Image Uploaded" ) {
?>
<img alt="" src="<?php echo base_url(); ?>assets/img/samples/sample1.jpg"style="width: 391px; height:231px"/>
<?php } else { ?>
<img alt="" src="<?php echo base_url(); ?>uploads/<?php echo $row->post_media ;?>" style="width: 391px; height:231px" />
<?php }?>
<h4 class="cat-label cat-label2"><?php echo $row->category;?></h4>
<div class="cover boxcaption">
<h3><?php echo $row->post_title;?><span class="topic-icn"><?php echo $row->comment_count;?></span></h3>
<p> <?php echo $pcontent_overview;?>....</p>
MORE <i class="fa fa-angle-double-right"></i>
</div>
<?php } ?>
</div>
</div>

Concrete5 - Custom block not editable, or recognized with the editing tool?

I'm making a site with conrete5. It's the first one I might add. I have made myself a couple of custom blocks. Named News, Teammates and References.
Now News and Teammates are not editable anymore. I will paste the News -blocks sourcecode.
----------- FORM.php ---------------------
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php
$al = Loader::helper('concrete/asset_library');
echo $al->file('optional', 'fID', t('Valitse kuva'), $bf, $args);
?>
<div class="form-group">
<?php echo $form->label('otsikko', t('Otsikko'));?>
<?php echo $form->text('otsikko', $otsikko);?>
</div>
<div class="form-group">
<?php echo $form->label('teksti', t('Teksti'));?>
<?php echo $form->text('teksti', $teksti); ?>
</div>
<div class="form-group">
<?php echo $form->label('korkeus', t('Korkeus'));?>
<?php echo $form->select('korkeus', array("108px"=>t("Pieni"),"299px"=>t("Iso")), $korkeus); ?>
</div>
<div class="form-group">
<?php echo $form->label('koko', t('Leveys'));?>
<?php echo $form->select('koko', array("col-md-3"=>t("Pieni"),"col-md-6"=>t("Iso")), $koko); ?>
</div>
<div class="form-group">
<?php echo $form->label('link', t('Linkki'));?>
<?php echo $form->text('link', $link); ?>
</div>
<div class="form-group">
<?php $psh = Loader::helper('form/page_selector');
echo $psh->selectPage('targetCID', $targetCID); ?>
</div>
----------- view.php ---------------------
<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$c = Page::getCurrentPage();
if($size=="col-md-3"){
$class='col-md-3';
$tag = $class;
}else{
$class="col-md-6";
$tag= $class;
}
if ($c->isEditMode()){
$class="editmode";
$editingStyle="padding: 15px; background: #ccc; color: #444; border: 1px solid #999;";
}
else {
$editingStyle = "";
}
$random = rand();
if($korkeus == "299px"){
$padding = '4px';
}else {
$padding = '5px';
}
$p = Page::getByID($targetCID);
$a = new GlobalArea('Header Navigation');
$blocks = $a->getAreaBlocksArray($c);
foreach ($blocks as $block){
if ($block->getBlockTypeHandle()=="autonav"){
$block->setCustomTemplate('cdrop.php'); // it's templates/cdrop.php -check the select option values when you set custom template manually at edit mode. I think you will need just "my_template"
$bv = new BlockView($block);
$bv->render('view');
}
}
?>
<?php $p = Page::getByID($targetCID); ?>
<a href="index.php">
<div class="pull-left <?= $koko;?>" style="padding:<?= $padding ?>;<?php echo $editingStyle;?>">
<div class="col-lg-12 alapalkki box" style="z-index:2;position:relative;">
<div class="image-big" style="background-color:transparent;text-align:center;position:relative;z-index:1;">
<!-- FiGuRe this shit out......... !-->
<?php
if($fID != 0){
$file = File::getByID($fID);
$filePath = $file->getVersion()->getRelativePath();
}
?>
<?php echo '<img src="' . $filePath . '" style="max-height:' . $korkeus . ';width:100%;"/>'; ?>
</div>
<div class="col-lg-12 " style="position:relative;z-index:255;padding:2px 0 0 15px;">
<div class="htitle">
<h4 style="color:white;"><b><?php echo $otsikko; ?></b></h4>
<p style="color:white;"><?php echo $teksti; ?></p>
</div>
</div>
</div>
</div>
</a>
Why is this not being an editable block? Why doesn't the concrete5 even recognize its existence when it is on the page? It just says at the area that it's empty.
$p = Page::getByID($targetCID);
$a = new GlobalArea('Header Navigation');
$blocks = $a->getAreaBlocksArray($c);
foreach ($blocks as $block){
if ($block->getBlockTypeHandle()=="autonav"){
$block->setCustomTemplate('cdrop.php'); // it's templates/cdrop.php -check the select option values when you set custom template manually at edit mode. I think you will need just "my_template"
$bv = new BlockView($block);
$bv->render('view');
}
}
?>
There's the problem. No idea what so ever what that is doing there..... Removed it. Worked like a charm.
-Kevin

Categories