Magento - How to override persistent billing.phtml using custom module - magento-1.8

Stuck on this for a long now :( I am trying to override a core template file
app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml
using custom module which I have successfully activated and the config file for my new module is located at
app/code/local/CustomCheckout/Checkout/etc/config.xml.
Below are the content
<config>
<modules>
<CustomCheckout_Checkout>
<version>1.0.0</version>
</CustomCheckout_Checkout>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<CustomCheckout_Checkout before="Mage_Checkout">CustomCheckout_Checkout</CustomCheckout_Checkout>
</modules>
</args>
</checkout>
</routers>
<layout>
<updates>
<checkout>
<file>persistent.xml</file>
</checkout>
</updates>
</layout>
</frontend>
</config>
I am trying to override the persistent.xml layout which in turn calls the said billing.phtml file. I placed the new layout file at following location
app/design/frontend/default/CustomCheckout/layout/persistent.xml.
Below are the content
<layout version="0.1.0">
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate">
<template>checkout/onepage/billing.phtml</template>
</action>
</reference>
</checkout_onepage_index>
</layout>
I have placed my modified billing.phtml file under
app/design/frontend/default/CustomCheckout/template/checkout/onepage/billing.phtml
but it is not being picked up. I am scratching my head...any help is appreciated.

Hopefully you've found an answer by now, but for posterity...
The issue here is that the "Persistent" module is already overriding that template. If you look in the persistent.xml layout file you see the following:
<reference name="checkout.onepage.billing">
<action method="setTemplate"><template>persistent/checkout/onepage/billing.phtml</template></action>
<block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml" />
<block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
</reference>
Magento's default loading order is alphabetical. So, since the Persistent module is "Mage_Persistent" and your module is "CustomCheckout_Checkout", the Persistent module is loaded last, and it's override is the one that sticks.
There are several solutions. One is to rename your module so that it's after Mage_Persistent in the alphabet.
A better solution is to use Magento's dependency functionality. In your module declaration file (app/etc/modules/CustomCheckout_Checkout.xml), you probably have something like this:
<?xml version="1.0"?>
<config>
<modules>
<CustomCheckout_Checkout>
<active>true</active>
<codePool>local</codePool>
</CustomCheckout_Checkout>
</modules>
</config>
Modify this as shown here:
<?xml version="1.0"?>
<config>
<modules>
<CustomCheckout_Checkout>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Persistent />
</depends>
</CustomCheckout_Checkout>
</modules>
</config>
This indicates to Magento that your module "depends" on Mage_Persistent and should therefore be loaded after it.
If that does not work for you, another technique would be to use a "remove" node in your layout xml to get rid of the original billing block:
<remove name="checkout.onepage.billing" />
Then re-add it with a different name, as it is in checkout.xml. Make sure to add all necessary blocks and actions underneath it from various layout files and use the same alias (as="billing").
Finally, if this module is not intended for re-use (the change is just for your current install) you could simply copy the phtml file into the same path in your custom package/theme folder.

I am magento developer. I did implement your problem at localhost & find solution. I just create kinex/links (namespace/module). In this module layout file contain the following code:
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate">
<template>kinex/links/billing.phtml</template>
</action>
</reference>
</checkout_onepage_index>

This is very Simple, You can simply write the xml as:
<checkout_onepage_index>
<reference name="checkout.onepage.billing">
<action method="setTemplate">
<template>your-module/checkout/onepage/billing.phtml</template>
</action>
<block type="persistent/form_remember" name="persistent.remember.me" template="persistent/remember_me.phtml" />
<block type="core/template" name="persistent.remember.me.tooltip" template="persistent/remember_me_tooltip.phtml" />
</reference>
</checkout_onepage_index>
If there is some error in checkout page, then it means billing or shipping.phtml file is missing.

Related

How to define custom web.config in .Net Core 2 for IIS publish?

VS will generate (and override) a web.config file as part of publishing to IIS. I have various items I need to include in the file (like extending the file upload max size limit, redirecting to HTTPS, etc.). I am currently having to copy and paste the contents into the file after every publish.
Is there a way to define the contents of the web.config file that Visual Studio generates when publishing a .NET Core 2 web app for IIS?
not sure if you solved this, but if anyone else runs across this problem, I had this issue and finally went looking for the source code for the transform task. it contains some logging, so I ran the dotnet publish with a /v:n parameter, which sets the logging verbosity to "normal":
dotnet publish src\MyProject -o ..\..\publish /v:n
when I ran this, I saw this in the output:
_TransformWebConfig:
No web.config found. Creating 'C:\Development\MyProject\publish\web.config'
even though there is a web.config in the project. I changed the properties of the web.config "Copy to Output Directory" to "Always", and now the web.config in my project gets merged with the auto-generated contents.
my csproj now has this in it:
<None Include="web.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
and the publish output has:
_TransformWebConfig:
Updating web.config at 'C:\Development\MyProject\publish\web.config'
NOTE: if you are publishing to an existing directory that already has web.config in it, it will update that file. (i.e., an old publish). if you don't specify an output directory, it will publish to something like /bin/Debug/net471/publish/, which may have old files in it.
NOTE2: you still need the Sdk="Microsoft.NET.Sdk.Web" attribute on the Project node in your csproj file, or it won't even bother looking for Web.configs.
for reference, here is the task source code:
https://github.com/aspnet/websdk/blob/master/src/Publish/Microsoft.NET.Sdk.Publish.Tasks/Tasks/TransformWebConfig.cs
I finally got back to this and wound up using a transform:
Create a web.release.config file in the root of the project
Set that file's properties to Build Action = None so it doesn't get copied directly to the destination folder
Use the transformation syntax to define the sections that need to be inserted:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location>
<system.webServer>
<security xdt:Transform="Insert">
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200" />
</requestFiltering>
</security>
<rewrite xdt:Transform="Insert">
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<modules xdt:Transform="Insert" runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</location>
</configuration>

How do you add an xml file to the App_Data folder of a web site and then modify it with NuGet

I am creating a NuGet package that adds or modifies several xml files. I want the Nuget package to add and then modify the xml files, so the user does not have to do anything to get the file added if it does not exist. I need to modify the xml file to customize it for the specific application.
The code I am using in the .nuspec file is:
<files>
<file src="web.config.*.xdt" target="content"/>
<file src="App_Data\*.xml" target="content\App_Data"/>
<file src="App_Data\*.xml.*.xdt" target="content\App_Data"/>
<file src="favicon.ico" target="content\favicon.ico"/>
</files>
The code with will add the file if they do not exist, or modify them if they do, but it won't add them and then modify them.
Each file I am trying to add then modify as a .install.xml.xdt file associated with it.
I am using a custom RoleManager. The xml file contents are:
<?xml version="1.0" encoding="utf-8" ?>
<roleManager />
The xml.install file contains:
<?xml version="1.0" encoding="utf-8" ?>
<roleManager xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
xdt:Transform = "SetAttributes(defaultProvider,enabled,cacheRolesInCookie,cookieProtection)"
defaultProvider="RoleProvider"
enabled="true"
cacheRolesInCookie="true"
cookieProtection="All" >
<providers xdt:Transform="Insert" >
<clear />
<add name="RoleProvider" type="Library.RoleProvider" applicationName="$RootNamespace$" />
</providers>
</roleManager>
Is there any way to accomplish what I want to do?
I have a tentative approach to the problem: Create a dependent solution to add the files.
The dependent solution has the following nuspec section:
<files>
<file src="App_Data\*.xml" target="content\App_Data"/>
</files>
This nuget package is then listed as a dependency in the main library as such:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Timothy R Dooling</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<file src="App_Data\*.xml" target="content\App_Data"/>
<dependencies>
<dependency id="LibraryCore" version="1.0.0" />
</dependencies>
</metadata>
<files>
<file src="web.config.*.xdt" target="content"/>
<file src="App_Data\*.xml.*.xdt" target="content\App_Data"/>
<file src="favicon.ico" target="content\favicon.ico"/>
</files>
</package>
The only hassle with this approach is that you have to uninstall the dependency or hand-delete the added files in order to completely undo the changes made to the application.
It would be preferable since such changes could involve more than one dependencies if the nuspec in the main package would know enough to uninstall the dependent package.
Anyone know how to get it to do that?

Setting MIME type of a file from web.config

I have a temporary directory at:
c:\inetpub\mysite\temp\
I build a text file dynamically and save it to that directory. Then I have the users browser download that file by putting it into an iframe. This works fine for files that the browser can't open (.doc, .zip) but because I'm using a .txt file the browser just opens it. e.g. It never goes through the normal download process where you can pick where you want to have it downloaded.
A little research and I found you can put a web.config in the same directory as the file to configure the HTTP headers and then do something like:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".txt" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
But when I do that I get Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.txt' So I'm guessing at a web.config at a parent level is already setting the MIME type for .txt.
Is there a way to set the MIME type for static content in a leaf directory (or for a specific directory) using a web.congig file?
I found it. You have to remove the other one before adding.
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".txt" />
<mimeMap fileExtension=".txt" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension

I'm trying to configure the default webpage for an IIS 7.5 website.
Request filtering is turned on. However .aspx pages are allowed, I've set default.aspx to be the default page for the website.
If I browse to localhost/default.aspx I get a webpage as expected.
IF I browse to localhost/ I get
HTTP Error 404.7 - Not Found
The request filtering module is configured to deny the file extension.
Any ideas?
It looks like the request filtering is actually filtering for a blank file name. Therefore you have to add this to the request filtering block in the web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true">
<remove fileExtension="." />
<add fileExtension="." allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
It's obvious now, but really I think its a massive gotcha.
More info: IIS 7 Not Serving Files - 404.7 Error
You can resolve by adding:
<requestFiltering>
<fileExtensions allowUnlisted="true">
<remove fileExtension="." />
<add fileExtension="." allowed="true" />
</fileExtensions>
</requestFiltering>
to your Web.Config file
You can resolve this by adding the file extension into the request filtering module of IIS.
Be sure to remove any PostBackURL="MyPage.aspx" from the button on the page. My guess is that when the postbackurl is included, IIS thinks its getting the page as a file. It rejects the .aspx file type by default. You can see this in the page error.
Bad: Creates a 404.7 (notice the PostBackURL)
<asp:FileUpload runat="server" ID="uplReplaceFile" ToolTip="Update this file" />
<asp:Button runat="server" PostBackUrl="MyPage.ascx" ID="bnHiddenFileUploadListener" OnClick="bnHiddenFileUploadListener_OnClick" />
Good: No error
<asp:FileUpload runat="server" ID="uplReplaceFile" ToolTip="Update this file" />
<asp:Button runat="server" ID="bnHiddenFileUploadListener" OnClick="bnHiddenFileUploadListener_OnClick" />

SubSonic - dividing up web.config

I'm trying to divide up my web.config into multiple config files so that when I import the DLL to other projects, the .config files will also be imported.
Issue is with SubSonicService:
I've defined:
configSections
*section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/*
/**configsections**
But this doesn't allow me to use the configFile attribute later on in my web.config.
The error I get in the web.config is:
The element 'SubSonicService' has incomplete content. List of possible elements expected: 'providers'.
Any tips?
Thanks.
I have this and it works.
web.config
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
<!--Other Sections-->
</configSections>
<SubSonicService configSource="SubSonic.config"/>
<!--Other Stuff-->
</configuration>
SubSonic.config
<SubSonicService defaultProvider="yadayada">
<providers>
<!--List Providers Hers-->
</providers>
</SubSonicService>
I remember reading something about making sure SubSonicService was the first section in the configSections.

Resources