i´m developing a theme and for some reason i need to move the default position for breadcrubms (also for many other things) over woocommerce themes. Then i realised to do something like this on my functions.php:
function woocommerce_remove_breadcrumb(){
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
}
add_action('woocommerce_before_main_content', 'woocommerce_remove_breadcrumb');
function woocommerce_custom_breadcrumb(){
woocommerce_breadcrumb();
}
add_action( 'woo_custom_breadcrumb', 'woocommerce_custom_breadcrumb' );
And then on any template file, output the breadcrumb just with:
<? do_action('woo_custom_breadcrumb'); ?>
And works. My question is more than that. Is this the correct approach for something like this? I mean for anything over woocommerce, not just breadcrumb, for any pice, ratings, titles, buttons, sidebar, and so on.
What i´m thinking on is why woocommerce templates don´t come with more deep code. I mean, why there´s no such a single-content-loop.php template where you can just change the order of things, title, category, content, images, etc. in an easy way rather that hooking into functions?
I think that is an acceptable way to call the breadcrumbs explicitly. Sometimes it is easier to call a specific function than remove everything around it!
As for changing the order of things and getting into advanced customization; there isn't a single file, but a number of files working together. Create a folder in your themes root called 'woocommerce' and copy the following files for a safe override:
woocommerce/woocommerce-hooks.php:
Here are your hooks, including the ones you are overriding in your themes functions.php. Here is where you can experiment with removing and repositioning certain elements on your product page. Search for 'Sidebar' and you will see where the 'woocommerce_sidebar' action is added with the function it references in...
woocommerce/woocommerce-template.php:
Here are the functions used in template files to output content based on conditional statements. For instance, search for the 'Single Product' series and you can see which template files are used for which functions. For instance 'woocommerce_template_single_title' uses 'single-product/title.php' - if you copy over this folder and file you can make very specific edits to just the title section
Between these two files and their accompanying references (like title.php) I believe you can do the things you described. Let me know how it works out! I'm new to woocommerce too!
Related
This page: /my-account/view-order/132616/
... is associated with the view-order.php template file under the my account section. I am able to edit this by going directly into the woocommerce plugin dir, but copying the file into /my-child-theme/woocommerce/myaccount/view-order.php does not have any effect. I am able to edit the orders.php template in this manner, but not this one. I haven't been able to find any answers online to this one: why some of these template files can be copied / overwritten and some cannot be? Also, there appears to be limited scope on applying a hook to manipulate the content on this page. What I want to do, is turn the product names listed here into links back to the products in the store. Thanks for any help!
turns out this doesn't satisfy my need since the content I'm trying to manipulate is in the woocommerce_view_order do_action. Now I'm on the hunt for a filter hook.
Hello everyone and thank you for taking time to read this.
I've been using Phalcon for quite a while for a high performance JSON/XML API.
The backend managing this application was/is still driven by an oudated version of symfony, but it is gonna be dropped in favour for Phalcon and the Volt Template engine.
Now my problem is the following:
Imagine a base application and a basic template and the application is modularized. Most modules are gonna be developed by different teams but they all have to integrate niceley, which from the program logic side is not a problem.
But imagine the following:
You have a simple page, some forms, head, navigation, etc, etc.
Now someone wants to add a module which injects a template block into the footer for whatever purpose. For example adding a TagCloud (for SEO purposes) into the footer.
The idea here is, that the plugin has way to edit any template files other than the ones it brings itself.
How can this be achieved without having to change the base templates after the initial development?
The idea is basically to hook into a event, lets call it TEMPLATE_RENDER for simplicity.
TEMPLATE_RENDER is fired, every listener that is registered for it now has its chance to add stuff to the template like additional blocks etc. All without having to manually change the core templates.
It would be sufficient if there is a way to simply add a bunch of template files together in Volt and output the compiled result.
EDIT:
Okay, after some thought what I'm looking for in Volt is this:
Compiler#compileMultipleFiles(String... files);
So it can be used like this:
$compiler->compileMultipleFiles('/path/to/template1','/path/to/template2', ...);
Which would do nothing else "in theory" than take everything in file1, file2, ..., fileN and put it into one large file and then compile that as a single template. If it is not yet possible I could emulate that function by simple having each files contents combined into a single file or cache variable and use compileString() but that would break any relative paths in the template, which would be a problem.
I could also compile each template down manually, but than I would end up with an pure html document without the ability to append to blocks in the main template.
Apparently there is no such function directly.
You can however use an array and iterate over this area at the end of the primary template and dynamically include any file passed into there.
I believe that you're looking for a Volt include. You can leave some tests in your templates like:
{% if foo.enabled %}
{% include "foo/bar.volt" %}
{% endif %}
If you need something more complex than this you can use template inheritance also.
... ok ... so ... i just needed to "clear cache" after all that. i thought because i don't have caching on (site is in development) i wouldn't need to clear it. wrong.
the solution was:
add the file node--my-content-type.tpl.php and go to Administration » Configuration » Development then click the clear cache button.
i hope this helps someone not spend hours on end solving this same problem!
Using Drupal 7.2, I have created a custom content type 'my_custom_type and I can't for the life of me figure out how to create a custom template for my custom type. My template file at the moment just prints "hello world", but no luck displaying it. I've tried these combos of things:
putting node--my-custom-type.tpl.php in the my theme's templates directory. That didn't work. So I, after researching, added this to my THEME_preprocess_page() function in templates.php:
if (isset($variables['node'])) {
$variables['template_files'][] = 'node--'.
str_replace('_',
'-',
$variables['node']->type);
}
putting that same code in THEME_preprocess_node() without the if, so:
$variables['template_files'][] = 'node--'.
str_replace('_',
'-',
$variables['node']->type);
both of the above but with my tpl.php file in the base template directory: /modules/node/
Any help would be tremendously appreciated. I'm at a complete loss.
Also, I added print "what the what" in /modules/node/node.tpl.php and it printed.. maybe this is because the content-type isn't a node? but then how to create a default template for a content type?
It's not advisable to modify core files. See http://drupal.org/best-practices/do-not-hack-core. I'm not sure if this is what you're doing, but if you are...
What you should do instead is create a subtheme. See guides at http://drupal.org/node/225125 and http://drupal.org/node/171194
Usually you would put your custom theme files in /sites/all/themes/custom/subtheme_name/ node--my-custom-type.tpl.php.
Remember to clear your cache at http://yoursite.com/admin/config/development/performance so that your new template files are recognized.
If you want to avoid having to clear your cache all the time, you can install http://drupal.org/project/devel and choose to rebuild the theme registry on every request.
Be sure to turn it off before your site goes live, as leaving it enabled incurs a huge performance it.
In MATLAB, when you click File -> New -> Function M-File, you get a file with the following contents:
function [ output_args ] = Untitled( input_args )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
end
Is it possible to override this behaviour, and specify your own text?
(The motivation is that I'm trying to persuade my colleagues to document their m-files more thoroughly, and having default text for them to fill in might encourage them.)
I didn't even know File->New->Function did that.
The way I solved the issue was to write a function that you call via
>>newFunction myNewFunctionName
It then
pops up an inputdlg window, which asks the user for the synopsis and the H1 line and allows to already write help to explain input and output arguments. There, the user also selects whether myNewFunctionName is a function or a class in order to choose the right header and 'function call'
checks whether a function of the same name exists already
asks for a folder to save the function, and
opens the function in the editor
The header is set up so that it's easy to fill in info about input and output. It also automatically lists the username of the person who created the file as well as the date and the Matlab version.
EDIT
For new classes, the template function automatically makes sure that they subclass my general superclass that implements methods such as 'help' (which calls doc(class(obj)) )
Now if the template functionwould also write the algorithm part of the function, it would be really convenient. :)
EDIT2
Here's a link to the function on the file exchange.
I would suggest making your own default m-file template, called default.m for example, and placing it in a folder on the MATLAB path where your colleagues can access it. You should then set the file to be read-only. Your colleagues can then execute any one of the following commands in the MATLAB Command Window when they want to create a new function m-file:
open default.m
open('default.m')
edit default.m
edit('default.m')
The functions OPEN and EDIT will open a file in the MATLAB Editor. Since the file default.m is read-only, if anyone tries to save over it they will get a dialog box warning them as such and asking them to save to a new file (or overwrite it). That should keep them from accidentally modifying the template.
I searched through all text files starting from matlabroot folder, but could not find that template. Seems it's hard-coded, which is weird.
I like Jonas approach. As my two cents, you can download a function (not mine) doing similar things with some customization from here.
After more pondering, I've come up with a solution that I'm happy with, combining Jonas' and gnovice's answers. It's a function that creates a new m-file (with template documentation), and opens it in the editor. It is available from the Matlab Central File Exchange.
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.