Have some issue with Opencart. Cannot understand why show objects twice while i'm just asking only one objects. I've created custom module on Opencart, add controllers on admin and catalog sections, views and language respectively. It works on one localhost, but shows twice objects on another localhost(where add new theme)
Here is my code on TWIG file:
link rel="stylesheet" type="text/css" href="../bmw/catalog/view/theme/default/stylesheet/categorieslist.css"/>
<div class="categorymodule">
{% for category in categories %}
<div class="categorylist">
<div class="categoryimage"> <img src="{{ category.image }}" alt="{{ category.name }}" title="{{ category.name }}"/></div>
<div class="categorytitle"><h4>{{ category.name }}</h4></div>
</div>
{% endfor %}
</div>
<div class="banner" id="banner">
<div class="kontur">
<img src="../new/image/catalog/kontur.png" style="width:100%">
</div>
<div class="pilsa">
<img src="../new/image/catalog/pilsa.png" style="width:100%">
</div>
<br>
</div>
It should show category image with title on the bottom and i add some banners, but when enter localhost root folder it's twiced(show categories and banners)
Module is added twice in the different layout positions (Design : Layouts : Home). On positions "Content Top" and "Content Bottom".
Related
I'm developing landing page with October CMS and using Static Pages plugin.
Here is my header.htm file with navigation:
<div class="header" id="header">
<div class="container">
<div class="header__inner">
<div class="header__logo">
<img src="{{ 'assets/img/logo.svg'|theme }}" alt="logo" class="logo">
</div>
<nav class="nav" id="nav">
{% partial 'menu-items' items=staticMenu.menuItems class='nav__list' %}
</nav>
</div>
</div>
</div>
Question is how to modify basic menu-items.htm partial if I'am using one page layout and I want exact section be active on menu item click (not separate page as it is now).
At the moment I have menu with such items and want one of these section be active on click:
/,
/#about,
/#projects,
/#contacts.
My menu-items.htm partial is below:
<ul class="{{ class }}">
{% for item in items %}
<li
class="nav__item {{ item.isActive or item.isChildActive ? 'active' : '' }}
{{ item.items ? 'dropdown' : '' }}"
>
<a class="nav__link"
{% if item.items %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}
href="{{ item.url }}"
>
{{ item.title }}
{% if item.items %}<span class="caret"></span>{% endif %}
</a>
{% if item.items %}
{% partial 'menu-items' items=item.items class='dropdown-menu' %}
{% endif %}
</li>
{% endfor %}
</ul>
At the moment code in menu-items.htm partial if statement add "active" class on click because of this line:
<li class="nav__item {{ item.isActive or item.isChildActive ? 'active' : '' }} {{ item.items ? 'dropdown' : '' }}"
...it is because item "isActive" property is "true" when exact menu item is clicked. But my question is, how to do the same (add "active" class) with section link in meniu navigation, because my project have only one page "home" and several sections in it. so I want menu navigation link be active on fixed navigation when someone click for eaxmple "About" link and scroll to /#about section.
I wrote just several lines of Jquery (thanks to Pettis Brandon advise).
$('.nav__item').click(function(){
$('.nav__item').removeClass('active');
$(this).addClass('active')
});
It removes 'active' class from '.nav__item' class and after that add it again on corresponding link, based on {{ item.url }}. Hope it helps for the other as well (who is using Static Pages plugin).
I am new to OctoberCMS and I am stuck now, I am facing issue to use my custom blog posts component (which overrides Rainlab blog posts) in the same page multiple times.
Say I have created an alias of default blogPosts to postLists and I defined my custom HTML structure and it is working well, no issues.
Now what I want is to use the postLists post structure in my page for three different categories and here I am stuck because when I pass variable to component like this - { % component 'postLists' categoryFilter='news' %} it does not work for the category filter and if I select a category from drag drop component UI it becomes global categoryFilter setting for the page.
This is my requirement.
My postList component code:-
{% set posts = __SELF__.posts %}
{% for post in posts %}
<div class="col-sm-6">
<div class="row">
<div class="col-sm-4 col-4 content_body_img">
<a href="{{ post.url }}">
{% if post.featured_images.count > 0 %}
<img class="media-object" src="{{ post.featured_images.first.getThumb(108, 108) }}" />
{% else %}
<img class="media-object" src="http://placehold.it/108x108" />
{% endif %}
</a>
</div>
<div class="col-sm-8 col-8">
<p>{{ post.title }}</p>
<!--location_date-->
<div class="location_date">
<ul>
<li><i class="fa fa-calendar"></i><span> {{ post.published_at|date('j F, Y') }}<span></li>
<li><i class="fa fa-map-marker"></i>Dubai</li>
</ul>
</div>
<!--location_date end -->
</div>
</div>
</div>
<!--content_body_img end -->
{% else %}
<div class="col-sm-6 col-6 col-lg-3">{{ noPostsMessage }}</div>
{% endfor %}
Please help me, any help will be very much appreciated.
Thanks Sanny
This is static Approach - I will post dynamic Approach as well give me some time
Best and possibly easy solution will be ( in case you just intend to show posts ) is to add 3 Post List component with Different Category filter option for each tab.
It should do your work
make sure this is optimal solution if you just need to show lists nothing else.
This question already has answers here:
How to concatenate strings in twig
(11 answers)
Closed 5 years ago.
I've got a project written in PHP in which I am using Symfony framework. This piece of code from Twig template doesn't work.
{% for restaurant in restaurants %}
<div class="col-md-3 col-sm-6 hero-feature">
<div class="thumbnail restaurant-thumbnail">
<img src="{{ asset('build/images/'.'image1.8e9b4ad0.jpg') }}" alt="cannot load image" class="restaurant-image">
<div class="caption">
<h3>{{ restaurant.getName() }}</h3>
<p>{{ restaurant.getShortDescription() }}</p>
<p>
Buy Now! Więcej informacji
</p>
</div>
</div>
</div>
{% endfor %}
When I change this
<img src="{{ asset('build/images/'.'image1.8e9b4ad0.jpg') }}"
to that:
<img src="{{ asset('build/images/image1.8e9b4ad0.jpg') }}"
code works. I don't know why.
plz try it
<img src="{{ asset('build/images/') }}{{'image1.8e9b4ad0.jpg'}}" alt="cannot load image" class="restaurant-image">
if you want to use Variable
<img src="{{ asset('build/images/') }}{{variable}}" alt="cannot load image" class="restaurant-image">
so I have this volt code:
views/administrator/index.volt
{{ content() }}
{% set user = session.get('user') %}
<br />
<div class="row">
<div class="col-xs-12 col-md-12 col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<a data-toggle="collapse" href="#container_userForm">
<span class="glyphicon glyphicon-asterisk"></span>
<b style="color: green;">New user</b>
</a>
</div>
<div id="container_userForm" class="panel-collapse collapse">
<div class="panel-body">
{% include "administrator/" ~ user['role'] ~ "-form-user.volt" %}
</div> <!-- end panel body -->
</div>
</div>
</div>
</div> <!-- end row -->
views/administrator/moderator-form-user.volt
exist and has some content.
but when I run the code, I have this error
View '/var/www/html/phalcon-dash/app/config/../../app/views/administrator/moderator-form-user.volt' was not found in the views directory
I took out the user['role'] and use {% include "administrator/moderator-form-user.volt" %}, it works normally (user['role'] = 'moderator')
can anyone explain to me why it happens and how to work around it, I'll need to implement more roles in the future, and I don't want to have multiple if-else in volt
Update
This is the answer to the problem
Volt not including file if path is concatenated
Have you tried it with partial?
{{ partial("administrator/" ~ user['role'] ~ "-form-user") }}
I'm guessing something is not right with views directory. Could you check it out as well?
From your controller, you can try this to get your views directory;
$this->view->getViewsDir()
Try to use the slash. Your include probably looks for a folder "administrator" inside of a folder "administrator", where index.volt is.
{% include "/administrator/" ~ user['role'] ~ "-form-user.volt" %}
im frecuent user of this forum and always find answers from other users, but this time i need to ask my own question.
At this moment im editing a wp template based on twig that i bought, right now im facing a fancybox gallery which just call the first image, and i need to add the gallery rel to the other images included in the post. i already found the missing code which call the rest of images from the post ID, but i dont know how to express it by the twig structure and incorporate it to the original code of the page
this is the code which display the gallery:
{% if wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
<div class="carousel property">
<div class="preview">
<a href="{{ wp.get_post_meta(post.ID, '_property_slides', TRUE).0.imgurl }}" class="fancybox">
<img src=" {{ wp.get_post_meta(post.ID, '_property_slides', TRUE).0.imgurl }}" alt="">
</a>
// the php code expressed on twig goes here //
</div>
<!-- /.preview -->
<div class="content">
<ul>
{% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
{% if loop.first %}
<li class="active" >
{% else %}
<li>
{% endif %}
<img src="{{ slide.imgurl }}" alt="">
</li>
{% endfor %}
</ul>
<a id="carousel-prev" href="#">{{ wp.__('Previous', 'aviators') }}</a>
<a id="carousel-next" href="#">{{ wp.__('Next', 'aviators') }}</a>
</div>
<!-- /.content -->
</div><!-- /.carousel -->
{% endif %}
This is the php code i need to implement on twig
add_filter(‘wp_get_attachment_link’,'add_gallery_id_rel’);
function add_gallery_id_rel($link){
global $post;
return str_replace(‘<a href’, ‘<a rel=”galeria’. $post->ID .’” href’, $link);
}
I really appreciate if you can help me with this (sorry about my weird english)
That code is a filter applied to the regular Wordpress functions, you are using a Twig Wrapper so that code won't work for you.
Try modifying the twig loop.
{% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
#... rest of the code
<a rel="galeria{{ post.ID }}" href="{{ slide.imgurl }}">
<img src="{{ slide.imgurl }}" alt="">
</a>
#... rest of the code
{% endfor %}
Skip the first slide using slice:
{% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE)|slice(1) %}
#... rest of the code same as above