Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '../index/index.tpl'' in
/var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php:174
Stack trace:
#0 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(551): Smarty_Internal_Template->isExisting(true)
#1 /var/www/docs/sw.com/public/application/tmp/smarty_compile/898ca70906754084b81f61d3ce7baee3b11bd8d3.file.layout.tpl.php(46): Smarty_Internal_Template->getRenderedTemplate()
#2 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(436): include('/var/www/docs/s...')
#3 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(568): Smarty_Internal_Template->renderTemplate()
#4 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(328): Smarty_Internal_Template->getRenderedTemplate()
#5 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(370): Smarty->fetch('/var/www/docs/s...', NULL, NULL, NULL, true)
#6 /v in /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php on line 174
I am using smarty template with zend framework and in that I create one more module like admin.In that module Controller is working and layout.tpl file is also working but problem is that when i add include file syntax in layout.tpl file that time same error is coming.
IndexController.php
<?php
class Admin_IndexController extends Models_UserCommonController
{
function init()
{
parent::init();
}
public function indexAction()
{
$this->view->assign('T_Body', '../index/index.tpl');
}
}
?>
layout.tpl
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>{$SITE_TITLE}</title>
</head>
<body>
<p>Hello</p>
{include file="$T_Body"}
</body>
</html>
index.php
Admin
I done same thing in windows its working but in ubuntu its not working.
I set all permissions and check everything path and all.
Default module is working in ubuntu but admin module is not working
Not too sure about the Smarty implementation but you have to remember that PHPs working directory is your projects root path.
You'd probably want to assign it absolutely with this manner:
$this->view->assign('T_Body', __DIR__ . '/../index/index.tpl');
Remember though that this only holds true for Zend Framework 2! Your code suggests that you're not using the second version but rather ZF1. Otherwise you absolutely should move forward and use namespaces and follow the tutorial on how to build your Controllers.
Related
I am using laravel version 5.5.45 and trying to learn Blade for first time. I created a file views/layout/app.blade.php. And want to extend that app.blade.php file in views/contact.blade.php. I extended the master blade file using #yield.
Do I need to do any change in route folder?
views/layout/views/layout/app.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
#yield('content')
#yield('footer')
</body>
</html>
views/contact.blade.php
#extends('layouts.app')
#section('content')
<h1>Contact Pafg</h1>
#endsection
When I hit the URL localhost/cms/public/contact I see the error in title.
You need to add custom route in web.php which is located in routes directory.
At the end of file add following code to connect the defined route to your view.
Route::get('contact', function () {
return view('contact');
});
Finally you can access it via localhost/contact
First of all you need to put the request to get view on browser. Now assuming that your project name: cms lets assume you are calling cms/contacts ( this is a get request just to get simple blade view ). Now this will go to web.php in routes directory, where you need to handle that request e.g.
Route::get('contact', function() {
return view('contact');
})
here assuming your contact.blade.php is in your resources/views/contacts.blade.php path. if it is within any another nested directory need to add that directory name e.g. return view('directory_name/contact');.
You can perform same action using controller method in which case you need to specify controller and method name in route file and return blade in that method. e.g.
Route::get('contact', 'controller#methodName');
To return blade you need to use view('blade_name') helper of laravel and you don't have to call you request like cms/public/contact, simply use cms/contact url.
Hope this helps.
I am using gulp-file-include to build my html pages using some partials & templates. By using context variables, I can customize each meta headers. However, don't know how I could include a line only if a context variable exists, as the "##else" statement doesn't seem to exist.
My parent HTML looks like:
##include ('_header.html', {
"title":"my page",
"description": "description",
"canonical":"http://www.sourcefromquote.com" })
<body>
A wonderful Page
##include ('_footer.html")
</body></html>
I was thinking to use a _header.html close to something like that :
<html>
<head>
<title>##title</title>
<meta name="description" content="##description">
##if (canonical) { <link rel="canonical" href="##canonical" /> }
</head>
If the "canonical" variable is not set in the the parent HTML, it throws an error (canonical is not defined).
I guess I could include the full tag in a variable and forget about the ##if, but that would not be as clean as expected !
Any ideas ?
Thank you in advance.
In the head, you enter:
##if (context.canonical) {<link rel="canonical" href="##canonical" />}
In the file that includes the header you enter:
##include('_head.html', {
"canonical" : "https://www.website.com/canonical-link.html"
})
gotemplates
Hello!
I'm learning Go language now and trying to port some simple WEB code (Laravel 4).
Everything was well, until I tried to reproduce Blade templates into text templates.
I found that Go can load my CSS and JavaScript files only from the catalog with a name "bootstrap" only.
Here is my catalog tree which I tried to use:
start-catalog
bootstrap (link to bootstrap-3.3.1)
bootstrap-3.3.1
css
bootstrap.min.css
js
bootstrap.min.js
jquery
jquery (link to jquery-2.1.1.min.js)
jsquery-2.1.1.min.js
go_prg.go
Here are my templates:
base_js.tmpl
{{define "base_js"}}
{{template "login_1"}}
<script src = "/bootstrap/js/jquery"></script>
<script src = "/bootstrap/js/bootstrap.min.js"></script>
{{end}}
base_header.tmpl
{{define "base_header"}}
<head>
<title>PAGE TITLE</title>
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
</head>
{{end}}
If the catalog name differs from "bootstrap" Go language or Firefox can't load files from the templates above: bootstrap.min.css, bootstrap.min.js, jquery.
If I use not the link but the catalog name directly "bootstrap-3.3.1" than Go or Firefox can't load.
If all required files are moved under "bootstrap" I'm getting the results I expected (exactly the same as in Laravel 4).
To launch go language code the command go run go_prg.go was used.
Environment: Ubuntu 14.04, go-1.3.3, Firefox 31.
Who's wrong: Go language, Firefox or me?
Any help will be highly appreciated!
The problem described was caused by
http.Handle("/bootstrap/", http.StripPrefix("/bootstrap/", http.FileServer(http.Dir("bootstrap"))))
before any template was handled. It allowed access files under the directory 'bootstrap' only.
The problem was fixed by changing to
http.Handle( , http.StripPrefix(, http.FileServer(http.Dir("."))))
and adding to pathes for CSS and JavaScript files. Like so
/bootstrap/js/jquery">.
I have to make a Web Application for downloading files from a folder.I use Tomcat as a server.I wrote a JSP page for listing the content of my data folder,and I tried to make links for each file from this folder.
The JSP page is this:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="java.io.File,java.io.IOException,java.util.*,java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Contents <br>
<% File f = new File("C:\\Users\\name\\Desktop\\eclipse\\app\\PTW\\WebContent\\data\\"); // current directory
File[] files = f.listFiles();
for (File file : files) {
if (file.isDirectory()) {
//System.out.print("directory:");
} else {
%>
<a href="<%=file.getAbsolutePath()%>" target="_blank"><br> <%=file.getName() %>
</a>
<%
}
}
%>
</body>
</html>
The problem is that downloading these files is working only in I.E. and only if user selects Right CLick - Save target As.
So my way to do this is wrong!But I don't understand why?How to force downloading files from this JSP?
Thank You!
You must know that the path to the file on the file system is a different path than the URL. The file system is only known by your server, the URL is the path which is accessed by browsers.
Let's say your file is in /opt/tomcat/webapps/myApp/folder/file.jpg and you are running your Tomcat on www.example.com. If you generate (through JSP) a link like
Download File
Your browser will see this path as:
www.example.com/opt/tomcat/webapps/myApp/folder/file.jpg
Your browser will not find the file. The URL the browser would neet to find it is:
www.example.com/myApp/folder/file.jpg
Which consists of
the domain www.example.com
the servlet context myApp
the path inside the application to the file folder/file.jpg
So you need to build the path /myApp/folder/file.jpg in your JSP. You can do it this way:
Download
I use Expression Language here instead of scriptlets. This is considered better style as it improves maintaineance and readability.
Note: This will only work if your File is inside the webapplication directory (myApp). If it is outside, you will need a servlet to stream your files to the client, but that is an other story.
I'm trying to run a very simple app to the new WSO2 AppServer (version 5.0.0) but there seems to be something very odd going on. When I try to access a page that does a simple JNDI lookup, I get the following error:
HTTP Status 500 - org.apache.jasper.JasperException: Unable to compile class for JSP Generated servlet error:
Only a type can be imported. javax.naming.InitialContext resolves to a package
An error occurred at line: 11 in the jsp file: /jndi.jsp
Generated servlet error: InitialContext cannot be resolved to a type
An error occurred at line: 11 in the jsp file: /jndi.jsp Generated servlet error:
InitialContext cannot be resolved to a type
The page contains just the following code:
<!DOCTYPE html>
<%#page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%#page import="javax.naming.InitialContext" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JNDI Test</title>
</head>
<body>
<h1>JNDI Test</h1>
<%
InitialContext ctx = new InitialContext();
%>
<p>Context: <%= ctx.getNameInNamespace() %>
</body>
</html>
It seems that the tomcat compiler is unable to "see" the java runtime classes, but I can't figure out why.
Any help would be appreciated.
Add the jndi look up code to a seperate java class and invoke it from your jsp page.