Blade templating - laravel-4

Is it possible to have the master.blade.php file outside of the template files.
Example below:
views/
master.blade.php
layout/
hello.blade.php
views/layout/hello.blade.php
#extends('layout.master)
I have tried the above but it cannot find the master.blade.php file. So is there a way to refer to a directory above the blade file.

it would be
#extends('master')
the "." in the view names indicate folders. so
#extends('my.long.path.to.template')
would be found in:
/views/my/long/path/to/template.blade.php
layouts don't have to be in a folder called layouts

Related

pdf generation with Laravel

I'm using LynX39\LaraPdfMerger to generate my pdf files from a file named pdf.blade.php. When it's a normal html file everything seems to be good but once generate the pdf file everything is wrong and ugly. Is there any way to make the blade looks like the normal html file? You can see the 2 images below. Any help will be appreciated. Thanks.
to generate the file
$pdf = PDF::loadView('layouts.pdf_view', $data);
return $pdf->download('fiche' . '_' . time() . '.pdf');
pdf file
!https://drive.google.com/open?id=1309cGQl8sFPB22vFZTOdseBt-M7rCTjs
html file
!https://drive.google.com/open?id=1oSJFfRkKsraonATJa50ExH3yNN2HcQqH
do one thing change permission of css folder to +750.
then put css path like
<link rel="stylesheet" href="{{ URL::asset('css_public_path') }}" type="text/css" />

Magento - where to add include files

I need to include a php snippet to a few .phtml template files e.g. <?php include("foo.php") ?>:
Where is the common place to add foo.php? Can I just create a folder called "partials" in the root dir or is there already a special place for include files?

unable to load header file through sub-folders in codeigniter

unable to load header file.
Structure of my codeigniter
Views->dashboard/admin_dashboard/dashboard.php
Controllers->dashboard.php
Now i have header in
Views->header/admin_header/header.php
I have tried with < ?php include('../../header/admin_header/header.php'); ?>
Thanks,
I think you shouldn't do include, try load view instead:
$this->load->view( 'header/admin_header/header' );
How about making subfolder for controller?
Here what you should do:
Ex:
controllers
- test
-- Main.php
Then you should regist it on config/routes.php, just add on newline:
$route['test/(:any)'] = 'test/$1';
Now you can access all controller files inside folder test

Include other .tpl in a .tpl file Prestashop

I'm usinh a Prestashop 1.5.4.1, and I would like to call a module in other module (precisely I need to use slider module just above the home featured products). I tried to call it via
include file='../directory/module.tpl'
but always I get only blank page without any code. I also tried with different ways of directory statement, but always the result was the same. Is there any possibility to include new module in correct way?
For this to work, your directory structure should be (Using PrestaShop 1.6):
-- mymodule.php
-- views
---- templates
------ hook
------ displayFooBarTemplate.tpl
-------- inc
---------- foo.tpl
---------- bar.tpl
Absolute way:
From your main module file:
protected function displayFooBarTemplate()
{
global $smarty;
...
$smarty->assign('module_templates', dirname(__FILE__).'/views/templates/');
return $this->display(__FILE__, 'displayFooBarTemplate.tpl');
}
then in your tpl file (displayFooBarTemplate.tpl):
{include file="{$module_templates}hook/inc/modal/foo.tpl"}
{include file="{$module_templates}hook/inc/modal/bar.tpl"}
Relative way (my favorite):
{include './inc/foo.tpl'}
{include './inc/modal/bar.tpl'}
What worked for me in Prestashop 1.6 is
{include file="$tpl_dir/modules/blocknewsletter/blocknewsletter.tpl"}
I put this in the footer.tpl file and correctly displayed the text box for subscribing to the newsletter. I suppose it works for all other modules, too.
Proper way to include a smarty tag includes using the curl brackets.
{include file='directory/module.tpl'}
Note that the directory in the include statement should be relative to the templates directory.
http://www.smarty.net/docsv2/en/language.function.include.tpl
In your php code declare a variable like this :
$this->path_to_tpl_folder = str_replace('\\', '/', _PS_MODULE_DIR_) . 'mon_module/tpl';
$this->context->smarty->assign('tpl_path', $this->path_to_tpl_folder)
Then in your smarty template :
{include file=$tpl_path/my_file.tpl}
Compatible with Prestashop 1.4 and 1.5.

codeigniter image path

I am a codeignite newbie and tried to add an image in my file under view folder.
I add <img src="../images/myImage.jpg"></img> to my service_view.php. All I can see is a broken link of a small icon.
however, if I change my path to
<img src="../../user_guide/images/myImage.jpg"></img>
I can see the image.
My file system is as follow:
application-
view ->folder (where service_view.php is located)
images -> folder (where myImage.jpg is located)
user_guide-
images ->folder ((where myImage.jpg is located))
Can anyone help me about this? Thanks a lot!
I would suggest storing images in an images folder at the same level as the application folder, instead of trying to mix both PHP code and resources underneath application. Then just link to it like you did to the user guide:
<img src="../../images/myImage.jpg" />
I know more than year has passed since the question was asked but for anyone who comes looking in future, Here is my solution....
I've tried this created a folder images at same level as that of application, in main index.php added a line before last require_once statement.
define('IMAGE_PATH', APPPATH.'../images/');
and used IMAGE_PATH anywhere I wanted to display images.
Hope this helps
I just have an image folder,
domain.com/images
then on the views i just use /images
<img src="<?php echo base_url(); ?>images/image.png" />
and put the images folder outside of the application folder in the same directory
Create an images folder at the same level of the applications folder.
With base_url() you can get the location of your site's base (cfr config).
This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet.
For example:
<img src="<?php echo base_url("/images/icons/stackOverflow.png"); ?>" alt="StackOverflow" title="StackOverflow is the best!" />
This would give you something like: ... src="http://example.com/images/icons/stackOverflow.png" ...
Source: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
it is better practice to upload the images in a folder that is present in the root or the site folder and use base href in the first line of head tag. then the whole page does not need and http path reference. just use the relative path. as codeigniter run using the index.php file in the root, we should use all the relative path w.r.t that index.php page
on local server try this
<img src="http://localhost/ci/uploads/<?php echo $this->upload->data()['file_name'];?>" width="200px"/>
on live use this
<img src="<?php echo base_url();?>/uploads/<?php echo $this->upload->data()['file_name'];?>" width="200px"/>
put a folder on your root directory such as "assets/images/" and the in your code just use it as
<img src="assets/images/imgname.jpg"></img>
Your file structure should be
-applications
-images
-assets
-Or any folder.
Keep the application folder, images folder, and assets folder inside the basic root folder.
Use when you want to include something from your root folder
FCPATH = C:\xampp\htdocs\your_root_folder\
<img src="<?php echo FCPATH; ?>/images/myImage.jpg" />
<img src="<?php echo base_url('/assests/images/image_name.jpg')?>" alt="">
This is the exact path for codeigniter, don't need write the "../../.." just write the path from assets (folder name)(sibling of application).
base_url gives the path of your project folder, not the path of the view folder inside application folder.

Resources