I've inherited some code that doesn't work, where a button (with a custom function) exists in the admin page for particular dataobject, and triggers an email to be sent. The code is currently trying to populate the body of the email by using a template file, which is currently in the theme folder for the site.
However, the email body is blank, as the template is not being found. My understanding is that the admin section of the site doesn't look in the theme folder for templates. Where can I put the template (and the other templates it includes) where they can be found from code in the admin part of the site?
$email = new Email($sender_email, $recipient_email, "Your order has been shipped!");
$email->setTemplate("OrderShipped");
$email->populateTemplate(array("Order" => $order));
$email->send();
The error being output to the error log is this:
[17-Nov-2014 14:34:01] Warning at framework/view/SSViewer.php line 780: None
of these templates can be found in theme 'mytheme': OrderShipped.ss
(http://mytestsite.co.nz/admin/orders/MyOrder/EditForm/field/MyOrder)
As the theme is not set when in the backend of the CMS, templates should not be in the themes folder. You can try to move the file into mysite/templates/Email for the main email template. Any includes can be stored in mysite/templates/Includes.
as jfbarrois wrote, the theme is not set in CMS. So I used this small hack and it started to work:
Config::inst()->update('SSViewer', 'theme_enabled', true);
Config::inst()->update('SSViewer', 'theme', 'mysite');
// change 'mysite' with the name of your theme
and you can keep the template in "mysite/templates/Email".
Maybe there's also some other option how to do that, but I haven't found it yet.
Related
When i try to import the project template i got the error
Why it was happening, and how to solve it?
I export the template by checking Content and Files option
Please help someone who have encountered this before?
This isn't a project template, it is a Portal or Site template (possibly a page template), but not a Project.
That sure looks like the error is telling you that the TAB (page) already exists. Check the XML file that the template created to see if you have multiple TABS in there with the same name/path.
Are you perhaps creating a TAB with the same name as the "ALIAS"
Example, in the Parent site you have http://site/CHILDNAME and you are now trying to create a portal called http://site/CHILDNAME?
Question:
What do I need to do to have Django load a template from the filesystem, instead of loading from memory/cache?
Use case:
I am using render_to_string() to generate a template's HTML for use as an attachment to a EmailMultiAlternatives.
Problem:
I have made changes to the template, sent a subsequent email, yet the changes to the template are not reflected in the email. I have printed the render_to_string() prior to sending the email and it too is not updated, so the problem exists prior to the email part.
Details:
I am using the default settings.TEMPLATE_LOADERS (filesystem/app_directories) for Django 1.7, have tried clearing the cache and have restarted the default development server.
If I change the filename of the template, render_to_string() renders the "changes."
What is even stranger is I have completely removed the template file from the filesystem, yet render_to_string() still renders the original template.
This is a "new problem," as I have modified templates countless times and their changes have been reflected immediately.
Maybe you have that file somewhere else on your file system? Try checking your template file locations in settings.py and review your template files in your file system.
I am trying to create a custom gitbook theme and in that I also want to change the layout so that the book I create using the theme have the layout that I want. I copied the default templates dir in my assests dir of the custom theme and then modified the layout.html and header.html files as I wanted. Then to include the modified template files, I added the following attribute to the index.js file
module.exports = {
book: {
assets: "./assests",
templates: {
"layout":"templates/layout.html",
"header":"templates/includes/book/header.html",
},
......
......
However with this configuration, the generated book is not picking the template file changes. However I do see the css/js changes that I had done.
For the record, layout and header template files do exist if you're going the "unadvised" (emphasizing the unadvised nature of this) route of:
Add "theme": "./customtheme" to your book.json file.
Create your customtheme folder in the root with the files from the Gitbook repo
Edit from there
This is so far the only way I've found edit your favicon, sidebar, header, and layout files. It's not recommended because you're no longer using the files in the repo, so updates could break it, but some things either aren't easy or possible to make changes without doing something messy and hacky like this. Hopefully simple things like updating a favicon, header, or sidebar could be made to be easier in the future. I've only found this solution after many, many google searches and plugin comparisons, so maybe some one has a better solution that I haven't found yet.
Templates "layout" and "header" don't exist. You can only change:
site: template for the website
glossary: template for the glossary
langs: template for the choice of languages
page: template for the ebook
Changing templates is really not advised, you should use plugins to only extend html,css,js using: https://github.com/GitbookIO/plugin/blob/master/index.js#L2
I am currently working on a new website with TYPO3 and now I am facing a big problem with template/cache.
Environment:
Extension "Portfolio" adds a new content element with Extbase/Fluid-Template. The template contains only the sentence "Create custom template" because I don´t want to provide a default template.
Extension "Layout A" contains the main template for the website, as well as the template for "Portfolio".
Cases:
When I am logged in as admin always the correct template is used.
When I am logged out and make "Clear all cache" in install tool the first page I load afterwards gets the correct template. The second/third/... page uses the first and wrong template.
Settings:
"config.no_cache = 0" is disabled
TYPO3 6.2.2
RealURL enabled
I added a TypoScript Text-Object with the template path to my fluid template and printed it in fronted. Always the path of the correct, second template.
Does anybody have an idea what´s the problem?
Thanks in advance!
Best regards
Boris
Install Tool Clearcache will clear the extbase cahe, so maybe the tempalte paths might be lost.
You should set the path to the templates explicitly via:
plugin.portfolio.view {
layoutRootPath = {$path}
partialRootPath = {$path}
templateRootPath = {$path}
}
I'm trying to get an extension/plugin on a page to use a different template from the one its hardcoded with.
I made an html template stored in:
typo3conf/ext/myextension/pi1/new_extension_template.html
I made a typoscript template object in the root of my site (so it would definitely get picked up).
In it, I have defined the following simple Typoscript (names changed for demonstration)
plugin.tx_myextension_pi1 {
templateFile = typo3conf/ext/myextension/pi1/new_extension_template.html
}
However when I load the page containing the plugin, I get a "no typoscript template found" error on that black TYPO3 error page.
I have tried a bunch of alternative ways in case the syntax was wrong but the above worked for me when working with the tt_news plugin.
E.g I have tried these without success too:
templateFile.file = typo3conf/ext/myextension/pi1/new_extension_template.html
...
tempfile.template_file = typo3conf/ext/myextension/pi1/new_extension_template.html
Any ideas what I'm doing wrong?
Can html templates stored in typo3conf be called via typoscript stored outside the plugin?
I'm thinking perhaps html template files would have to be stored in fileadmin/plugin_templates/ for this to work.
You are mixing things: no typoscript template found means that on the page you inserted the plugin there is no TS template available.
Page with plugin isn't nested under the main page (which - as I assume - has main TS template and is displayed properly), so just drag it into the main page, or create new TS template on its level.