I want change in code of open cart theme but all files is .twig so when I write php code in it don't work . until when i change in the stylesheet file . the theme don't see any changes.
how I can change .twig to php and make the theme see the changes in css file ??
this is part of header.twig
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ title }}</title>
<base href="{{ base }}" />
{% if description %}
<meta name="description" content="{{ description }}" />
{% endif %}
{% if keywords %}
<meta name="keywords" content="{{ keywords }}" />
{% endif %}
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
I want to add this code to it but when I put it in header.twig it don't work
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/style.css">
<?php if($direction=='rtl'){?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/rtl-style.css">
<?php }?>
You really shouldn't mix PHP with TWIG. Just use passed variables. Check the documentation for more info:
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29835
https://twig.symfony.com/doc/2.x/
Use this extension to enable twig: https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29835
Related
So I have this view1.php where I want to pass different values from different links to view2.php.
I manage to pass and get the value, but the css I put in my layout.php just won't work for view2.php.
I don't know where I'm doing it wrong.
Are there another way to pass different values other than this?
view1.php
#extends('layouts.layout')
#section('content')
<div>
OP 6000
OP 10000
OP 20000
</div>
#endsection
web.php
Route::get('/pass/{id}','User\MyController#postID');
MyController.php
public function postID($id) {
return view('user.view2', [
'id' => $id
]);
}
view2.php
#extends('layouts.layout')
#section('content')
<div>
{{$id}}
</div>
#endsection
layout.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<link rel="stylesheet" type="text/css" href="css/materialize.css" media="screen,projection"/>
<link rel="stylesheet" href="css/bootstrap/bootstrap.css">
<link rel="stylesheet" href="css/user.css">
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<nav> </nav>
<main class="">
#yield('content')
</main>
<footer> </footer>
#yield('alert')
</body>
<script type="text/javascript" src="js/materialize.min.js"></script>
</html>
Seems the css is not loading in view2.php. You need to use baseurl to load css.
Example : <link rel="stylesheet" href="{{URL::asset('css/user.css')}}">
This issue occurs because when you redirect another view your CSS not load properly.
My advice to you is using the assets method.
<link rel="stylesheet" type="text/css" href="{{ asset('css/materialize.css') }}" media="screen,projection"/>
<link rel="stylesheet" href="{{ asset('css/bootstrap/bootstrap.css') }}">
<link rel="stylesheet" href="{{ asset('css/user.css') }}">
Just because the URL of your view2 are http://something.com/pass/some_id and you are linking stylesheets by css/some_css.css so that, it is searching in the current directory i.e. pass so that, the URLs of the stylesheets are becoming like http://something.com/pass/css/some_css.css. That's an issue.
If you will use /css/some_cs.css, it will try to locate the files from the home directory i.e. the / directory, so the URL will become http://something.com/css/some_css.css and everything will work perfectly.
else, you should use the helper provided by Laravel
{{asset('css/some_css.css')}}
It will generate URL, where the files are located without fail.
I can't figure it out what could cause this issue, but i'am pretty sure it simple. I am extending main view main.blade.php (located in views folder). This includes css from partials folder.
I have two pages: Enquire, Approved enquire. (both located in views/trader/ folder.) only difference is routing, one would have /enquires the other would have /enquires/approved.
Blade/Css working if on main route: Route::get('/enquires','Trader\PagesController#getEnquires');
Blade/Css does not work when using suburl: Route::get('/enquires/approved','Trader\PagesController#getApproved');
Please refer to this image:
routing display error
If you require any other information please let me know,
Tahnks in advance,
Dan
It seems the problem is in how you're creating links to assets (images, CSS and JS files). To make it work, use Laravel asset() helper:
<link rel="stylesheet" href="{{ asset('css/theme.css' }}">
Which will create full path to an asset.
Also, you must keep all assets inside public directory of your project, for example: /laravel_project/public/css/theme.css
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>#yield('title')</title>
<meta name="keywords" content="HTML5 Template" />
<meta name="description" content="Trusted Workers - Find local tradesmen">
<!-- Favicon -->
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<!-- Mobile Metas -->
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Web Fonts -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light" rel="stylesheet" type="text/css">
<!-- Vendor CSS -->
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css">
<link rel="stylesheet" href="vendor/owl.carousel/assets/owl.carousel.min.css">
<link rel="stylesheet" href="vendor/owl.carousel/assets/owl.theme.default.min.css">
<link rel="stylesheet" href="vendor/magnific-popup/magnific-popup.css">
<!-- Theme CSS -->
<link rel="stylesheet" href="css/theme.css">
<link rel="stylesheet" href="css/theme-elements.css">
<link rel="stylesheet" href="css/theme-blog.css">
<link rel="stylesheet" href="css/theme-shop.css">
<link rel="stylesheet" href="css/theme-animate.css">
<!-- Current Page CSS -->
<link rel="stylesheet" href="vendor/rs-plugin/css/settings.css" media="screen">
<link rel="stylesheet" href="vendor/rs-plugin/css/layers.css" media="screen">
<link rel="stylesheet" href="vendor/rs-plugin/css/navigation.css" media="screen">
<link rel="stylesheet" href="vendor/circle-flip-slideshow/css/component.css" media="screen">
<!-- Skin CSS -->
<link rel="stylesheet" href="css/skins/default.css">
<!-- Theme Custom CSS -->
<link rel="stylesheet" href="css/custom.css">
<!-- Head Libs -->
<script src="vendor/modernizr/modernizr.js"></script>
I finally just got my Symfony2 app to work in Heroku except that it's not getting any CSS or JS. Does anyone know what the problem might be?
Including <head> code from the base.twig.html
<head>
<meta charset="UTF-8" />
<title>{% block title %}Machine{% endblock %}</title>
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{{ asset('bundles/bmatznerfoundation/css/foundation.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('bundles/project/css/main.css') }}">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="{{ asset('bundles/project/js/jquery-1.11.2.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/project/js/script.js') }}"></script>
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('bundles/project/favicon.ico') }}">
</head>
I noticed that it seems to be using Symfony2 favicon and such. So it might be using the wrong directory somehow, or bundle, for the "web" view of things.
it's
Root >
Web >
bundles >
bmatznerfoundation > ...
framework > (original symfony junk)
project > (THE FILES I WANT)
.htaccess
app.php
app_dev.php
apple-touch-icon.png
config.php
favicon.ico (a Symfony icon)
robots.txt
Haha, this is silly, in my .gitignore file, /web/bundles was there. I simply removed it, re-committed, then everything worked great!
This question already has an answer here:
Install assets from app directory
(1 answer)
Closed 7 years ago.
Im having problems with loading my css and js files.
Css and js are in app/Resources/views/css and app/Resources/views/js folders
This is my app/Resources/views/base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<link rel="stylesheet" type="text/css" href="../app/Resources/views/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../app/Resources/views/css/bootstrap-theme.min.css" />
</head>
<body>
{% block body %}{% endblock %}
<!-- this also doesnt work ofcourse -->
<script src="../app/Resources/views//js/jquery-2.1.4.min.js"></script>
<script src="../app/Resources/views//js/bootstrap.min.js"></script>
</body>
</html>
It cant find my files.
How should i solve this?
Thanks!
Your "app" folder is outside the webroot and can't be accessed. Put the files in the "web" folder instead!
I am working with symfony 2.5 and while including the css and js files although they seem to work but when i check the source in browser i see multiple css and js files being included where as i only included them once. This is what my header.html.twig looks like
{% block head %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Home | Flat Theme</title>
{% block stylesheets %}
{% stylesheets '#DefaultBundle/Resources/public/css/*' %}
<link rel="stylesheet" href="{{ asset('bundles/default/css/bootstrap.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/font-awesome.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/prettyPhoto.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/animate.css') }}/">
<link rel="stylesheet" href="{{ asset('bundles/default/css/main.css') }}"/>
{% endstylesheets %}
{% endblock %}
{% block topjavascripts %}
{% javascripts '#DefaultBundle/Resources/public/js/*' %}
<script src="{{ asset('bundles/default/js/html5shiv.js') }}"></script>
<script src="{{ asset('bundles/default/js/respond.min.js') }}"></script>
{% endjavascripts %}
{% endblock %}
</head>
{% endblock %}
<body>
Here is the source i see in browser and you will notice each css and js file has been mentioned over 5 times.
I tried removing the #DefaultBundle/Resources/public/css/* from {% stylesheets '#DefaultBundle/Resources/public/css/*' %} but doing that removes all the style
What am i doing wrong?
Try this:
{% block head %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Home | Flat Theme</title>
<link rel="stylesheet" href="{{ asset('bundles/default/css/bootstrap.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/font-awesome.min.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/prettyPhoto.css') }}"/>
<link rel="stylesheet" href="{{ asset('bundles/default/css/animate.css') }}/">
<link rel="stylesheet" href="{{ asset('bundles/default/css/main.css') }}"/>
<script src="{{ asset('bundles/default/js/html5shiv.js') }}"></script>
<script src="{{ asset('bundles/default/js/respond.min.js') }}"></script>
</head>
{% endblock %}
<body>
Or, if you don't want to call each file explicitly, try this:
{% block head %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Home | Flat Theme</title>
{% block stylesheets %}
{% stylesheets 'bundles/default/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
{% endblock %}
{% block topjavascripts %}
{% javascripts '#DefaultBundle/Resources/public/js/*' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
</head>
{% endblock %}
<body>
this is pretty funny
{% stylesheets '#DefaultBundle/Resources/public/css/*' %}
using that you're telling the template engine to iterate all the css in the assets directory, and adding all the <link/> to them, that's why they repeat times the assets
As per documentation:
(http://symfony.com/doc/current/book/templating.html#including-stylesheets-and-javascripts-in-twig)
You can also include assets located in your bundles' Resources/public folder. You will need to run the php app/console assets:install target [--symlink] command, which moves (or symlinks) files into the correct location. (target is by default "web").
http://symfony.com/doc/current/cookbook/assetic/asset_management.html#including-javascript-files
To include JavaScript files, use the javascripts tag in any template:
{% javascripts '#AppBundle/Resources/public/js/*' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
Including CSS Stylesheets:
{% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
Notice that in the original example that included JavaScript files, you referred to the files using a path like #AppBundle/Resources/public/file.js, but that in this example, you referred to the CSS files using their actual, publicly-accessible path: bundles/app/css. You can use either, except that there is a known issue that causes the cssrewrite filter to fail when using the #AppBundle syntax for CSS Stylesheets.