Hy all,
I'm trying to give users an confirmation message when they unsubscribe to an newsletter. But i'm only getting the confirmation message without the rest of the website.
Here's the url so you can see what's going on...
In the unsubscribe controller class i have this code to render the page:
$this->language->load('newsletter/unsubscribe');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->template = 'default/template/newsletter/newsletter.tpl';
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
My template file looks like this:
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
When i look at the other's ( the product controller or the account, and google ) it says that this is the right way to render the page ( with the childs like that ). But as you can see, the children ( the rest of the site ) isn't renderd.
What did i miss? Why isn't this working?
Alright, i've figured it out. I could delete my question, but mayby does this help others in the future so i'm answering it...
My template file looked like this:
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
That's only the content. But you also need to echo the header, footer and all that kind of stuff. So you've got to do something like thisedi:
<?php echo $header; ?>
<?php echo $column_left; ?>
<?php echo $column_right; ?>
<div id="content">
<?php echo $content_top; ?>
<h1 style="display: none;">
<?php echo $heading_title; ?>
</h1>
<div class="box">
<div class="box-heading">Uitschrijven</div>
<div class="box-content">
<div id="notification">
<div class="success" style="">
U bent succesvol uitgeschreven.
<img src="catalog/view/theme/metroshop/image/close.png" alt="" class="close">
</div>
</div>
</div>
</div>
<?php echo $content_bottom; ?>
</div>
<?php echo $footer; ?>
And that's working fine now. Hope that this help's somebody in the future.
Related
I am using OpenCart v 2.1.1.
In the admin area, the settings area indicates that the theme is set to Default.
On the server, I navigated to catalog -> view -> theme -> default -> template -> common
and opened up the header.tpl file for editing.
Inside the header.tpl file, I located line 115 which appears to be the last item
<li><?php echo $category['name']; ?></li>
Then on the next line I added in:
<li>Contact Us<li>
I Saved Changes, refreshed web page, and the Contact Us link does not appear in the blue menubar.
What have I done wrong..
you need to delete the cache of the template engine, else it won't update the cached template.
seems you add this line to the not correct place. you should add it before the last </ul> tag. this is 114 line in OC2.1 version.
<li>Contact Us<li>
</ul>
The last part of the header.tpl:
<?php if ($categories) { ?>
<div class="container">
<nav id="menu" class="navbar">
<div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<?php foreach ($categories as $category) { ?>
<?php if ($category['children']) { ?>
<li class="dropdown"><?php echo $category['name']; ?>
<div class="dropdown-menu">
<div class="dropdown-inner">
<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
<ul class="list-unstyled">
<?php foreach ($children as $child) { ?>
<li><?php echo $child['name']; ?></li>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php echo $text_all; ?> <?php echo $category['name']; ?> </div>
</li>
<?php } else { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
<?php } ?>
<li>Contact Us<li>
</ul>
</div>
</nav>
</div>
<?php } ?>
I have checked it works with default. Of course do not forget clear cache of your browser.
Kindly tell me about auto run carousel module from carousel.tpl? i am very new in opencart kindly help me. I have edited with JS.
<div id="carousel-<?php echo $module; ?>" class="banners-slider-carousel">
<?php /*?><div class="box-heading"><span class="heading_inner">Our Brands</span></div><?php */?>
<div class="customNavigation">
<a class="btn prev"> </a>
<a class="btn next"> </a>
</div>
<div class="product-carousel" id="module-<?php echo $module; ?>-carousel">
<?php foreach ($banners as $banner) { ?>
<div class="slider-item">
<div class="product-block">
<div class="product-block-inner">
<?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 } ?>
</div></div></div>
<?php } ?>
</div>
</div>
<span class="module_default_width" style="display:none; visibility:hidden"></span>
<script type="text/javascript"><!--
$('#carousel-<?php echo $module; ?>-carousel').jcarousel({
items: 6,
autoPlay: 3000,
navigation: true,
navigationText: ['<i class="fa fa-chevron-left fa-5x"></i>', '<i class="fa fa-chevron-right fa-5x"></i>'],
pagination: true
});
--></script>
try this script
<script type="text/javascript"><!--
$('#module-<?php echo $module; ?>-carousel').owlCarousel({
items: 6,
autoPlay: 3000,
navigation: true,
navigationText: ['<i class="fa fa-chevron-left fa-5x"></i>', '<i class="fa fa-chevron-right fa-5x"></i>'],
pagination: true
});
--></script>
I have to tweak the searchform from my wordpress theme, because it wont allows me to use accents such as é/è/à/ù etc, I dont to make them non-special chars and I thought about using Regex but cant figure out how/where to put the regex snippet.
Here is the page code :
do_action( 'mytheme_before_searchform' ); ?>
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<div class="row collapse">
<?php do_action( 'mytheme_searchform_top' ); ?>
<div class="small-11 columns">
<input type="text" value="" class="search-form" name="s" id="s" placeholder="SEARCH">
</div>
<?php do_action( 'mytheme_searchform_before_search_button' ); ?>
<?php do_action( 'mytheme_searchform_after_search_button' ); ?>
</div>
Any idea how I should proceed ?
Thanks
You have to put it on your theme's function file. In my case the form is redirected to the wp page /google-search (permalink), like this:
function add_rewrite_rules($aRules) {
$aNewRules = array('google-search/([^/]+)/?$' => 'google-search?pagename=page-google-search&q=$matches[1]');
$aRules = $aNewRules + $aRules;
return $aRules;
}
And i have registered the q var so wp allows it to be passed on the url.
Hope this help!
i create new template for j2.5,
i need to add many module only show on home,
now i need to show many module all page without home,
pleas see my code below :
<div class="row" style="margin-top:20px;">
<div class="col-xs-12 co-md-12">
<?php if($this->countModules('adsright')) : ?>
<div class="col-xs-12 col-md-2">
<jdoc:include type="modules" name="adsright" style="custom" />
</div>
<?php endif; ?>
<div class="col-xs-12 col-md-10">
<div class="content">
<jdoc:include type="message" />
<jdoc:include type="component" /> </div></div>
</div>
</div>
when add module to adsright position and unchecked home page,was not show on my content,
how can i solve that ?
please tell me full way for create position conditional.
thanks.
please give some clear description of your problem.
And if you want certain positions and div structure on home page and not require same on inner pages then you can set condition based on this code. I hope this will help.
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'Home page';
}
$html = '<html>
<body>
<div id="dupe_1">1
<div class="dupe_1.1">1.1</div>
<div id="dupe_1.2">1.2</div>
</div>
<div id="dupe_2">2
<div class="dupe_2.1">2.1</div>
<div id="dupe_2.2">2.2</div>
<div>extra</div>
</div>
</body>
</html>';
$html = phpQuery::newDocumentHTML($html);
$node = pq('div:regex(id,^dupe_\d+$)',$html);
echo count($node);
This returns 7 that is all divs. It should return only 2 divs (dupe_1 and dupe_2)
I would avoid doing things like that, you should be able to get those with css:
[id*=dupe_]:not([id*="."])