Magento - Inject custom module on product info page - templates

I've searched on web for how to add "block" with my template on the product page. I build my custom module that displays some sort of information and I would like to show that, let's say under the long description of my product.
I've been trying to format the xml layout of my module but without luck.
After some search I've found this: Programatically create Magento blocks and inject them into layout which I can not make it work for me. But it is probably because I've missed something.
My module is structured like this:
CODE: app/code/local/deveti/Countrypurchase
DESIGN: app/design/frontend/default/default/template/Countrypurchase/index.phtml
LAYOUT: app/design/frontend/default/default/layout/countrypurchase.xml
I know the correct way is to edit main layout file, manually add a block, but I'd like to do that on the fly.
EDIT: this works!
So I would do in my module layout xml countrypurchase.xml something like this:
<?xml version="1.0"?>
<layout version="1.0">
<catalog_product_view>
<reference name="product.info">
<block type="core/template" name="product.countrypurchase" as="countrypurchase" template="countrypurchase/index.phtml" />
</reference>
</catalog_product_view>
</layout>
And I've added a call to catalog/product/view.phtml:
<?php echo $this->getChildHtml('countrypurchase'); ?>
And it works ;)
Thank you for your help!

The problem with the product view page is that it's output is mainly controlled by the PHP code in the template catalog/product/view.phtml. Magento doesn't offer much extensibility points out of the box. You could add it to the content block but that would put your custom content either completely at the top or completely at the bottom.
I think you are required to modify the template and add PHP code to render your custom block at the position you want, like:
<?php
echo $this->getChildHtml('product.countrypurchase');
?>
With this in place you can either add your block with the name product.countrypurchase via the XML layout or programmatically.

Related

how do you pass arguments to fragment called from NavigationDrawer using NavigationUI?

I've converted my app to use NavigationUI. But setupWithNavController() replaces my setNavigationItemSelectedListener().
In my listener I was passing a (type safe) argument to the fragment.
If I understand your question correct what you are looking for is:
Navigation parameters documentation
Briefly:
In your navigation graph, on the fragment you want the value sent to, you will add an argument.
<fragment android:id="#+id/myFragment" >
<argument
android:name="amount"
app:argType="integer"
android:defaultValue="0" />
</fragment>
When you then reference that fragment as an action, the library will generate a Directories class, which will look something like this:
val action = SpecifyAmountFragmentDirections.confirmationAction(amount)
v.findNavController().navigate(action)
The names are generated based upon what you named the Fragment and actions.
Also note that it is possible to send whole objects if they are Parcelable as well.
If the Fragment in question is the startDestination of your graph I am not sure if you can do it right away. A work around might be to load the data in the Fragment? Or maybe into a shared ViewModel from the Activity?
Good luck!
If anyone is still looking for an answer to this question. I've found a usefull workaround with the NavigationUI Global actions (working with alpha-09)
You can provide a top level action to your navigation graph:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_nav"
app:startDestination="#id/mainFragment">
...
<action android:id="#+id/action_global_mainFragment"
app:destination="#id/mainFragment"/>
</navigation>
And use it with your navigation controller to navigate with the correct bundle when a user click on a menu item. Be carefull to remove .setupWithNavController(navController) call from your NavigationView, or it will override your behavior.

TYPO3 Flexform: Enable show/hide for array elements?

I have created a custom content element in TYPO3 6.2 LTS using FlexForms. The backend user can add tiles with an image, text etc. In the form this is realized in an array. TYPO3 already provided automatically two items for "delete" and "sort/move" for each element (I wish I could add an image but my SO reputation is too low). Is there an easy way to also add the little lamp for "show/hide" in this case?
My Flexform looks like this (abbreviated):
<type>array</type>
<el>
<title>
<TCEforms>
<label>Headline</label>
<config>
<type>input</type>
<size>10</size>
</config>
</TCEforms>
</title>
<description>
<TCEforms>
<label>Description</label>
<config>
<type>input</type>
<size>30</size>
</config>
</TCEforms>
</description>
...
</el>
for me, it is no possible.
Your can see here this feature request and the reject from the typo3 team : feature request
As recommended, add a hide check box in your slide element

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.

Magento - catalog.xml not using correct template

Noob developing a Magento theme and I can't seem to figure out why Magento is not using the path I specify in the setTemplate action on catalog.xml.
I've got my own theme in /app/design/frontend/default/mycustomtheme and I've been patching files over from the base and making changes.
I've copied over /app/design/frontend/base/default/layout/catalog.xml to my custom theme at /app/design/frontend/default/mycustomtheme/layout/catalog.xml. I've set the template to be a specific phtml file...
<catalog_product_view translate="label">
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<reference name="root">
<action method="setTemplate"><template>page/2column.phtml</template></action>
</reference>
Yet it's not working. Can someone spot what the problem might be? I've got all cache disabled and other changes I make I can see immediately, just not this one.
edit: I should note, if I change something else in the catalog_product_view xml node I see those changes are reflected. For instance if I remove <action method="addJs"><script>varien/product.js</script></action> then I see the reference is removed in the rendered html file.
edit2: Adding images to address questions ...
did you setup-up / configured the theme from your store backend?
Yes, and it's actually loading the correct header and footer, and it's properly styled.
Are you sure you have such template under /app/design/frontend/default/mycustomtheme/template/page/ directory?
Yes, I can confirm the file is there
OMG. The (one and only) product I was testing on had a specific layout set under the "Design" section. So I guess that was overriding anything I had set in catalog.xml
I'd like to have the 3 hours of my life back.

How should I go about writing a Joomla! template?

I am using Joomla! CMS to develop a website. In the not-so-distant past I customized a template to schlep up a website. It was fun and interesting to tear apart the code to de-joomla!-fy the template. So interesting that in fact, I am flirting with the idea of making my own template from scratch.
So, if I am to pursue this, where do I start? Do you know of any really good reference material, or should I just play with the code all day until things work out? I prefer to do tons of reading (for the concepts) before I go at it.
Create a HTML page with the layout you want, inclusive of stylesheets and Javascript
(1.5/2.5 is Mootools based)
(Joomla 3.x is jQuery based)
Adding Javascript
Keep the template initially very basic.
Save this page as index.php page.
The default directory layout is:
css
html
com_<componentname>/ mod_<modulename> (used to override the base templates of Components and Modules)
images
js
templateDetails.xml
index.php
favicon.ico
Change/Add the different Joomla constructs
Also updating the related templateDetails.xml with positions and file locations etc.
See a current template for an example of the layout.
Ex.
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
Header section:
<jdoc:include type="head" />
Your different Modules:
<?php if($this->countModules('search')) : ?>
<jdoc:include type="modules" name="search" />
<?php endif; ?>
<jdoc:include type="module" name="breadcrumbs" />
Your Main Content tag is:
<jdoc:include type="component" />
To allow your template the ability to display debug information add:
<jdoc:include type="modules" name="debug" />
For more advanced additions to a template have a look at the default templates (ja_purity, Beez).
To override component and module layouts copy the layout files of the component or module into a similarly named directory below the html directory of your template and change it.
Edit...
Extra utilities.
To highlight the used module names in a browser add tp=1 to the end of your URL ex. yourdomain.com?tp=1
To View an inactive but installed Template add template=template_name. ex. yourdomain.com?template=Beez
These two can be combined, like this. yourdomain.com?template=Beez&tp=1
For more information look at:
Joomla Template Tutorial Part 1 - Joomla Template Concepts
How to Create Your First Joomla Template
Joomla! Docs: Template Development
Google Joomla templates
The time-honored method of learning how to do code/templates/anything is to "steal" from someone who already knows how to do it and then modify that until:
you're happy with the outcome; and/or
you've learned enough to be able to go it alone.
I suggest that would be the quickest route to success. Theory is fine but you'll learn faster by doing, and making mistakes.