Magento - catalog.xml not using correct template - templates

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.

Related

Changing default base URL of Sitecore ServiceApiController, Is it possible?

when we implement SitecoreApiController, for each action method we make using Sitecore.Services.Core.ServicesController("namespace") attribute, we get a url like this:
/sitecore/api/ssc/{namespace}/{controller}/{id}/{action}
I wonder if we could change this default pattern, somehow in config files. I particularly interested in /sitecore/api/ part, because sometimes in the sense of security concerns, certain clients don't like to reveal that much about CMS platform behind the scene. Sometimes they even ask us to hide anything in HTTP header that tells about Microsoft ASP.NET explicitly.
Is this possible here?
Edit
this link shows a way to customize it using pipelines but I wonder if we could change the base url just through config files without needing a custom pipeline
I had a look at it, and I think I found out how - although I haven't tested it.
It looks for a setting named Sitecore.Services.RouteBase and if it can't find it, it uses sitecore/api/ssc/ as the default value.
You should be able to change it with a config patch like this in the App_Config/Include folder:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Sitecore.Services.RouteBase" value="custom/api/" />
</settings>
</sitecore>
</configuration>

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.

How do I prevent sitecore from adding a ~ to an image path?

I have a clean install of Sitecore 6.5, DMS 2.0, and the E-Commerce Module and Sample Site (v1.2). When I have the sample site installed, most of the images appear to be broken. The HTML that is rendered includes img src attributes that contain a path that start with /~/. Example:
http://~/media/Images/Ecommerce/Examples/Products/Digital%20SLR/D200.ashx?w=250&as=1
Now, I'm assuming this is either because the sample site hasn't been updated in a while to stay current with Sitecore changes, or there is a configuration for media paths that get returned from it. Here's an example of the XSLT rendering used to write the image:
<img id="product_shot" class="fix" alt="{sc:fld('alt',.)}" title="{sc:fld('alt',.)}" src="/{sc:GetMediaUrl(.)}?w={$ImageWidth}&as=1" />
Does anyone know of a way to prevent the image url from being rendered with a ~ when using XSLT? Did I do something wrong with my initial setup and configuration?
John West gives a great breakdown here: http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/12/Sitecore-Idiosyncrasies-Media-URLs.aspx
The important info being a configuration of "Media.MediaLinkPrefix". You can create a patch file, or modify your Web.config to change it to something else. The places I've read have people changing it to a single dash "-/media"
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Media.RequestExtension">
<patch:attribute name="value"></patch:attribute>
</setting>
<setting name="Media.MediaLinkPrefix">
<patch:attribute name="value">-/media</patch:attribute>
</setting>
</settings>
<customHandlers>
<handler trigger="-/media/" handler="sitecore_media.ashx"/>
</customHandlers>
</sitecore>
</configuration>
Another solution which I can think of is to change your web.config like this:
InvalidItemNameChars: Add “~“
But this will work not only for images but for any content items out there in your Sitecore content tree.
This is more of a workaround than a solution. Since I'm setting this up for demo purposes, it'll do just fine.
In web.config, I changed the value of Media.MediaLinkPrefix to include the hostname and media prefix. Since the Sitecore E-Commerce Example Site XSLT renderings start all calls to sc:GetMediaUrl(.) with a / character and sc:GetMediaUrl(.) itself returns its first character as a /, this causes the src attribute value to be written with the full host name and then correctly resolves:
<img src="//sitecore.local/~/media/Images/Ecommerce/Examples/Products/Digital%20SLR/D200.jpg />
Far from ideal, but for these purposes, this workaround did the trick.

Magento - Inject custom module on product info page

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.

Magento - How can I move the Navigation Block to be in the right column?

I've been editing Magento's default CSS to change the look and have come to a point where I want to move around some content blocks.
I've killed off the left column through CSS
.col-left { display: none; }
And then increased the width of the main content part to create a 'two column layout'. What I want to do now is move the navigation for the categories into the right column. I just have no idea how...
How do I move content blocks around in Magento? :/
Making large moves like that in Magento is best accomplished by modifying the layout XML files, rather than hacking through CSS. In the file catalog.xml, here are the relevant lines:
<reference name="top.menu">
<block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>
</reference>
<reference name="left">
<!--<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
<action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>
<action method="setLinkUrl"><url>checkout/cart</url></action>
</block>-->
</reference>
<reference name="right">
<!--<block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>-->
<!--<block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"/>-->
</reference>
To render the topnav, move that catalog/navigation line into the left or right column blocks and the navigation will be rendered as such.
Hope that helps!
Thanks,
Joe
Magento has four "standard" layouts: 1col, 3col, 2col-left and 2col-right, but you can add more if you like. You'll want to change the layout used on the page your editing instead hacking around with CSS. That's definitely the wrong way to do it.
As Joseph points out, Magento's templating system is comprised of blocks, or templates, which are positioned by layout files. Templates are standard php, though are prefixed with .phtml, and layouts are xml. You'll find large groups of these files in app/design/frontend/$interface/$theme/(template|layout).
Magento is pretty renown for it's poor documentation, but you may want to checkout their Designer's Guide which covers the concept of templates and layouts in a little detail, including how to move blocks around.
The syntax of a layout file is far from straightforward but, pretty much, all you're going to need to know at this stage is that in order to reference blocks in the right hand, left hand and content columns look out for:
<reference name="(right|left|content)"></reference>
Moving the <block /> declarations from one to another with cause the blocks to move.
Another key one to remember is to look out for:
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
Using the setTemplate action when referencing the root container will allow you to switch templates to 1column, 2columns-left, 2columns-right or 3columns easily. The layout templates themselves can be found in template/page/.