Joomla: Using the same override in two different templates - templates

I am working with Joomla 1.5 and using two different templates. To customise the frontend, I am overriding components and modules in /template/myTemplate/html/componentOrModule/. In a few cases I need the same overide in both templates.
Until now, I am using include to reuse the code. But it is still annoying, that I have to create the folders and files twice.
I reckon, that there is a better/easier way of doing it. But I do not have clue.
Did someone have the same problem and has already solved it? Any ideas appreciated.

There is no Joomla solution to this issue. My proposal would be to have a stub file in your template html folder and then include that file from a third folder. Something like the following:
/templates//html/com_content/article/default.php
You can copy that file into all the relevant override folders and then have one folder in the templates folder named "common" where you have the actual files with the output.

Related

(Django) How to include template file from app into base.html in templates

I am building a site in Django CMS. In my templates directory for the project is base.html.
I am writing an app "was_this_helpful" to add a dialog box on some pages for users to give feedback. I want to include a file from was_this_helpful/templates into base.html but it says the file does not exist.
{% include 'was_this_helpful/dialog.html' %}
My file structure look like this:
- was_this_helpful
- templates
- was_this_helpful
- dialog2.html
- dialog.html
- required app files
I read somewhere that sometimes template files need to be another level deeper in templates to be found which is why I made the dialog2.html but still it's not working. I do not understand how to accomplish this. Based on what I've read it should work. Is it different because I'm not in another app, just the templates directory?
Without knowing more it's hard to tell if it's a simple solution or not.
The way you have your code written, there is not a was_this_helpful/dialog.html - you only have a dialog2.html inside your was_this_helpful so was_this_helpful/dialog2.html would be the reference path.
I've always created another folder inside my templates folder with the name of the directory above my templates folder. Just like you have with your was_this_helpful second directory. I find that this makes it much easier to extend base.html files.
You can always do it absolutely too by two periods before the path call, so ../was_this_helpful/templates/dialog.html
If you don't have luck with that either, there is an {% extends %} method as well which might accomplish what you're trying to do as well.
Good luck!

not able to add custom template files in gitbook themes

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

How can I rename the template directory/folder - Joomla 1.5

I want to rename NOT inner folder(rhuk_milkyway оr others). But exactly folder "templates".
I think it one of the ways to protect site from regular virus attaks.
I changed:
1). folder name
2). paths in file index.php in that folder
What else must I do?
I don't think that renaming templates folder would do any good. You can still see path of template css, js and images in html source.
Lets say you rename your templates folder to secret_folder, but when viewing html source you will see /secret_folder/rhuk_milkyway/css/style.css instead of /templates/rhuk_milkyway/css/style.css.
If you're afraid of regular virus attacks - get right folder permissions, and it should do the trick.

Meteor: index.html is getting huge

In my meteor project I can separate the javascript files in the client and server directories. But I cannot find a solution for all the html templates I need to define.
The problem I have now is that I need to embed this svg image in a template too, which is a huge image. So now I have this html file which is now 2 times 'huge' :)
The reason I need to have this svg inline in my html/template is because I need to style it with css. Any suggestions ?
You can put the .html files anywhere! Besides the server directory, of course. The natural place to store them is the client folder, and a good practice is to keep each template in a separate file. The Javascript code related to that template (data helpers, events, callbacks) can then go to a file with the same name and with extension .js instead of .html. These are the basics if you want to keep your project tidy.

Magento - locate specific core files

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/
I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code
renderTotals(); ?>
Now I managed, by accident, to stumble upon two of the files I wanted to change:
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php
I made local copies of these files (http://www.magentocommerce.com/wiki/how_to/how_to_create_a_local_copy_of_app_code_core_mage) to override the default labels, like I would if I was overriding a template file.
My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?
Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.
Hope this makes sense and thanks in advance!
From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).
If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.
As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.
I always use Dreamweaver's site / directory search function. It will scan through all the files in the Core folder and tell you where the function is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.
Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the function to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.