$tc="test tcpdf";
// print a block of text using Write()
$this->pdf->Write($h=0,$tc, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=true, $firstblock=false, $maxh=0);
I want to load view PHP in my codeigniter in TCPDF. I had success to export it from my string in my controller. But i want it to load from my view. Can you help me? Thanks
Related
I have a {{!! Form::model!!}} where I am passing a variable $values from the Controller and displaying it inside of the Form select those values. In mine main blade i have 3 additional blades I am including through
#if($jobs->open)
#include('jobs.review.open')
#endif
I am trying to load the data $jobs from controller only when someone clicks , I figured to do some by create an ajax call with onclick event, so i have the data $jobs back. An only now trying to include jobs.review.open blade.
Any help will be appreciated
One common strategy is to put the rendering in the AJAX call. The server returns a ready-to-go chunk of HTML in its reply, and the JavaScript code simply inserts it into the DOM at the appropriate place with innerHTML. The server uses a blade to prepare the HTML that it then returns.
The initial page HTML that is displayed doesn't include the content, but does include dummy placeholder <div>s which mark the places where the HTML will be inserted.
I want to save what I do with the ckeditor as a new document and use it as a view in laravel is possible? Any idea how I could do it?
thanks for your attention
Well, you are not providing and code, but you can do something like this and it should work. because this is just a WYSIWYG editor, you will need to use {!!$post(or whatever)->content!!}, this way every styling you make with the editor will be saved in the database and will not be escaped.
This is the controller where I keep everything in the ckeditor and saves it in the view resource
public function store(Request $request)
{
$ruta = base_path().'/resources/views/oficios/pdf/';
$nombre = "p.blade.php";
$archivo= $request->editor1;
\Storage::disk('pdf')->put($nombre, $archivo);
dd('Plantilla Guardada');
}
This is the html that is created with ckeditor for example:
<p><strong><em><s>{{ $oficio->subject }}</s></em></strong></p>
Then in another view I include #include ('oficios.pdf.p')
And it is there where I mark error by the character
Is there any way to send a complete lang file to a view, so that I can access the $lang-variable inside the view.
At the moment the only thing I can find is sending seperate lines to the view (using $this->lang->line('lang_key')) which sounds very antagonizing if I have a few dozen lines I want to print in the view.
My question is if there's a way to select a specific language file and make the whole $lang array in that language file accessible from a view.
Try this in you view in order to see all your lang array.
print_r($this->lang);
You should put :
$this->load->lang('your lang file name');
in the constructor of the controller from which you load your view.
and use it in the view as :
<?php lang->line('key');?>
Load the translation file in the constructor:
$this->lang->load('trans_file', 'spanish');
An then on the view, you can echo each line by:
<?php echo $this->lang->line('prod_not_found'); ?>
I will try to be as clear as possible to explain my problem. If not, tell me !
Mywebapp is based on Codeigniter. In it, I did a controller in order to show images uploaded by the users. By this way, the images can only be seen by members or authorized people and are not public like in facebook for example (image addresses are just hashed but are public).
I also use the mpdf library to generate a pdf from the content of a web page. To use it, I have in the third party directory the mpdf library. To be able to use it with my formatting, I put in the library directory (in application directory) my mpdf library (just to be able to use it from different controller). I have a pdf controller which is called from the view where I want to generate the pdf.
So the process is : I call a function of the pdf controller from my view. In this function, I call a function of my mpdf library which create a mpdf object (the third party class) and generate the pdf.
The generation of the pdf works great. The only I had is for the images. I explain. In my html document, the image are embedded like that :
<img src="http:localhost/www/myapp/library/image/hashed_name_of_the_image" alt="" />
The image function of the library controller retrieve the image and shows it. But in this function, I can protect or not the access to run it. For example, to force to be a logged user to see an image (if($this->session->userdata(‘logged’) == true)).
If there is no restriction, the generated pdf contains the images. Cool :).
But if I put a restriction, it doesn't. I understand that the mpdf object is the one which is asking to image function to show the image. So the verification failed.
I tried to use a config parameter on the CI instance object before I call the pdf function. For example, set to true a "pdf_conversion" and the conversion finished, set it back to false.
But it doesn't work. When I check the value in the image function, it's still false... It's like the config value is not change for all object but only for th pdf object which has changed it.
Is there a way to do what I want to do ??? With config parameter or anything else !!! I think I misunderstood something but don't know what !
thanks by advance for answers
Bastien
You problem is that then the library "calls" the image function, it is not logged in. So your controller code denies access.
There are two things you can do:
Move the code that generates/gets the image form the controller into a new library. then call that library from the controller and from the PDF library. This is the preferred way.
In the "image" action, find a way to check if the request is coming from the PDF library. Best guess is to look for something in the HTTP headers the PDF library sends. Anyway this is not very secure since HTTP headers can be "faked".
OFF TOPIC: Is there a reason you server the image from a controller action instead of by directly referencing the image file?
CLARIFICATION ON SOLUTION 1
So you'll have a library image.php that looks like this
class Image {
...
function get_image($hash){
[code for getting the image here]
}
...
}
In the controller:
function image($hash) {
$this->load->library('image');
if (if($this->session->userdata(‘logged’) == true)) {
$image = $this->image->get_image($hash);
[send it to the browser]
}
}
In the PDF library
function export($hash) {
$ci =& get_instace();
$ci->load->library('image');
[do pdf stuff]
$image = $ci->image->get_image($hash);
$this->add_image($image);
[do more pdf stuff]
}
This is the idea, the actual details of the implementation are up to you.
HI I have a codeigniter controller called CIcontroller and I have a method say redirectmethod
in the redirectmethod i have some code and then i do this
$data['redirect_page'] = 'page_name';
$this->load->view('template_view',$data);
the template view basically loads header footer and the corresponding view as specified by the data parameter
Now everything works fine but my url has value http:\\blabla\CIcontroller\redirectmethod instead of http:\\blabla\page_name
could anyone help me fix this thing
You need to emit a Location header to tell the browser to load a different page. See redirect in the url helper.