Working with multiple breadcrumbs in a knowledge base - php

I am working with Heroic Knowledge Base, and I am having trouble getting only one breadcrumb to show up (their suggested CSS code is not working). Unfortunately, I am not a PHP expert, and I am not sure how to edit the code so that it only shows one of the lines that it is pulling (we don't care which one) I have added the PHP from their breadcrumbs file. Any assistance would be greatly appreciated.
<?php
/**
* Breadcrumbs template
*/
?>
<?php if(hkb_show_knowledgebase_breadcrumbs()): ?>
<!-- .hkb-breadcrumbs -->
<?php $breadcrumbs_paths = ht_kb_get_ancestors(); ?>
<?php foreach ($breadcrumbs_paths as $index => $paths): ?>
<ol class="hkb-breadcrumbs" itemscope
itemtype="http://schema.org/BreadcrumbList">
<?php $last_item_index = count($paths)-1; ?>
<?php foreach ($paths as $key => $component): ?>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<?php if($key==$last_item_index): ?>
<span itemprop="item">
<span itemprop="name"><?php echo
$component['label']; ?></span>
</span>
<?php else: ?>
<a itemprop="item" href="<?php echo $component['link']; ?>">
<span itemprop="name"><?php echo $component['label']; ?></span>
</a>
<?php endif; ?>
<meta itemprop="position" content="<?php echo $key+1; ?>" />
</li>
<?php endforeach; ?>
</ol>
<?php endforeach; ?>

I was able to solve this issue using the following code, however I would like to make it so that it is only effective when there is more than one.. the code below worked on articles with two breadcrumbs, but when there is only one it hid them all together.
ol.hkb-breadcrumbs {
display: table-column-group;
}

Related

OpenCart get Product Viewes

First i should say i couldn't login into OC Support forum somehow, hope get solution here.
Trying to show Product Viewes in Product Page, I googled and found out how can to get another data from OC database and show it up on Product Page, so here is:
controller - product.php:
$data['viewed'] = $product_info['viewed'];
template - product.php;
<?php echo $viewed; ?>
but get error:
Undefined variable: viewed in
/homepages/5/xxxxxx/htdocs/xxxxx/catalog/view/theme/xxxxx/template/product/product.tpl
According to this Post i did right way, but i don't know why got get this error? any idea?
here is part of template code:
<h1><?php echo $heading_title; ?></h1>
<?php echo $viewed; ?>
<ul class="list-unstyled product-info">
<li><b><?php echo $text_stock; ?></b> <span class="Stock"><?php echo $stock; ?></span></li>
<li><b><?php echo $text_model; ?></b> <span class="Model"><?php echo $model; ?></span></li>
<?php if ($manufacturer) { ?>
<li><b><?php echo $text_manufacturer; ?></b> <?php echo $manufacturer; ?></li>
<?php } ?>
<li><b><?php echo $text_category; ?></b> <span>
<?php if( $categories ): ?>
<?php foreach( $categories as $category ): ?>
<?php echo $category['name']; ?><span class="Comma"> ، </span>
<?php endforeach; ?>
<?php endif; ?>
</span></li>
<?php if ($reward) { ?>
<li><b><?php echo $text_reward; ?></b> <span class="reward-points"><i class="fa fa-plus" aria-hidden="true"></i> <?php echo $reward; ?></span></li>
<?php } ?>
</ul>
If you're getting that error the only possible explanation is that the variable is not defined, which logically leads me to the conclusion that the file you edited is not the same controller that's calling your template. This can happen if you are using any OCMOD which has an unchanged version of product.php in the cache, since OCMOD doesn't know about changes you've made until you do a refresh. Do you have any OCMOD installed? Have you tried refreshing the OCMOD cache since you made the change?

Multilingual slideshow

I have this code for a slideshow in my Drupal 7, Nexus 7.x-1.3 theme.
My website is multilingual and I need to use a different image for every language, eg. I would like to change slide-image-1.jpg (en language) with other image-name for (gr language).
My code:
<?php if ($is_front): ?>
<?php if (theme_get_setting('slideshow_display','nexus')): ?>
<?php
$slide1_head = check_plain(theme_get_setting('slide1_head','nexus')); $slide1_desc = check_markup(theme_get_setting('slide1_desc','nexus'), 'full_html'); $slide1_url = check_plain(theme_get_setting('slide1_url','nexus'));
$slide2_head = check_plain(theme_get_setting('slide2_head','nexus')); $slide2_desc = check_markup(theme_get_setting('slide2_desc','nexus'), 'full_html'); $slide2_url = check_plain(theme_get_setting('slide2_url','nexus'));
$slide3_head = check_plain(theme_get_setting('slide3_head','nexus')); $slide3_desc = check_markup(theme_get_setting('slide3_desc','nexus'), 'full_html'); $slide3_url = check_plain(theme_get_setting('slide3_url','nexus'));
?>
<div id="slidebox" class="flexslider">
<ul class="slides">
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-1.jpg'; ?>"/>
<?php if($slide1_head || $slide1_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide1_head; ?></h2><?php print $slide1_desc; ?>
<a class="frmore" href="<?php print url($slide1_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-2.jpg'; ?>"/>
<?php if($slide2_head || $slide2_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide2_head; ?></h2><?php print $slide2_desc; ?>
<a class="frmore" href="<?php print url($slide2_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
<li>
<img src="<?php print base_path() . drupal_get_path('theme', 'nexus') . '/images/slide-image-3.jpg'; ?>"/>
<?php if($slide3_head || $slide3_desc) : ?>
<div class="flex-caption">
<h2><?php print $slide3_head; ?></h2><?php print $slide3_desc; ?>
<a class="frmore" href="<?php print url($slide3_url); ?>"> <?php print t('CONTACT US'); ?> </a>
</div>
<?php endif; ?>
</li>
</ul><!-- /slides -->
<div class="doverlay"></div>
</div>
<?php endif; ?>
<?php endif; ?>
Is there any solution for that? Thank you.
There is a Drupal connector from Smartling that may be of help. Here is a video showing how the connector works.
Many sites running on Smartling do language/country-specific image replacement, which is explained here.
Hope this helps,
Nataly
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<SCRIPT>
function english(){
$(#image).attr('src','http://link.to.your/english/image.png')
}
function greek(){
$(#image).attr('src','http://link.to.your/greek/image.png')
}
</SCRIPT>
<IMG id="image" src="http://link.to.your/greek/image.png">
Change to English<BR>
Change to Greek
Finally I fixed it in page.tpl with php code. One if/else on your page language to set you picture path.
Regards, HashKey

Fishpig Wordpress Repeater Fields

So I've got a Magento install, with Fishpig Wordpress Integration and the ACF plugin to pull in meta values. I'm also using the repeater field here which pulls in the metadata as an array (as I understand it). The Fishpig documentation is non- existent so alot of this is guess work really but here's my code:
<?php
/**
* #category Fishpig
* #package Fishpig_Wordpress
* #license http://fishpig.co.uk/license.txt
* #author Ben Tideswell <help#fishpig.co.uk>
*/
?>
<?php $page = $this->getPage() ?>
<?php if ($page): ?>
<?php $helper = $this->helper('wordpress') ?>
<?php $author = $page->getAuthor() ?>
<div class="page-title">
<h1><?php echo $this->escapeHtml($page->getPostTitle()); ?></h1>
</div>
<?php
$lookbooks = $page->getMetaValue('lookbooks');
if($lookbooks):
foreach ($lookbooks as $lookbook) {
$title = $lookbook['title'];
$content = $lookbook['content'];
$images = array($lookbook['images']);?>
<h2><?php echo $title;?></h2>
<div class="connected-carousels">
<div class="stage">
<ul>
<?php foreach($images as $image) { ?>
<li>
<img src="<?php echo $image['image'];?>" alt="<?php echo $image['alt'];?>" />
</li>
<?php } ?>
</ul>
‹
<a href="#" class="next next-stage" >›</a>
</div>
<div class="navigation">
‹
<a href="#" class="next next-navigation" >›</a>
<div class="carousel carousel-navigation">
</div>
</div>
</div>
<?php echo $content ; ?>
<?php }
else : ?>
<div class="post-view">
<div class="entry std">
<?php if ($page->isViewableForVisitor()): ?>
<?php if ($featuredImage = $page->getFeaturedImage()): ?>
<div class="featured-image left"><img src="<?php echo $featuredImage->getAvailableImage() ?>" alt=""/></div>
<?php endif; ?>
<?php echo $page->getPostContent() ?>
<br style="clear:both;"/>
<?php else: ?>
<?php echo $this->getPasswordProtectHtml() ?>
<?php endif; ?>
</div>
</div>
<?php endif;?>
<?php endif; ?>
What I'm trying to do is use the repeater field to make a carousel using jcarousel, I'm fine with my jquery but there's some sort of PHP error here preventing the page from loading.
Here's my ACF structure with the labels:
lookbook (repeater)
--title
--content
--images (repeater)
----image
----alt
I can't see any php errors in the servers error log, nor is the page displaying any errors. It's just not echoing the $image array although it is repeating the loop the right amount of times.
Maybe I'm miles away, maybe I'm nearly there I just can't see anything wrong with it.
Thanks in advance
There is an issue in version 1.2.1.0 of the ACF extension that breaks repeater fields that are embedded inside a repeater field. I have just released version 1.2.2.0 that fixes this issue and allows you to use repeater fields inside other repeater fields.

Wordpress Facebook Album Plugin

I am currently using a Wordpress plugin called Facebook Page Album and below is the example code for showing the Facebook page albums list and I'm trying to convert it into Wordpress short code but I'm not sure how I should go about it as I'm not to familiar with Wordpress but I can only seem to use the Return statement so how would I go about using the following code with a short code.
<?php
$list = facebook_page_albums_get_album_list();
?>
<ol class="album-list">
<?php foreach ($list as $item) : ?>
<?php
if ($item['type'] != 'normal' || $item['name'] == 'Cover Photos') continue;
?>
<li class="album">
<?php if ($thumb = $item['cover_photo_data']):?>
<div class="album-thumb">
<a href="<?php echo add_query_arg('id', $item['id']);?>">
<img src="<?php echo $thumb['picture'];?>"/>
</a>
</div>
<?php endif; ?>
<div class="album-info">
<h5><?php echo $item['name'];?></h5>
<div class="counts">
<div class="photos-count"><?php echo $item['count'];?></div>
<?php if (!empty($thumb['comments'])) :?><div class="comments-count"><?php echo count($thumb['comments']['data']);?></div><?php endif;?>
<?php if (!empty($thumb['likes'])) :?><div class="likes-count"><?php echo count($thumb['likes']['data']);?></div><?php endif;?>
</div>
</div>
</li>
<?php endforeach;?>
</ol>

jQuery Sortable Lists with CodeIgniter

I am attempting to make a sortable list out of list items populated from the database using the jQuery plug in but the effect is only applied to the first item presented:
<?php if(isset($bookmarks)) : foreach($bookmarks as $row) :?>
<div id="makeDrag">
<?php $fixed = preg_replace('#^[^:/.]*[:/]+#i', '', $row->URL); ?>
<li>
<div class="well">
<div><?php echo anchor('http://'.$fixed, $row->Name); ?></div>
<div><strong>Comments:</strong> <?php echo $row->Comments; ?></div>
<h4 class="btn-small">
<?php echo anchor("site/delete/$row->id", "Delete"); ?>
</h4>
</li>
</div>
<?php endforeach; ?>
I can kind of see where this is going wrong but do not know how to fix it. I would obviously like the effect to affect all the populated li not just the first one. Any help would be great. Sorry if I am unclear, I can try and rephrase things if this is confusing.
The cause is likely because you have
$('#makeDrag').sortable();
but you also have a foreach statement that creates multiple #makeDrag elements thus making your HTML invalid.
To fix this:
<?php if(isset($bookmarks)) : ?>
<ul id="makeDrag">
<?php foreach($bookmarks as $row) : ?>
<?php $fixed = preg_replace('#^[^:/.]*[:/]+#i', '', $row->URL); ?>
<li>
<div class="well">
<div><?php echo anchor('http://'.$fixed, $row->Name); ?></div>
<div><strong>Comments:</strong> <?php echo $row->Comments; ?></div>
<h4 class="btn-small"><?php echo anchor("site/delete/$row->id", "Delete"); ?></h4>
</div>
</li>
<? endforeach; ?>
</ul>
<?php endif; ?>
HTH

Categories