Setting of CRISPY_TEMPLATE_PACK variable in Django Crispy Forms - django-forms

I am referring to this: http://django-crispy-forms.readthedocs.org/en/d-0/install.html. I would like to use Django Crispy Forms together with Twitter Bootstrap, hence i need to set
CRISPY_TEMPLATE_PACK to bootstrap.
Where do i do this? I am not sure how to do this.. Need some guidance...

CRISPY_TEMPLATE_PACK = 'bootstrap'
it goes in your settings.py.

CRISPY_TEMPLATE_PACK = 'bootstrap4'
It should be added to your settings.py file in your root directory

Related

How to Use Vuejs on Laravel blade

everyone, I want to make a dormitory management system with laravel and vuejs but I don't know how to display my data instead of "welcome.blade.php" file but instead of "blade" use vue component if someone knows this please help me how to do this. I use API route for this
thanks everyone
You don't use it instead of blade you mostly use it with or inside blade.
Use Vue like normally would just treat your blade template as your plain HTML.

How is it possible to include a .blade file from outside of the Laravel project?

I have a Laravel 5.8 project and I'm using Blade to display the website.
However, I have .blade files outside of the Laravel project, that I'd like to #include() or display from the controller with return view(); with blade.
Here is a similar folder structure:
/var/www/examplesite1/
/var/www/examplesite2/
/var/www/laravel/
/var/www/storage/blade/
So for example the Laravel application is on the /var/www/laravel/ path. The blade file I'd like to get is from this path /var/www/storage/blade/.
What I tried was:
return view('/var/www/storage/blade/file.blade.php');
include('/var/www/storage/blade/file.blade.php');
None of them worked, becauase I got an error like this: View [.var.www.storage.blade.file.blade.php] not found.
I also tried it with omitting the 'blade.php' from the end, but it's the same.
Is it possible to include a blade file from outside the Laravel project? If yes, how?
You can add new directories to the views paths in config/views.php. https://laravel-news.com/laravel-view-path

How can I access the value from a Vue component?

I am trying to make my portfolio using Laravel. I am very new to Laravel. I thought by making a mini project in it will make me familiar with Laravel. Recently, I figured out that Laravel has a dependency on Vue.js
I tried to include jQuery libraries as I am not at all familiar with Vue. But that didn't go so well. Then I started searching for Vue.js but I couldn't find much.
With a lot of effort I made the following Vue component:
var trialEle = new Vue({
el: '#trialEle',
data: {
working: 'yes'
}
});
And then I tried to access the value of working by the following markup:
<div id="trialEle">
<h1>Is this working: {{working}}</h1>
</div>
But I don't know what I am missing because I am constantly having this error:
UPDATE:
As suggested by #Chamara in the answer below, I have changed {{working}} to #{{working}}, now there is no error screen.
But still I cannot access the value of working from my Vue component.
It is displayed on the page as follows:
Is this working: {{working}}
Any help will be truly appreciated.
Thanks in advance.
{{}} is a built in syntax in blade if you need to use vue {{}} inside your blade file you need to put # in front of the {{}}. So like this#{{working}}. # in blade ignore it as a syntax.

Laravel - how to access public folder from JS file

I am using the exact same Ajax call in multiple blade templates.
If Ajax fails, I show an error jpg located in public/images/danger.png.
When I had my JS in the blade file written inline in <script> tags, it was easily accessible as I had blade helpers to access public with:
{{asset('/images/danger.png')}}
Yet now, accessing /public with:
http://"+location.host +"/public/images/danger.png
is impossible.
It would be unDRY to put the exact same AJAX call in 12 blades, no need to elaborate why..
How do you guys counter this issue?
remove /public from your route,you can directly use /images/imgname.jpg
You can just use absolute routes in your javascript files. This will however not work if your Laravel application sits in a sub folder.
"/public/images/danger.png"
just the same as used in html (in blade)
like
$('.abc').attr("src", "{{asset('imgs/male_b.svg')}}");

Joomla: How to create a file inside a component that can be accessed directly?

I am trying to override a component. The file structure is like this:
templates/mytemplate/html/com_contact/contact/<files>
From inside the default_form.php, I want to access another php file. So where do I keep that other file and what changes do I have to make to the component view? I am using Joomla 1.5.15.
What type of change? Is it a change you can make in the template override?
Well you can include it as a simple iframe like here or if you want to include a php file you can use include or require_once like here.

Resources