template content won't show in opencart - php

I'm having an issue with open cart(v2.0.3.1) and the journal template (v2.4.9).
The issue: when I add a journal module like the Carousel, Banners etc. and try to place the module in the content section (either column_right, column_left or content_top, content_bottom) it won't show up on the site (not only home but all other pages aswell) However if I cange the position to "top" or "bottom" it does show up!
I've checked the file catalog/view/theme/journal2/template/common/home.tpl
to check if the columns are printed and saw this:
<div id="container" class="container j-container"><div class="row"><?php echo $column_left; ?> <?php echo $column_right; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?><?php echo $content_bottom; ?></div>
</div>
So they seem to be echoed however they don't show up on the website.
Actualy they do show up but only with the opencart elements not the custom elements made by the template.
I could use some help because i've been searching for 2 whole days and I can't seem to find a propper solution.
Need to figure this out for a client.

The problem was in the template after I updated it to a newer version the issue resolved!

Related

CMS block only on first category page

I'm using Magento 1.9 and struggling on one thing.
I have a CMS block in my category page but I want it to show only on the first page! So if I scroll down and move to page 2 on the same category I don't want to see that CMS block again.
I tried to put this code in the CMS block... but it ignores me
(category-accordion.accordion is the main div of the CMS block)
<script>
if (window.location.href.indexOf("?p=") >-1)
{document.getElementsByClassName('category-accordion accordion')[0].display='none';}
// ]]></script>
Any idea?
EDIT:
tried the following code on the category page:
<?php if($this->isContentMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif($this->isMixedMode() && (strpos($_SERVER['REQUEST_URI'], '?=p') !== true)): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>
<?php elseif($this->isMixedMode() && (strpos($_SERVER['REQUEST_URI'], '?=p') !== false)): ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>
you can set condition in Category View Template catalog\category\view.phtml.
<?php
$currentPage = (int) $this->getRequest()->getParam('p', 1);
if($currentPage <= 1) {
echo $this->getCmsBlockHtml()
} ?>
try this.
<script>
if (window.location.href.indexOf("?p=") >-1)
{
jQuery('.category-accordion.accordion').hide();
}
</script>

PHP issue, forward slash showing on some pages but not others

I've got a php echo which I'm using to echo out image banners on a zen cart based system.
<hgroup id="cat_banner" style="background-image:url(images/categories/banners<?php echo"/"; echo strtolower(str_replace('&','and',str_replace(' ','_',$breadcrumb->last()))); ?>_banner.jpg);">
<h1 id="productListHeading"><?php echo $breadcrumb->last(); ?></h1>
<?php
// categories_description
if ($current_categories_description != '') {
?>
<p id="indexProductListCatDescription" class="content"><?php echo $current_categories_description; ?></p>
<?php } // categories_description ?>
it is not showing the / on some images but is showing it on others and displaying the image.
$path = strtolower(str_replace('&','and',str_replace(' ','_',$breadcrumb->last())));
<hgroup id="cat_banner" style="background-image:url("images/categories/banners/".$path."_banner.jpg)>

How to hide a div is function doesn't exist?

I am adding a custom layout for Genesis that will place the blubrry player. I got it correctly but my problem is the wrapping div. It is visible if no Podcast is added.
This is the code for the player:
<?php if function_exists('the_powerpress_content') the_powerpress_content(); ?>
Here is my complete code:
add_action('genesis_entry_header', 'the_powerpress_player');
function the_powerpress_player(){
if( is_single() || in_category('5') ){
?>
<div class="podcast-div"><?php if function_exists('the_powerpress_content') the_powerpress_content(); ?></div>
<?php
}
else {
echo "<div class="no-podcast">";
echo "<div>";
}
}
Is there other way where the div wrapper will show only if if the podcast attachment is added? I tried the above code but I got critical error. With no 'else' clause the div is rendered but I wanted it invisible if no podcast in the post.
TIA
Replace
echo "<div class="no-podcast">";
With
echo "<div class='no-podcast'>";
-----------^----------^---
<?php function the_powerpress_player(){
if( is_single() || in_category('5') ){ ?>
<div class="podcast-div">
<?php if function_exists('the_powerpress_content') the_powerpress_content();?>
</div>
<?php } else { ?>
<div class="no-podcast" style="display:none;">
</div>
<?php }?>

PHP - limiting the output of a plugin

I'm using a plugin titled "WP Recent Links" which I first learned about via Eric Meyer's site. Eric uses to display a Link Log within his site and I'm doing the same on my test site - http://matala.jorgeledesma.net/ but I'm running into a little situation and that is that I don't know how to limit the output either on the sidebar or the actual page - http://matala.jorgeledesma.net/recent-links/
My goal is to have it echo only the first 5 entries on the sidebar and for the recent-links page only echo the current month. The code below displays the sidebar properly
<?php if (!is_page('48')) { ?>
<aside id="meta" class="widget">
<h1 class="widget-title">Link Log</h1>
<?php if ($links = rp_recentlinks_home()) { ?>
<ul>
<?php foreach ($links as $link) { ?>
<b><li><?php echo wptexturize($link->link_text); ?></b>
<?php if ('' != $link->link_caption) { ?>→
<?php echo wptexturize(convert_smilies($link->link_caption)); ?><?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</aside>
<?php } ?>
and this code display the actual recent-links page
<h1 class="page-title"><?php rp_recentlinks_archive_header(); ?></h1>
</header>
<div class="entry-content">
<?php $links = rp_recentlinks_archive_page(); ?>
</div>
<?php if ($links) { ?>
<ul>
<?php foreach ($links as $link) { ?>
<p id="rlink-<?php echo $link->ID; ?>"><?php echo wptexturize($link->link_text); ?>
<?php if ('' != $link->link_caption) { ?>→
<?php echo wptexturize(convert_smilies($link->link_caption)); ?><?php } ?>
</p>
<?php } ?>
</ul>
<?php } ?>
I tried putting the following code in the body.
$list = array_slice($input, 0, 5); // $list now only having first 5 item.
But I don't know how to apply it, if that's the command at all. So perhaps, someone can guide in the right direction. Thanks in advance, Jorge.
Looks like all you have to add is this before you pass $links to the foreach loop:
$links = array_slice($links,0,5);

Magento - check if cms page

i want to check via php if a page is a cms_page in Magento. I need diffrent breadcrumbs for cms pages, so im trying to this with a condition, but i have no idea how to or where to look at.
Heres my breadcrumbs.phtml so far.
<?php if(this is a cms page): ?>
<p>some content</p>
<?php else: ?>
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php $charsges = 0; ?>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<?php
$charsges = strlen($_crumbInfo['label']) + $charsges;
if($charsges > 40){
$chars = 18;
if(strlen($_crumbInfo['label']) > $chars){
$_crumbInfo['label'] = substr($_crumbInfo['label'], 0, $chars);
$_crumbInfo['label'] = $_crumbInfo['label'].'..';
}
}
?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span> > </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
greets rito
The following should give you what you want
//from a block or phtml script
$this->getRequest()->getModuleName()
When this returns the string 'cms', you're on a CMS page.
When Magento's frontend and admin routers can't find a match on your URL, the CMS router takes over. If the CMS router finds a match (based on the CMS pages you've setup), it hands off the request to the cms module and Mage_Cms_IndexController controller.

Categories