How can I customize yii2 theme - yii

Im just trying Yii2. Now I have created a yii2 basic appication. Next what I want to do is change the theme. I have an HTML file I want to change this appications theme as like that HTML. I have gone through yii2 theming But Its not what i want I want to add all css,js,images,font of that HTML to my project. How can I do this in yii2 Plz somebody help me.

Hi you have to do following things for theming in yii2 as simple as yii1 :-
first of all open web.php into config directory of yii2 application,
then in component array pass view array like:
'view' => [
'theme' => [
'pathMap' => [
'#app/views' => [
'#webroot/themes/demo/views',
]
],
],
] // here demo is your folder name
now create the folder name as "themes" into web directory.
In this themes folder copy your html folder like(demo) which contains all css, js etc. files. in this folder create views folder as yii which contains main.php and others layouts if needed.
override index.php in views by your corresponding index file
by appropriate changes into paths of files. create corresponding views and
actions for your html files.
in yii2 we can define our css and js into Appasset.php .

Hi you need to do a few things to start off.
Copy the new HTML template Css, JS, Plugins and Images into your project directory eg testdrive/assets/
We need to link the CS and Js files to the project. Go to testdrive/protected/views/layouts/ directory and create a new file eg main.php add the respective css and js links to the respective files as you would on a html file in the head section.
<head>
<link href="<?php echo Yii::app()->request->baseUrl; ?>/assets/css/style.css" rel="stylesheet">
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body><? php echo $content ?></body>
3.Once the layout is ready we need to initialise yii to use the layout we have created. Proceed to the Controller eg SiteController.php
public function actionlogin{
$this->layout = 'main';
}
Now you're set to get your hands dirty.

Related

Vue Cli 4 not copying index.html to output path

I need to copy the index.html in public to a specific folder defined in public path, but this is not working as I expect.
I also don't want the cli to include header and scripts references in the html file.
My index html output should contains only: <div id='app'></div> plus some specific html tags required by our CMS system.
For that I use:
chainWebpack: config => {
// disable splitting of JS files for dist folder
config.optimization.delete('splitChunks')
config.plugins
.delete('html')
.delete('prefetch')
.delete('preload')
}
But my index.html is not being copied to my output path.
If I remove .delete('html'), index.html will copy normally, but with headers and script references.
I had the same with Vue Cli 3 and this used to work. What am I missing?

Link to file that opens in browser

I'm trying to provide a link to a gpg file on a webpage. Irrespective of relative path or absolute (static asset), on clicking the link, the index page keeps re-appearing. I don't want to use js to read the contents of gpg and render that. Instead, I want the browser to handle opening of the file (either open or download). Not working with other file types as well.
I have tried adding webpack config for this particular file type (file-loader/url-loader). Using raw-loader I can read the contents of the file, but I don't need that. Tried adding the file as an import.
To reproduce, create new project with vue-cli. Add this to App.vue template: Link
Create vue.config.js:
chainWebpack: config => {
config.module
.test(/\.gpg$/)
.use('file-loader')
.loader('file-loader')
.end()
}
}
Kindly suggest a way to include links to file present on the same domain. I don't want the vue app to handle rendering of such files.

How to use different css files for admin front end and main site front end nuxt js

I am trying to use two different layouts for my project. Currently I am using css file in nuxt config file like this
css: [
'~assets/css/main.css',
'~assets/css/admin.css',
],
It works but the problem is if I add css files for admin layout all front end and admin css are used in both places. How can I use these css separately?
Thank you.

How to get assets files url in yii?

I added CKEditor to my yii webApp and now i have problem with filebrowserBrowseUrl attribute,
What should i put instead of 4db59eda folder? Or how can i get assets files and folders url?
Thanks.
<script type="text/javascript">
CKEDITOR.replace( 'Projects_content',
{
filebrowserBrowseUrl :'http://localhost/altin/assets/4db59eda/filemanager/browser/default/browser.html?Connector=http://localhost/altin/assets/4db59eda/filemanager/connectors/php/connector.php',
At my project I've included the files in a folder called "js" at app root. It's at the same level of protected, css and etc.
You can add your scripts to your page like the following example:
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl.'/js/yourscript.js');
The best way to use URL's at the Yii is with Yii::app()->baseUrl.

How to use Free CSS Templates with ASP.NET MVC 4?

I need to use a css template for webpage I am building but I don't know how to use in asp.net mvc4. so How to use CSS Templates with ASP.NET MVC 4 in visual studio 2012 for web application?
It's simple:
Move your css and images into ~/Contents folder.
Move your js files into ~/Scripts folder
Copy and paste your html snippets to cshtml files
On 3rd step you need to port the layout portion of your template to ~/Veiws/Shared/_Layout.cshtml. Here you need to point references to your css and js correctly. For example:
And also you need to be aware that _Layout.cshtml should contain #RenderBody(). That's where all child views will be inserted.
Just found a video with basic demonstration of process: link
It is the same as you use for simpe HTML files. In the solution you can add an existing item and your browse your CSS file which will be added in the Content folder then you have to reference it in the page where it will be used.
If you want to apply all the rules to every page you can reference it in the _Layout.cshtml page which is called before everypage. It is like the container.
You have many options to call it. I will suggest you also reading Bundling and minification in this link which is also interesting to know.
There are Few Steps:
Make Directory inside Content folder in my case mytemplate.
Copy all your template content inside mytemplate folder.
Add new Layout page in View>Shared Folder in my case _mytemplate.cshtml.
open your template Index.html file inside any editor(i.e: Dreamviewer,Notepad etc).
Copy all header stuff from your html file to inside of Header in _mytemplate.cshtml file.
Copy all body stuff Inside of your Index.cshtml to Layout page.
Save your Project by Cntrl+S and Run it in browser. Thats it.