Magento code for $this->getChildHtml('topContainer'); - templates

I am coding a magento theme. I have enabled path hints but in
the header the call to $this->getChildHtml('topContainer');
does not reveal any path hints. How can I find out which
.phtml file is loaded when the above call is made, so
that I can create the appropriately named and located
.phtml custom file?

topContainer is a "page/html_wrapper" block.
It means there is no template file associated with it.
The role of this block is to render all it's children blocks inside an html element.
Take a look at the _toHtml() method in 'app/code/core/Mage/Page/Html/Wrapper.php'.
Sincerely,
Jonathan
--- More explanations:
You can take a look at a perfect exemple in:
layout/customer.xml (in base theme)
layout/sales.xml (in base theme)
You have a similar block:
<block type="page/html_wrapper" name="my.account.wrapper" translate="label">
It's the area where all other blocks of customer account will be rendered.
In order to put the blocks in this area, you have to create a "reference" node with attribute "name" set to the name of the "wrapper".
For exemple if you look (inside sales.xml) to the "sales_order_view" handle, you'll see <reference name="my.account.wrapper"> and inside this node, other blocks.
These other blocks are classics blocks (core/template) and they have templates files.
So you can compare a 'page/html_wrapper' block to a 'core/text_list' block.
The only difference is the first one will wrap the rendered child block into an html element.
Take a look to the 2 files mentionned above, they will help you a lot.

Related

Drupal 8 Webform: how to display text input on one page on the next page?

I am trying to develop a multistep webform in Drupal 8 using Webform 8.x-5.1. I have written a WebformHandler that extends Drupal\webform\Plugin\WebformHandlerBase and made it available to the webform.
In the first step of the webform, I collect a text-field. I would like to display the value of that text-field in an HTML element (Advanced HTML/Text or Basic HTML) on the second page after doing some computation.
I have overwritten submitForm() in the WebformHandler and in it assign the value I want to the HTML element as follows:
$form['elements']['page_name']
['advanced_html_element']['#text'] = '...my HTML...';
Using ksm() I can see that this assignment works, but the the HTML element is not rendered with my HTML: the element is either invisible or contains the initial value set up in the form editor.
Clearly I'm missing something. Should I be using something other than submitForm? Can anyone help me?
It's been a long haul, but I've finally worked out how to do what I want to. The following works for me.
Firstly, I discovered the method validateForm in WebformHandlerBase. On each page in a form with multiple pages, you will find that the following methods are called in the order given here:
submitForm (called once)
alterForm(called possibly more than once)
validateForm (called once)
The name validateForm leads me to believe I may be misusing this method, but that is where I set up the elements on the following page that I wish to programmatically initialise. It works, so what the hey!
In validateForm, I initialise the elements that appear on the following page as follows:
$form_state->setValue(<element name>, <data structure>);
The <element name> is the name you give the element in the form editor ("Build" tab). The <data structure> has to be correct, of course: I suggest you find the appropriate structure by first filling in the element on the next page manually and seeing what turns up in $form_state.
There is also a $form_state->getValue(<element name>), which seems to me to mean that $form_state can also be used for storing session data, say in hidden fields. I initially used Drupal::service('tempstore.private')->get('xxx') for storing data that had to be available across page boundaries, but $form_state might be a cleaner solution.
I hope this helps someone: I spent a horribly long time trying to get this to work.

How to on one page sequence decide begining of a new node to insert different header

EDIT AFTER GETTING CORRECT RESULT:
Ok, I managed to do that. Basically when I understand what really #Kevin wants me to do, I created empty marker on the begining of topic (with keep-with-next), and after title of topic is created I changed it to normal header. Now everything is ok.
EDIT:
I tried #Kevin-Brown suggestion, but probably I did something wrong. I will show minimal version, to give an general image of that what happened.
I got:
flow
block with normal header marker
block with keep-with-next always, and empty marker which actually doesnt matter in my case
block with content
and header looks like:
<fo:block>
<fo:retrieve-marker retrieve-class-name="body-header-marker" retrieve-position="first-including-carryover" retrieve-boundary="page"/>
</fo:block>
Problem is that header is no really carryover. Because right now, even if I remove empty marker, I will have header on the page with the topic, and I won't have anything on next pages of topic. Then again I will have one again on the begining of the topic. What I did wrong?
OLD QUESTION:
I am working with Formatting Objects, and I have some problems with finding good (actually any) solution in same cases. Is there any way to check if currently processing node actually taking 2 pages?
Maybe if I try to define the problem, you can suggest some better solution. I have multiple topics in xml, and during processing of topic, I adding header and footer to every page. I want to change it, to not add header, on page where title of new topic is located (topic starts from new page). So maybe there is better way to do what I want, than checking pages. Because I think that because of different approach to "variables" in functional programming, I might be not able use page as I wanted.
The general principle you want in pseudo markup is this:
block-container for topic
throw marker containing the header for the topic
... content of topic ...
end block-container for topic
block-container with empty marker keep-with-next as "always"
throw marker with nothing in it (basically clear the marker)
end block-container with empty marker
block-container for topic
throw marker containing the header for the topic
... content of topic ...
end block-container for topic
... and so on ...
So you pull the marker first-including-carryover into your header. This means the first marker whose parent container starts at the top or carry's over from the last page.
If your page starts perfectly with the start of a topic, the first marker on the page will be the empty one. This is because you are gluing the empty marker block-container to the start of every topic. There is no content in this structure, it will not corrupt your output. I did not show above putting the empty marker container above the first topic, but do that also if you want.
If your page breaks inside a topic, then the "carryover" marker would be pulled which would have the header of the topic from the previous page pulled. Normally this marker would include something like "- Continued" at the end.
You could put every topic in a separate fo:page-sequence and use an fo:page-sequence-master (http://www.w3.org/TR/xsl11/#fo_page-sequence-master) to select a different fo:simple-page-master just for the first page. You could make it so that page-master has a different header.
See, e.g., 'Switching the layout in facing pages automatically (page-sequence-master)' in http://www.antennahouse.com/antenna1/comprehensive-xsl-fo-tutorials-and-samples-collection/, although you would probably want to select on page-position="first" rather than odd-or-even.

Magento - left.ptml not showing on all product list pages

left.phtml the file that displays the left navigation on a magento page is only showing on one list view page and not the others does anyone have a solution to get that file to show in all list views
If you are tasking left.phtml,
Then According magento structure left.phtml are only show for Non-Anchor category in it left side of category.
And layer navigation are only showing for Anchor category.for anchor left.phtml is not showing.
For non-Anchor categories
see catalog.xml code
<catalog_category_default translate="label">
<label>Catalog Category (Non-Anchor)</label>
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
Also for
Anchor categories
see at catalog.xml
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
Hope ,you will understand.
Check the layout in folder theme/package (it can be in default/default, when your theme is in another folder)
Check if layout is plugged (use in your layout.xml something like <remove name="header">). If header will be removed - you use correct layout
Check the handle and reference name, where you are adding block. For example: you are adding layered navigation block. On one page it placed in handle <catalog_category_layered>, but your page there no this handle. Try to add to <catalog_category_default> or even in <default>.
Open your template and check if the block was added there. Look for
<?php $this->getChildHtml('blockName'); ?>
Try to change your block name (maybe on this page already exist block with the same name)
(this option can be useless for you) Please check the block output in system / configuration / advanced
Maybe there is a conflict between two navigation modules (for example module A and module B). The module A can use it for rewrite. But the module B will use it only for investigation and use on this page it's own calls. In that case the module A will not work (to resolve this issue you need to change rewrite. class A should rewrite class B)
If you are trying to add navigation to CMS page - try to google this topic (how to add navigation to CMS page). There are many examples and I don't want to duplicate them.

woocommerce advanced templating

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!

Assign/call a page inside umbraco template

I have a page that has 3 sections... left top, left bottom and Right Column. It uses a masterpage from master template... how would I call three different page to fit in these three sections... For now I harcoded left-top section, but I should be able to edit all these three section from umbraco without having to change any code... basically I created three pages, so that I can insert them to respective sections, but I am not sure how to call them from the templates.
I tried this on all three sections... but it only allows me to edit one section
<umbraco:item id="Item1" runat="server" field="bodyText"></umbraco:item>
Is there a way, where I can call "mypage" using ?
I did this with a master macro which calls the razor scripts with a DynamicNode as param.
foreach(DynamicNode child in Model.GetChildrenAsList)
{
#RenderPage("script name here", new DynamicNode(child.id)) // this lets the next script us Model too
}
To get the script name I made a static class that compares the .NodeTypeAlias with a list of constants and returns the script path. This way when ever you change something in the tree it will call it differently on load.
You can add as many params as you want in order to play about with the css or structure for example.
Hope this helps.