Is it possible to transfer an id value from view to controller? - codeigniter

What I want to do is get the id from a button on my view:
<button type="submit" id="stuff">
to my controller, so I can change the style with:
echo '<style type="text/css">
#stuff{
background-color: #11eb00;
}
</style>';
Is this possible in CodeIgniter, or am I doing this completely wrong?

You shouldn't need to use PHP to output any css. This would be a general misuse of the intended system.
You can just put the css style as you defined it in the html, or ideally in its own css file that is properly linked in the header.
<link rel="stylesheet" type="text/css" href="/path-to-your-stylesheet.css">

Related

Can not display background-image in laravel

please help me! In resources/views/welcome.bale.php:
<link rel="stylesheet" href="{{asset('css/style.css')}}">
<div class="factarea overlay">
<h2>Facts that Make us Unique</h2>
</div>
In public folder: css/style.css
.factarea {background-image: url(../img/website.jpg);}
public/img/website.jpg location
I hope the below line will help you to resolve this issue.
You can try this.
background-image: url("/img/website.jpg");
You can try with another way like in-line css and check what we getting the image or not. so we can easily find the correct path.
Thanks
use root path
.factarea {background-image: url(/img/website.jpg);}
like this then
websiteurl/img/website.jpg will work here
websiteurl/public/img/website.jpg will not work only pretty url will work
so in order to work in public url as well you have to add inline css
which is
<link rel="stylesheet" href="{{asset('css/style.css')}}">
<div class="factarea overlay" style="background-image: url({{ asset('img/website.jpg') }})">
<h2>Facts that Make us Unique</h2>
</div>

why is blade making a head tag?

I'm using a Laravel app with an external public directory, e.g. root/Laravel, and root/html/public.
I need this app to load from a require on an php file that already has another framework(root/html/this-section.php), hence that other fw has its own head, and body tag. This app will load between the header and footer of that index.
In my blade layout.app file, i have
#section('stylesheets')
<link rel="stylesheet" href="/this-section/css/vendors.css">
<link rel="stylesheet" href="/this-section/css/app.css">
#show
<div id="main">
#include('layouts.sidebar')
#include('layouts.header')
<section>
#yield('content')
</section>
</div>
The issue I'm having is if no my app layout, when I delete the head and body tags during testing, which is what i need, the blade system, or what i dont know, is still creating an empty head tag set, <head></head>, then when i enable the stylesheets section, it ends up in that <head> tag.
Expected: The head tag should not be there. I don't want a head tag. What in laravel can i adjust to remove this auto creation of head (and body)?
It sounds like your using tags that belong in the <head> section is causing this. While your source may be pristine:
browsers will add in the missing-but-required tags as appropriate, resulting in you seeing them in the browser's web inspector:

Form Select with AspnetBoilerplate BSB Theme

Can't get a styled select form element to display correctly with the AspnetBoilerplate BSB Theme and there is no examples of one being used in the code.
I do see in the stylesheet the .bootstrap-select styles. Does someone have an example of how to use this?
Create your html with the .selectpicker class.
<select class="selectpicker">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
Options can be passed via data attributes or JavaScript.
$('.selectpicker').selectpicker({
style: 'btn-info',
size: 4
});
If you have not included libraries then include them all.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/i18n/defaults-*.min.js"></script>

Laravel 5 proper way to require CSS file from view

I've got specific Form component, which is declared as
Form::component('fcRadio', 'components.form.fcradio', ['name', 'options', 'selected' => null]);
and used as
{{ Form::fcRadio('name', $options }}
What I want is somehow attach custom CSS file, so if the page fires this component at least once, the desired CSS file is included to the <head> of my document.
For example, in Joomla it was like
$this->document->addStylesheet('my_awesome_style.css');
Is there any way to achieve the same in Laravel?
UPD:
I've extended the answers below a bit to let it add multiple styles from multiple templates. Finally, it looks like this:
#section('styles')
#parent
{{HTML::style('css/fcradio.css')}}
#stop
It works fine, but if I use the component twice per page, style is also adds twice. How can I allow multiple but unique entries?
So this is typically how I deal with it:
In your folder: resources/views I create a folder called layout. This folder handles the templates for all my pages.
Then I create a file called default.blade.php. In it I put the bulk of the HTML code. Here's an example of how default.blade.php could look (slimmed down, obviously)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
#yield('title')
</title>
<link rel="stylesheet" href="{{ asset('css/main.css') }}">
<!-- Additional per-page css -->
#yield('css')
</head>
<body>
#yield('content')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="js/script.js"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
<!-- Include per-page JS -->
#yield('js')
</body>
</html>
Right, so essentially what we have so far is the #yield() and asset() helpers.
#yield() is special blade syntax that Laravel uses to say, "Okay. Any time a blade view that is inheriting THIS master template calls the section named in this #yield() I will display that content right here.
asset() is a nifty little helper that basically appends your URL structure onto the string you pass it. So if your url is http://MyGreatSite.com and you use asset('js/script.js') it will spit out a fully qualified URL that will work anywhere on the site (http://MyGreatSite.com/js/script.js). asset() is great because you can use it in blade templates that will get sent out as an email and all of the files will work in an email inbox because they are absolute links.
Right. So now we have this master template and we need to use it. So what I do is create another view in the resources/views directory. Lets say we're doing a contact page. I would make contact.blade.php. Now I want to inherit that master template we created. So we do that like so:
#extends('layout.default)
#section('css')
<link rel="stylesheet" href="{{ asset('css/contact.css') }}">
#stop
#section('title')
Contact Us
#stop
#section('content')
<h1>Contact us</h1>
<p>
Contact us via email: contact#mygreatsite.com
</p>
#stop
#section('js')
<script src="{{ asset('js/contact-form.js') }}"></script>
#stop
Okay, so, first things first. At the very top we tell this blade file that we want to use the template we just made. We use the blade helper #extends() and pass it the path to our view relative to the views directory separated by periods.
Next, we want to create the sections that correspond to the template. We do that by opening the section with #section() and passing the name of the section we want to push this block of content to. We write our content and then we close the section by using #stop. Pretty simple. For images, css, or js, we simply use the asset() helper again.
I know it's a little long-winded, but hopefully that helps and explains the process a little better.
tl;dr: Use #yield(), #section(), and asset().
So I think I understand what you are saying.
In your blade layout file create a section inside the head:
<head>
#yield('componentcss')
</head>
And in the component do:
#section('componentcss')
{{HTML::style('css/fcradio.css')}}
#stop
You could also just include the css but I wouldn't advise this:
#section('componentcss')
<style>
.exampleclass {text-align:center;}
</style>
#stop
Hopefully I have understood you correctly.
I've finally found a bit tricky but working solution:
#hasSection('fcRadioStyle')
#else
#section('fcRadioStyle')
{{Html::style('css/components/fcradio.css')}}
#stop
#section('styles')
#yield('fcRadioStyle')
#append
#endif
This makes by Form::fcRadio append this style only once

Change Font Size of Help Text in Apex

I need to change Font Size of Page Items Help Text in Oracle Apex. How could I do this?
The Apex item help usually (maybe always?) has a class of "instructiontext". So you can define attributes for this using CSS. If you have a CSS script you can add an entry to it like this:
.instructiontext {color: red; font-size: 300%}
Otherwise you could simply add some inline CSS in the page template header like this:
<html lang="&BROWSER_LANGUAGE." xmlns:htmldb="http://htmldb.oracle.com">
<head>
<title>#TITLE#</title>
<link rel="stylesheet" href="#IMAGE_PREFIX#themes/theme_20/theme_3_1.css" type="text/css" />
<!--[if IE]><link rel="stylesheet" href="#IMAGE_PREFIX#themes/theme_20/ie.css" type="text/css" /><![endif]-->
#HEAD#
<!-- Add this -->
<style type="text/css">
.instructiontext {color: red; font-size: 300%}
</style>
<!-- End of my CSS -->
</head>
<body #ONLOAD#>#FORM_OPEN#
The result:
Ok, I know this is a seriously old post I'm digging up, but this post is what I ended up at, while searching for "instructiontext".
Anyway, I have new information. Tony's solution still works in APEX 5.0, but somewhere since between then and APEX 19.2, things got changed by Oracle. It appears that nolonger is the class "instructiontext" being applied, but instead the class "apex-help-dialog".
So, if you extend the CSS-definition like so:
.instructiontext, .apex-help-dialog {color: red; font-size: 300%}
it will work in both versions. This should prove convenient while transitioning your application from say, APEX 5.0 to APEX 19.2, like we are doing.
Hopefully this will be of some use to anyone.

Resources