adding a template to cms page in magento - module

I'm hoping someone can help me with this. I've been trying to add a custom template to the list of available layouts when adding a CMS page to magento. I've followed this tutorial.
However, my custom template is not showing in the list of available layouts. I have been able to do this successfully by hacking the magneto core file as described at the end of that article, but would prefer to do it as a module.
I have created the following files
app/code/local/mycustom/template/config.xml
<?xml version="1.0"?>
<config>
<modules>
<mycustom_template>
<version>0.1.0</version>
</mycustom_template>
</modules>
<global>
<page>
<layouts>
<home translate="label">
<label>Home Page</label>
<template>page/home.phtml</template>
<layout_handle>custom_homepage</layout_handle>
</home>
</layouts>
</page>
</global>
</config>
and app/etc/modules/mycustom_template.xml
<?xml version="1.0"?>
<config>
<modules>
<mycustom_template>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Page />
</depends>
</mycustom_template>
</modules>
</config>

Create the file app/etc/modules/Easylife_Layout.xml
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Layout>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Page />
</depends>
</Easylife_Layout>
</modules>
</config>
also create app/code/local/Easylife/Layout/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Layout>
<version>0.0.1</version>
</Easylife_Layout>
</modules>
<global>
<page>
<layouts>
<custom_layout module="page" translate="label">
<label>Custom layout</label>
<template>page/custom_layout.phtml</template>
<layout_handle>custom_layout</layout_handle>
</custom_layout>
</layouts>
</page>
</global>
<frontend>
<layout>
<updates>
<easylife_layout>
<file>easylife_layout.xml</file>
</easylife_layout>
</updates>
</layout>
</frontend>
</config>
create app/design/frontend/your package/yourtheme/layout/easylife_layout.xml
<?xml version="1.0"?>
<layout>
<custom_layout translate="label">
<label>Custom layout</label>
<reference name="root">
<action method="setTemplate"><template>page/custom_layout.phtml</template></action>
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</custom_layout>
</layout>
and finally create app/design/frontend/your package/yourtheme/template/page/custom_layout.phtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper custom-layout">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container custom-layout-container">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
I hope it will be of help to you.

Take a look at /app/code/core/Mage/Page/etc/config.xml you will see what you need to add to your own xml file.
<global>
<page>
<layouts>
...
</layouts>
</page>
</global>

Related

Auto-Commit in Analysis Services Cube Writeback

is there any global setting in analysis services multidimensional (cubes) to auto commit transactions?
i.e.:
Step 1: A writeback statement like update cube is executed
<Header>
<BeginSession xmlns="urn:schemas-microsoft-com:xml-analysis"/>
</Header>
<Body>
<Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
<Command>
<Statement xmlns="urn:schemas-microsoft-com:xml-analysis">
UPDATE CUBE [Planung] SET
([Measures].[Kg]
[Artikel].[Produkt].[1])
= 66000
</Statement>
</Command>
<Properties>
<PropertyList>
<LocaleIdentifier>1033</LocaleIdentifier>
</PropertyList>
</Properties>
</Execute>
</Body>
Step 2: I have to commit the statement using the session Id from the response
<Header>
<Session xmlns="urn:schemas-microsoft-com:xml-analysis"
SessionId="9168D94F-BD3C-4E1B-8A9E-6F05BC9B2532" />
</Header>
<Body>
<Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
<Command>
<Statement xmlns="urn:schemas-microsoft-com:xml-analysis">
COMMIT
</Statement>
</Command>
<Properties>
<PropertyList>
<LocaleIdentifier>1033</LocaleIdentifier>
</PropertyList>
</Properties>
</Execute>
</Body>
I already went through many properties of my project and also through the prodiver settings but was not able to find anything helpful.
Thanks in advance.
Best regards

how to add new button to open module url on product view page using custom module

I want to add new button (Own Measurement) using custom module on product view page along with Add to cart button. on click new button it will redirect module's index.phtml.
my module config.xml file is:-
<?xml version="1.0"?>
<config>
<modules>
<SilkSoftware_Measurement>
<version>0.1.0</version>
</SilkSoftware_Measurement>
</modules>
<frontend>
<routers>
<measurement>
<use>standard</use>
<args>
<module>SilkSoftware_Measurement</module>
<frontName>measurement</frontName>
</args>
</measurement>
</routers>
<layout>
<updates>
<measurement>
<file>measurement.xml</file>
</measurement>
</updates>
</layout>
</frontend>
<global>
<helpers>
<measurement>
<class>SilkSoftware_Measurement_Helper</class>
</measurement>
</helpers>
<blocks>
<measurement>
<class>SilkSoftware_Measurement_Block</class>
</measurement>
</blocks>
</global>
<admin>
<routers>
<measurement>
<use>admin</use>
<args>
<module>SilkSoftware_Measurement</module>
<frontName>admin_measurement</frontName>
</args>
</measurement>
</routers>
</admin>
<adminhtml>
<menu>
<measurement module="measurement">
<title>Measurement</title>
<sort_order>100</sort_order>
<children>
<measurementbackend module="measurement">
<title>own measurement</title>
<sort_order>0</sort_order>
<action>admin_measurement/adminhtml_measurementbackend</action>
</measurementbackend>
</children>
</measurement>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<measurement translate="title" module="measurement">
<title>Measurement</title>
<sort_order>1000</sort_order>
<children>
<measurementbackend translate="title">
<title>own measurement</title>
</measurementbackend>
</children>
</measurement>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<measurement>
<file>measurement.xml</file>
</measurement>
</updates>
</layout>
</adminhtml>
</config>
I create this module with the help of Silksoftware and it show module frontend properly. i want whenever i install module then this button (Own Measurement) add automatically on product view page and on click button it will redirect to module index.phtml file.

Magento Custom Api Code can't pass in parameters (Undefined variable error)

Hello fellow Magento hackers,
I am trying to create a custom API handler and while I can get the function to run, passing in variables for some reason does not work and I get an empty parameter called in. System.log returns the error: DEBUG (7): Undefined variable: inputvar. Please help!
First things first, my directory structure at app/code/local is as follows:
Company
-Customapi
-etc
-api.xml
-config.xml
-wsdl.xml
-Model
-Order
-Api.php
-Api
-V2.php
Now for the code.
Api.php
class Company_Customapi_Model_Order_Api extends Mage_Api_Model_Resource_Abstract
{
public function test($inputvar){
echo $inputvar;
$result = $inputvar;
return $result;
}
}
V2.php
class Company_Customapi_Model_Order_Api_V2 extends Company_Customapi_Model_Order_Api {}
wsdl.xml:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"
schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
</schema>
</types>
<message name="getTestRequest">
<part name="inputvar" type="xsd:string"/>
</message>
<message name="getTestResponse">
<part name="result" type="xsd:string"/>
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="customapiOrderTest">
<documentation>Test the API.</documentation>
<input message="typens:getTestRequest"/>
<output message="typens:getTestResponse"/>
</operation>
</portType>
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="customapiOrderTest">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action"/>
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="{{var wsdl.name}}Service">
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}"/>
</port>
</service>
</definitions>
api.xml:
<?xml version="1.0"?>
<config>
<api>
<resources>
<customapi_order translate="title" module="company_customapi">
<model>company_customapi_model_order_api</model>
<title>company Order API</title>
<acl>order</acl>
<methods>
<test translate="title" module="company_customapi">
<title>A test function.</title>
<acl>test</acl>
</test>
</methods>
</customapi_order>
</resources>
<v2>
<resources_function_prefix>
<customapi_order>customapiOrder</customapi_order>
<!-- prefix+functionname = customapiOrderTest -->
</resources_function_prefix>
</v2>
</api>
</config>
config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Company_Customapi>
<version>0.1.0</version>
</Company_Customapi>
</modules>
<global>
<models>
<Company_Customapi>
<class>Company_Customapi_Model</class>
</Company_Customapi>
</models>
</global>
</config>
test.php:
$session = $client->login(SOAP_USER, SOAP_PASS);
$result = $client->customapiOrderTest($session, "inputvaluehere");
var_dump ( $result);
Found the answer. In Wsdl.xml you have to specify the session parameter as one of your inputs (your function on the server can't see it but you do pass it in from the client)
<message name="getTestRequest">
<part name="sessionId" type="xsd:string"/>
<part name="inputvar" type="xsd:string"/>
</message>
Only took me 2 days to find the answer. Don't you just love Magento!

Wide Logo on start Screen in window store app?

In my app I want set set my default logo as wide logo.When user pin to start my app wide logo will be shown how to do that?
I tried to edit manifest file but every thing is fine there
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="eaccc03b-ad21-4762-9c73-39835d6eb23b" Publisher="CN=Admin" Version="1.0.0.0" />
<Properties>
<DisplayName>App5</DisplayName>
<PublisherDisplayName>Admin</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="App5.App">
<m2:VisualElements DisplayName="Kids" Square150x150Logo="Assets\Logo.png" Square30x30Logo="Assets\SmallLogo.png" Description="App5" ForegroundText="light" BackgroundColor="#464646">
<m2:DefaultTile Wide310x150Logo="Assets\WideLogo.png">
<m2:ShowNameOnTiles>
<m2:ShowOn Tile="wide310x150Logo" />
</m2:ShowNameOnTiles>
</m2:DefaultTile>
<m2:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#ffffff" />
<m2:InitialRotationPreference>
<m2:Rotation Preference="landscape" />
</m2:InitialRotationPreference>
</m2:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
Just add DefaultSize property:
<m2:DefaultTile Wide310x150Logo="Assets\WideLogo.png" DefaultSize="wide310x150Logo">
...
</m2:DefaultTile>
this will make the Wide Tile as Default tile. if you want the 150*150 logo as default,just change DefaultSize as DefaultSize="square150x150Logo"

Magento API: Publish a new method in soap V2

I'm new in Magento and I'd like to create a my own API v2 method.
I've built a simple project...
Mycompany
Mymodule
etc
api.xml
config.xml
wsdl.xml
Model
Api
V2.php
Api.php
These are the main files...
(1) api.xml
<config>
<api>
<resources>
<mymodule translate="title" module="mymodule">
<title>mymodule</title>
<model>mymodule/api</model>
<methods>
<myapimethod translate="title" module="mymodule">
<title>myapimethod</title>
<acl>mymodule/myapimethod</acl>
</myapimethod>
</methods>
</mymodule>
</resources>
<v2>
<resources_function_prefix>
<mymodule>mymodule</mymodule>
</resources_function_prefix>
</v2>
<acl>
<resources>
<mymodule translate="title" module="mymodule">
<title>Mymodule</title>
<sort_order>2000</sort_order>
<myapimethod translate="title" module="mymodule">
<title>myapimethod</title>
</myapimethod>
</mymodule>
</resources>
</acl>
</api>
</config>
(2) wsdl.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
</schema>
</types>
<message name="myapimethodRequest">
<part name="sessionId" type="xsd:string"/>
<part name="message" type="xsd:string" />
</message>
<message name="myapimethodResponse">
<part name="result" type="xsd:string" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="myapimethod">
<documentation>this is an example of api method...</documentation>
<input message="typens:myapimethodRequest" />
<output message="typens:myapimethodResponse" />
</operation>
</portType>
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="myapimethod">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="{{var wsdl.name}}Service">
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</port>
</service>
</definitions>
(3) Api.php
<?php
class Mycompany_Mymodule_Model_Api extends Mage_Api_Model_Resource_Abstract
{
public function myapimethod($sessionId, $message)
{
return "This is the message : ".$message;
}
}
(4) V2.php
<?php
class Mycompany_Mymodule_Model_Api_V2 extends Mycompany_Mymodule_Model_Api
{
}
(5) test.php
<?php
try {
define("SOAP_WSDL",'http://localhost:8080/magento/index.php/api/?wsdl');
define("SOAP_WSDL2",'http://localhost:8080/magento/index.php/api/v2_soap?wsdl=1');
define("SOAP_USER","dtsSoapUser");
define("SOAP_PASS","casares");
if($_GET['ver'] == '2') {
$client = new SoapClient(SOAP_WSDL2, array('trace' => 1,'cache_wsdl' => 0));
echo "<br>version 2 <br>";
}
else {
$client = new SoapClient(SOAP_WSDL,array('trace' => 1,'cache_wsdl' => 0));
echo "<br>version 1 <br>";
}
$session = $client->login(SOAP_USER, SOAP_PASS);
$result = array();
try {
if($_GET['ver'] == '2') {
$result = $client->Myapimethod($session, "My message....");
var_dump ( $result);
} else {
$result= $client->call($session, 'mymodule.myapimethod', array($session, "My message ...."));
var_dump($result);
}
} catch (SoapFault $exception) {
echo 'EXCEPTION='.$exception;
}
echo "<br>end test<br>";
} catch (Exception $e){
echo var_dump($e);
throw $e;
}
?>
Using the following Url, the result is:
.../test.php/?ver=1
version 1
string 'This is the message : My message ....' (length=37)
end test
It's to say: using Soap v1, the method works!.
But if I use the soap v2 call...
.../test.php/?ver=2
the result is:
version 2
EXCEPTION=SoapFault exception: [3] Invalid api path. in C:\wamp\www\PruebasPHP\test.php:22 Stack trace: #0 C:\wamp\www\PruebasPHP\test.php(22): SoapClient->__call('Myapimethod', Array) #1 C:\wamp\www\PruebasPHP\test.php(22): SoapClient->Myapimethod('b9e1e8d15a61398...', 'My message....') #2 {main}
end test
The role has access to all the api resources...
I don't know what is wrong? can anyone help me with this problem?
Can be anything related to acl's?
Thanks in advance!!!
It's a problem of path.
I've solve the problems as follows...
The folder structure of my project is:
Mycompany->
Mymodule->
etc->
api.xml
config.xml
wsdl.xml
wsi.xml
Model->
Folder->
Api.php
Api->
V2.ph
(1) api.xml
<?xml version="1.0"?>
<config>
<api>
<resources>
<mymodule_folder translate="title" module="mymodule">
<title>mymodule</title>
<!-- acl>mymodule/api</acl>-->
<model>mymodule/folder_api</model>
<acl>mymodule/folder</acl>
<methods>
<myapimethod translate="title" module="mymodule">
<title>myapimethod</title>
<acl>mymodule/folder/myapimethod</acl>
</myapimethod>
</methods>
</mymodule_folder>
</resources>
<resources_alias>
<folder>mymodule_folder</folder>
</resources_alias>
<v2>
<resources_function_prefix>
<folder>folder</folder>
</resources_function_prefix>
</v2>
<acl>
<resources>
<mymodule translate="title" module="mymodule">
<title>mymodule</title>
<sort_order>1</sort_order>
<folder translate="title" module="mymodule">
<title>Folder</title>
<sort_order>2000</sort_order>
<myapimethod translate="title" module="mymodule">
<title>myapimethod</title>
</myapimethod>
</folder>
</mymodule>
</resources>
</acl>
</api>
</config>
Pay attention to the name of the api method "myapimethod" and the folder "Model\Folder".
(2) wsdl.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
</schema>
</types>
<message name="folderMyapimethodRequest">
<part name="sessionId" type="xsd:string"/>
<part name="message" type="xsd:string" />
</message>
<message name="folderMyapimethodResponse">
<part name="result" type="xsd:string" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="folderMyapimethod">
<documentation>this is an example of api method...</documentation>
<input message="typens:folderMyapimethodRequest" />
<output message="typens:folderMyapimethodResponse" />
</operation>
</portType>
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="folderMyapimethod">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="{{var wsdl.name}}Service">
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</port>
</service>
</definitions>
The name of the api method must be: folderMethodname", where "folder" is the name of the folder under the "Model" where the api method is declared.., in our case : "folderMyapimethod"
(3) api.php
<?php
class Mycompany_Mymodule_Model_Folder_Api extends Mage_Api_Model_Resource_Abstract
{
public function myapimethod( $message)
{
return "This is the message: ".$message;
}
}
(4) V2.php
<?php
class Mycompany_Mymodule_Model_Folder_Api_V2 extends Mycompany_Mymodule_Model_Folder_Api
{
//empty
}
(5) test.php
$result = $client->folderMyapimethod($session,$message);
This line shows how to call to my api method...
It works!
Your code is excellent ! there's no mistake on
As far as i know (from my experience). that exception shown because your tag placement on your api.xml doesn't match with you called function.
check on files
core\Mage\Catalog\Model\Product\Api.php
and
core\Mage\Catalog\Model\Product\Api\V2.php
there is a function named items on both class.
maybe you must add your code on api_v1 on api_v2 class like this:
<?php
class Mycompany_Mymodule_Model_Api_V2 extends Mycompany_Mymodule_Model_Api
{
public function myapimethod($sessionId, $message)
{
return "This is the message : ".$message;
}
}
or
maybe it's cache.
The cache is strong, because it's API V2. try to clear your cache on:
admin -> system -> cache management -> clear magento cache.
try to clear wsdl.xml cache on /tmp/wsdl.xml (hidden on your server) try to grep it.
remove all files on var/log/*