Custom css added to page.xml in Magento is not loading - css

I have a custom css.I have placed it in the theme that we are using - skin\frontend\my-theme\default\css\custom.css
Now I have called this file in page.xml - app/design/frontend/my-theme/default/layout/page.xml
Syntax:
<layout version="0.1.0">
<default translate="label" module="page">
<block type="page/html_head" name="head" as="head">
<action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
</block>
</default>
</layout>
When I check view source, I don't see my custom.css.
Can you tell me what is wrong and how I get get to work custom.css?

You should try :
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="head">
<!-- /skin/frontend/yourpackage/yourtheme/css/custom.css -->
<action method="addItem"><type>skin_css</type><name>css/custom.css</name><params/></action>
</reference>
</default>
</layout>
Or :
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="head">
<!-- /skin/frontend/yourpackage/yourtheme/css/custom.css -->
<action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
</reference>
</default>
</layout>
When you want to insert something in an existing bloc, you have to use "reference" tag. Put the block name in the "name" attribute.
You can now add everything you want to your existing block (like childs, css, templates...).

Related

After added new custom column in magento 2 filter not working for date sorting

I have added new column in sales order for coupon code. after added this column sorting working fine but when i am filtering for last day order it is showing something went wrong.
the ajax issue is in 'mui/index/render'
app\code\Vicomage\CustomCoupon\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
app\code\Vicomage\CustomCoupon\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vicomage_CustomCoupon" setup_version="2.0.0">
</module>
</config>
app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php
<?php
namespace Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid;
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
class Collection extends OriginalCollection{
protected function _renderFiltersBefore()
{
$joinTable = $this->getTable('sales_order');
$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['coupon_code']);
parent::_renderFiltersBefore();
}
}
app\code\Vicomage\CustomCoupon\view\adminhtml\ui_component\sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="coupon_code">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Coupon Code</item>
</item>
</argument>
</column>
</columns>
</listing>
add below lines of code before parent::_renderFiltersBefore() in your file app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php
$this->getSelect()->group('main_table.entity_id');
$this->getSelect()->group('main_table.store_id');
let me know if you still facing same issue.

Web.config transformation locator condition or xpath not working with multiple attributes

I'm using Microsoft's XDT library to transform my web.config files and discovered that Locator is not working as expected. Using the example below, I would expect that both the attributes are set and the converter node is inserted in all three appenders, but only the attributes are updated in all three. The converter node is only inserted into the first appender. How do I get it to insert into all three log4net appender nodes?
I've tried switching to XPath, but it only throws errors. A working example would be nice, because every example I've followed so far seems to fail with an error.
Test site: https://webconfigtransformationtester.apphb.com/
For example:
Web.config
<?xml version="1.0"?>
<configuration>
<log4net>
<appender name="App1">
<layout>
<conversionPattern value="foo"/>
</layout>
</appender>
<appender name="App2">
<layout>
<conversionPattern value="foo"/>
</layout>
</appender>
<appender name="App3">
<layout>
<conversionPattern value="foo"/>
</layout>
</appender>
</log4net>
</configuration>
Web.Debug.config
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<log4net>
<appender xdt:Locator="Condition(#name='App1' or #name='App2' or #name='App3')">
<layout>
<conversionPattern value="bar" xdt:Transform="SetAttributes" />
<converter xdt:Transform="Insert">
<name value="Default" />
<type value="Common.DefaultConverter, Common" />
</converter>
</layout>
</appender>
</log4net>
</configuration>
Results:
<?xml version="1.0"?>
<configuration>
<log4net>
<appender name="App1">
<layout>
<conversionPattern value="bar" />
<converter><name value="Default" /><type value="Common.DefaultConverter, Common" /></converter></layout>
</appender>
<appender name="App2">
<layout>
<conversionPattern value="bar" />
</layout>
</appender>
<appender name="App3">
<layout>
<conversionPattern value="bar" />
</layout>
</appender>
</log4net>
</configuration>
It turns out that it was designed this way. Only attributes are applied to all target nodes. To work around the issue, download the code from here and add the following lines:
In XmlElementContext, add the property:
internal bool HasLocator
{
get
{
return this.LocatorAttribute != null || (this.parentContext != null && this.parentContext.HasLocator);
}
}
In XmlTransform modify this line, adding the call to HasLocator:
if (ApplyTransformToAllTargetNodes || context.HasLocator) {
This code will determine if a "Locator" has been set within the current context or any parent context (like in my example) and apply all transforms to all target nodes.

Magento Add External CSS in local.xml

I have the following file
url/var/www/html/app/design/frontend/default/default/template/productslider/widget/slider.phtml
That should use the css located in
url/var/www/html/skin/frontend/boilerplate/default/productslider/css/less-compiled.css
url/var/www/html/skin/frontend/boilerplate/default/productslider/css/sass-compiled.css
There is a way to add my external .css through local.xml ?
I tried with
<reference name="head">
<action method="addLinkRel">
<rel>stylesheet</rel>
<href>http://cerrajerianecochea.com.ar//var/www/html/app/design/frontend/default/default/template/productslider/widget/css/sass-compiled.css</href>
</action>
</reference>
<reference name="head">
<action method="addLinkRel2">
<rel>stylesheet</rel>
<href>http://cerrajerianecochea.com.ar//var/www/html/app/design/frontend/default/default/template/productslider/widget/css/less-compiled.css</href>
</action>
</reference>
Solved
<link rel="stylesheet" href="<?php echo $this->getSkinUrl(); ?>css/yourCssfile.css" type="text/css" />
Try adding them as text in the head section instead, like this;
<reference name="head">
<block type="core/text" name="uniquename">
<action method="setText"><text><![CDATA[<link href="http://cerrajerianecochea.com.ar//var/www/html/app/design/frontend/default/default/template/productslider/widget/css/sass-compiled.css" rel="stylesheet" type="text/css"/>]]></text></action>
</block>
If these will load on a secure and non secure page, ommit the http: from the link

How to replace attributes in XML transforms without the name attribute

I am using SlowCheetah to transform my Log4Net files when I publish. However, it can't seem to distinguish between the attributes in different appender sections.
My Log4Net.config looks basically like this:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="DevEmail" />
<from value="DevEmail" />
<subject value="Dev Warning" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="Time: %date%newlineHost: %property{log4net:HostName}%newlineClass: %logger%newlineUser: %property{user}%newlineMessage: %message%newline%newline%newline" />
</layout>
<threshold value="WARN" />
</appender>
<appender name="FatalSmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="DevEmail" />
<from value="DevEmail" />
<subject value="Dev Fatal" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="Time: %date%newlineHost: %property{log4net:HostName}%newlineClass: %logger%newlineUser: %property{user}%newlineMessage: %message%newline%newline%newline" />
</layout>
<threshold value="FATAL" />
</appender>
</log4net>
And my transform file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="ProductionEmail" xdt:Transform="SetAttributes" />
<from value="ProductionEmail" xdt:Transform="SetAttributes" />
<subject value="Production Warning" xdt:Transform="SetAttributes" />
</appender>
<appender name="FatalSmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="ProductionEmail" xdt:Transform="SetAttributes" />
<from value="ProductionEmail" xdt:Transform="SetAttributes" />
<subject value="Production Fatal" xdt:Transform="SetAttributes" />
</appender>
</log4net>
The problem is that the transformed config has the same subject attribute value for both appenders; I guess when it hits the SetAttributes it can't tell which tag it's looking for, so it transforms all of them. What it the correct syntax to tell it to only find the elements within the same appender? I assume I need to use the xdt:Locator attribute, but I can't do Match(name) like I do for web.config because these elements don't have a name attribute. The appender element has a name attribute, but I don't know how to tell it to match based on the parent element's name.
I know that I could use replace on the appender node, with the match(Name), but then I would be replacing the entire node, including a bunch of elements such as the layout which I don't want to be transformed (and thus have multiple copy-pastes of the same code, which I would like to avoid).
I found the answer in this MSDN article: http://msdn.microsoft.com/en-us/library/dd465326.aspx.
I needed to use xdt:Locator="Match(name)" on the parent <appender> node, and then xdt:Transform on the child nodes. I had tried this previously but had used xdt:locator="Match(name)" instead of xdt:Locator="Match(name)"... The attribute is case sensitive.

Best way to insert a css reference for a single page in Magento

Have had no luck trying to add a reference to a custom.css file to the customer dashboard page in Magento. It makes me want to shoot Magento in the eye, Navy SEAL style.
According to the docs, either of the following inserted into customer.xml in should work:
<reference name="customer_account_dashboard">
<action method="addCss"><link>dashboardfix.css</link></action>
</reference>
<reference name="customer_account_dashboard">
<action method="addCss"><stylesheet>css/dashboardfix.css</stylesheet></action>
</reference>
When inserted before this block:
<reference name="my.account.wrapper">
<block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
<block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
<block type="core/template" name="customer_account_dashboard_top" as="top" />
<block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
<block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
<block type="clientname/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
</block>
</reference>
It fails silently (no errors, its as if it wasn't processed at all)
When inserted after the block, I get an "Invalid method Mage_Customer_Block_Account_Dashboard::addCss(Array ( [0] => css/dashboardfix.css )) error
dashboardfix.css is in the skinname/css folder with my other assets.
Any ideas?
There was a minor syntax error in your code - see corrected code below.
Also, for this to work you need macguffin.css file to be placed in the same css folder as your styles.css (or boxes.css), i.e. the css folder of your theme.
You may also want to turn off caching and merging of css files to make sure this is working correctly.
Here is how you should have the complete block:
<!--
Customer account pages, rendered for all tabs in dashboard
-->
<customer_account translate="label">
<label>Customer My Account (All Pages)</label>
<!-- Mage_Customer -->
<reference name="head">
<action method="addCss"><stylesheet>css/macguffin.css</stylesheet></action>
</reference>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="content">
<block type="page/html_wrapper" name="my.account.wrapper" translate="label">
<label>My Account Wrapper</label>
<action method="setElementClass"><value>my-account</value></action>
</block>
</reference>
<reference name="left">
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
<action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
</block>
<remove name="tags_popular"/>
</reference>
</customer_account>
Just remember, so long as your css file is called macguffin.css it will all work out just fine.

Resources