How to integrated this pdf library : Wkhtmltopdf
with codeigniter app ?
I was using TCPDF, not so good, because I can not modify html propterties with javascript or jquery...
Oke, You know, if U wanna using TCPDF in CI, YOu must download TCPDF and put those TCPDF's folder to library for example.
And then, you make a file to extends the head class of TCPDF like
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once dirname(__FILE__) . '/tcpdf/tcpdf.php';
class TC_Pdf extends TCPDF
{
}
Okey. Now if I wanna using Wkhtmltopdf, what I am suppose to do ?
Related
I know how to display default view in Code Igniter. But, how can I access other files inside view folder. Example I want to display 'application/views/admin/index.php' but it isn't default view.
You can add sub folders in view like so.
$this->load->view('admin/index');
Is that what your meaning.
Codeigniter Views
File name: Example.php
<?php
class Example extends CI_Controller {
public function index() {
$this->load->view('admin/index');
}
}
Folder Structure
application
application / views /
application / views / admin
application / views / admin / index.php
I would not choose index.php for a name for a view I would rename it to another name dashboard.php or some thing. Because you have a index.php in the main directory.
im using the laravel 5.1 and building web app
i just bought HTML theme and directly copy all the css and Js files to public/assets ( not using any task runner such as gulp or grunt). i try to customize the login and register view page and if i use the default routing its fail to load the js and CSS ( just load plain HTML ) but if i point it directly by
Route::get('login','AuthController#getLogin')
its working . how can i fix the JS and CSS problem ?
*all the other pages works right and load the CSS and JS *
here are the screen shots from other pages and login page :
here is from my login page that fail to load :
if i use route to directly link to the page not passing through the Auth controller and after submit send data to login function ( like simple normal forms) its working but if goes through the controller system its fail . also if i use :
Route:resource('contact','contactcontroller')
my contact pages such as index, create , etc all are fail to load CSS but if i directly link to them like:
Route:get('contact','contactController#index')
it will successfully load the CSS and my page will be shows fine .
this question may help you with that !
Laravel stylesheets and javascript don't load for non-base routes
BTW : look at your page with firefox(chrome) Inspect Element Or Firebug to see the http requests!
Try using this way script and style link
{!! HTML::script('js/bootstrap.min.js') !!}
{!! HTML::style('css/bootstrap.min.css') !!}
<link href="{{URL::asset('../assets/css/bootstrap.css')}}" rel="stylesheet">
<script src="{{URL::asset('../assets/js/jquery.js')}}"></script>
I use these methods works 10/10.
I have two directories within my codeigniter controller.
/controllers/admin/
dashboard.php
content.php
enquiries.php
/controllers/members/
profile.php
chat.php
settings.php
Because the directory folders are not themselves controllers I can't perform any functions if the user browses to the root of the directory.
Example if the user browses to
/localhost/admin/
a view won't be loaded and will not show a 404. This lets users know that the directory does exist, giving me a security risk because people will know that I have an admin directory.
How is it possible to show a 404 message if the user browses to the root of the directory folder???
You could add this in config/routes.php:
$route['admin'] = 'errors/page_missing';
$route['members'] = 'errors/page_missing';
... where Errors is a controller with a method of page_missing, where you load a 'file not found' view.
The way I do it is creating the default controller welcome.php in the directories I wan't to hide and add the show_404() function. Like this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
show_404();
}
}
This way, you don't have to fiddle with routes or rewrite rules. Simple and clean.
I am using CodeIgniter Version 2.1 & trying to link assets like images,stylesheets, javascript files etc in my views by using, header.php:
<link href="<?php base_url();?>css/style.css" rel="stylesheet" />
my controller code, calls the view:
<?php
class Main extends CI_Controller{
public function index() {
$this->load->view('header');
}
The view file from which I am trying to load the asset is located
../application/views/header.php.
the css file is loaded:
../application/views/css/style.css
this does not work. I get 404 - Page not found error.then, I tried moving css/style.css outside ../application directory in webroot. To my surpise, having assets in webroot(outsite ../application/views) seems to work nicely.
Now,
My Question is
Is having our assets directly in webroot, outsite ../application directory right approach? If YES/NO, then why?
If having assets directly in webroot is a good idea, than should I move ../application/views directory in webroot as well? How?
PS: I am new to CodeIgniter framework, so unaware of the best practices
If you see this, the section where .htaccess is used to remove index.php from the urls, that has a rewrite condition:
RewriteCond $1 !^(index\.php|images|robots\.txt)
In this line, images is a folder that will be ignored while mod-rewriting. So, you can replace it by assets, put all your directly linking files there, and happily use them.
RewriteCond $1 !^(index\.php|assets|robots\.txt)
EDIT: my bad, hadn't seen the date the question was asked. nevertheless, should be useful for someone.
It is best to put your assets in the webroot folder. When requesting assest from the server (depending on your setup), it will start from the root directory and work it's way down.
http://yoursite.com/application/views/css/mystyles.css
if it's in the root you only need to go from there
http://yoursite.com/css/mystyles.css
Although it might be worth putting them all inside a folder (/assets) to keep them contained, as well as the ability to write a more effective rewrite rule (if you are trying to remove the index.php from the url) to ignore the single folder instead of all the individual folders (/css, /js, etc)
As for the views folder, it's best if you leave it in the application folder as CodeIgniter has a built in loader that automatically checks /application/views for the view file when you use the code $this->load->view('myview')
Although there are way to move the views folder, if you are new to CI it's probably best to leave it there for now.
For linking css you can do something like:
echo link_tag('css/mystyles.css');
Check this for ref: http://codeigniter.com/user_guide/helpers/html_helper.html
I have created a module that works on the administrator and public side. On the public side, I want to have a plugin for certain parts which I can put into the pages.
I have done this but it doesn't load after putting in {pyro:properties:rental}
Here is the code in /addons/modules/properties/plugin.php.
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Plugin_Properties extends Plugin
{
function rental()
{
$rentalForm = '<div class="search_full">
<div class="container_12">
<div class="grid_12">
<h1>Rental Search</h1>
</div>
<form action="" method="post">
<div class="grid_4">
<h2 class="liberationtext">Choose your destination</h2>
<label for="region">Region</label>
</div>
</form>
</div>
</div>';
return $rentalForm;
}
}
The module is called properties and the plugin just returns some HTML to display.
When I look at the log, it says ERROR - 2011-05-18 13:53:57 --> Unable to load: properties
I made this into a plugin (in the plugins folder) and it worked fine when I called it. I'm not sure what to do. Any help would be good.
I still a beginner in pyrocms but all seems correct implementing this modular plugin.
pyro tag {pyro:properties:rental} it's OK
file container /addons/modules/properties/plugin.php. it's OK
Code in plugin file it's OK
So the problem must be triggered in another part.
A very useful answer that mention modular plugins in Pyrocms module or widget or plugin
With this:
{{properties:rental}}
{{/properties:rental}}
you will see the search_full div output.
Use this
{{properties:rental}}
you don't need to close it
{{/properties:rental}}
Pyrocms developing-plugins