include xml in xml Joomla - joomla

Is there any way to include xml file in to another in Joomla 2.5 and up?
I am not asking how to write joomla xml params. Question is simple as title .
Is there a way to include one xml in to another in Joomla ?
I have 2 files templateDetails.xml and extend.xml
used these examples:
http://msdn.microsoft.com/en-us/library/aa302291.aspx
Can we import XML file into another XML file?
start code
templateDetails.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 2.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd" [
<!ENTITY extend SYSTEM "extend.xml">
]>
<extension version="2.5" type="template" client="site" method="upgrade">
<name>...</name>
<creationDate>...</creationDate>
<author>...</author>
<copyright>...</copyright>
<authorEmail>...</authorEmail>
<authorUrl>...</authorUrl>
<version>1.0</version>
<positions>
<position>top</position>
</positions>
<config>
<fields name="params">
<fieldset name="basic">
&extend;
</fieldset>
</fields>
</config>
</extension>
extend.xml:
<?xml version="1.0" encoding="utf-8"?>
<field name="somevar" type="list" default="2" label="My label" description="My desc">
<option value="1">Yes</option>
<option value="2">No</option>
</field>
I either made mistake somewhere or should use another approach. Any help is appreciated,

Unfortunately I don't think this is possible with Joomla. It is something I have looked at to reduce xml code duplication in Joomla components I am developing. I was searching Stack OVerflow to see if any solution was on here. The problem is in the way Joomla loads the xml files. It uses $xml = simplexml_load_file($file) to load files but to use entity expansion this would need to be changed to $xml = simplexml_load_file($file,null, LIBXML_NOENT). There are multiple locations where Joomla loads xml files so each would need to be changed. I don't know if there is a specific reason the Joomla developers did not use the extended form or may be I have missed something and there is a way to do this. I have it down as something to investigate further and possibly raise as a pull request for a later release of Joomla (I've checked in release 3.2.4 and it hasn't changed).

Related

Where to put a simple callable php script in Joomla directory

I have some Joomla HTML content which contains a simple HTML form which results should available to a simple PHP script.
Basically the HTML form looks like:
<form action="action.php" method="post">
The question is where can/should I put my action.php script in the Joomla project directory to be
callable for my form action and
not overwritten by Joomla updates
I would recommend creating a component for forms. You probably need to handle the input in your form, and do some action based on what is in the form, and return the form if there are errors, etc.
Simplest way to make a component:
add a folder in components: /components/com_whatever
Add php-file: whatever.php in folder com_whatever
Add xml-file: whatever.xml
Content of whatever.xml:
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">
<name>Whatever</name>
<version>1.0.0.0</version>
<files folder="site">
<filename>whatever.php</filename>
</files>
<administration>
</administration>
</extension>
Content of whatever.php:
<?php
defined('_JEXEC') or die;
echo "HELLOOOO";
// or rather some code handling your form data
Install the component by going to yoursite/administrator/index.php?option=com_installer&view=discover
Now you can reach whatever.php from the form, using:
<form action="index.php?option=com_whatever" method="post">
There is lots of stuff you can and probably should do in your component, but this is the bare minimum.
PS: You could install a form component, there are lots. Alternatively you could use a component-builder to create your form, then you also get admin-tools to handle the incoming data.
For that you have to create joomla content plugins, using content plugin you can handle form submit action.
For Reference:
https://docs.joomla.org/J3.x:Creating_a_content_plugin

support unicode in magento product url key

I would like to use my language (not english) for url key. I research and found there're some tutorial on : http://rakan.me/2012/07/19/support-unicode-in-magento-product-url-key/ but it show 404 not found already.
anyway someone give this link to download: https://github.com/Minglong/Magento-unicode-URL
but in this zip file it contains only module folder(Model and etc). so I think I need to write the rest myself. Please advice me how can I implement this module.
Or anyone ever try this module, is it working ?
Thks
All the code from GITHUB is fine. You just need to add the below code at app/etc/modules/Rakanalh_UnicodeUrls.xml
<?xml version="1.0" ?>
<config>
<modules>
<Rakanalh_UnicodeUrls>
<active>true</active>
<codePool>local</codePool>
</Rakanalh_UnicodeUrls>
</modules>
</config>
If you place the above code from github in local folder then the codePool tag has to be local or else if you place it in community folder then codePool tag has to be community.

how to change email format from html to text in magento for admin?

in magento on order confirmation email is sent to admin in HTML format,
but i want to change it to plain text format so how and from where i can change that format only for admin, customer should get email in HTMl format as it is.
Can anyone please give me solution for this?
Thanks.
For future readers, do not edit core files as others suggest. You can achieve this in config alone with a tiny custom module.
I have AheadWorks' blog module installed, you may not, or you may have other modules that need their email format overridden. So, adjust accordingly.
Create app/etc/modules/YourNameSpace_EmailFormat.xml and add to <depends>, so your config is loaded last:
<?xml version="1.0"?>
<config>
<modules>
<YourNameSpace_EmailFormat>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Contacts/>
<AW_Blog/>
</depends>
</YourNameSpace_EmailFormat>
</modules>
</config>
Create app/code/local/YourNameSpace/EmailFormat/etc/config.xml, adding elements for all the templates you wish to override:
<?xml version="1.0"?>
<config>
<modules>
<YourNameSpace_EmailFormat>
<version>1</version>
</YourNameSpace_EmailFormat>
</modules>
<global>
<template>
<email>
<customer_create_account_email_template>
<type>text</type>
</customer_create_account_email_template>
</email>
</template>
</global>
</config>
That's it. I needed the reverse, so I had <type> set to html. This goes very well with Yireo's Email Override module so you can easily customise your templates. If converting plain text emails to HTML, be sure to change template tags like {{var foo.bar}} to {{htmlescape var=$foo.bar}} to prevent malicious code injections.
First create custom email template from Transactions emails and text type set as plain. Note down that template Id. and use in below file.
At \app\code\local\Mage\Sales\Model\Order.php sendNewOrderEmail() load manually template is and sent variables to that and send email.
you have to override and extend the Mage_Core_Model_Email_Template model to achieve this and set the correct header from there and you can't separate those by user and you ahve to build your own logic for that

Magento: add a modified header.phtml to a copy of empty.phtml file for a custom module

I have created a custom module for a landing page after default customer login, I'm using the blank template page : empty.phtml;
I want now to add to "empty.phtml" an edited version of footer and header.phtml, without editing the original versions of this files.
How can I do that ??
Thanks a lot.
Try put it to landing page's section into your layout file:
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<your_landing_page>
<reference name="header">
<action method="setTemplate"><template>your_module/header_file.phtml</template></action>
</reference>
...

Nesting of layout tag in Magento xml

I am not sure where to keep my layout xml in the custom module. Does it go in the config.xml of the module or a separate layout.xml is needed. How does Magento picks up the layout xml?
Right now I am using it like this, which doesn't work. A bit clueless here, any pointers? Code samples work great for me :)
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Ashfame_Adminoverrider>
<version>1.0.0</version>
</Ashfame_Adminoverrider>
</modules>
<global>
<layout>
<adminhtml_sales_order_create_index>
<reference name="root">
<reference name="form">
<reference name="data">
<block type="ashfame_adminoverrider/sales_order_create_shipping_address" as="shipping_address" template="ashfame/adminoverrider/sales/order/create/form/address.phtml" />
</reference>
</reference>
</reference>
</adminhtml_sales_order_create_index>
</layout>
</global>
</config>
Config XML and layout XML are two different things.
The config.xml files can be used to tell Magento to load a new layout xml file. Search for catalog.xml in
app/code/core/Mage/Catalog/etc/config.xml
for the correct place to put the nodes in your own XML files. You're looking for something like this
<catalog>
<file>catalog.xml</file>
</catalog>
<map>
<file>catalog_msrp.xml</file>
</map>
One you're there, place your globally uniquely named xml file in the base design package's layout folder and/or your theme's layout folder.
That should be enough to get you googling. Good luck.

Resources